tools/jprof/leaky.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/jprof/leaky.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,122 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef __leaky_h_
     1.9 +#define __leaky_h_
    1.10 +
    1.11 +#include "config.h"
    1.12 +#include <stdio.h>
    1.13 +#include <string.h>
    1.14 +#include <sys/types.h>
    1.15 +#include "libmalloc.h"
    1.16 +#include "strset.h"
    1.17 +#include "intcnt.h"
    1.18 +
    1.19 +typedef unsigned int u_int;
    1.20 +
    1.21 +struct Symbol;
    1.22 +struct leaky;
    1.23 +
    1.24 +class FunctionCount : public IntCount
    1.25 +{
    1.26 +public:
    1.27 +  void printReport(FILE *fp, leaky *lk, int parent, int total);
    1.28 +};
    1.29 +
    1.30 +struct Symbol {
    1.31 +  char* name;
    1.32 +  u_long address;
    1.33 +  int    timerHit;
    1.34 +  FunctionCount cntP, cntC;
    1.35 +
    1.36 +  int regChild(int id) {return cntC.countAdd(id, 1);}
    1.37 +  int regParrent(int id) {return cntP.countAdd(id, 1);}
    1.38 +  void regClear() {cntC.clear(); cntP.clear();}
    1.39 +
    1.40 +  Symbol() : timerHit(0) {}
    1.41 +  void Init(const char* aName, u_long aAddress) {
    1.42 +    name = aName ? strdup(aName) : (char *)"";
    1.43 +    address = aAddress;
    1.44 +  }
    1.45 +};
    1.46 +
    1.47 +struct LoadMapEntry {
    1.48 +  char* name;			// name of .so
    1.49 +  u_long address;		// base address where it was mapped in
    1.50 +  LoadMapEntry* next;
    1.51 +};
    1.52 +
    1.53 +struct leaky {
    1.54 +  leaky();
    1.55 +  ~leaky();
    1.56 +
    1.57 +  void initialize(int argc, char** argv);
    1.58 +  void open(char *arg);
    1.59 +
    1.60 +  char*  applicationName;
    1.61 +  int    logFileIndex;
    1.62 +  int    numLogFiles;
    1.63 +  char*  progFile;
    1.64 +  FILE*  outputfd;
    1.65 +
    1.66 +  bool  quiet;
    1.67 +  bool  showAddress;
    1.68 +  bool  showThreads;
    1.69 +  bool  cleo;
    1.70 +  u_int stackDepth;
    1.71 +  int   onlyThread;
    1.72 +  char* output_dir;
    1.73 +
    1.74 +  int   mappedLogFile;
    1.75 +  malloc_log_entry* firstLogEntry;
    1.76 +  malloc_log_entry* lastLogEntry;
    1.77 +
    1.78 +  int    stacks;
    1.79 +
    1.80 +  int sfd;
    1.81 +  Symbol** externalSymbols;
    1.82 +  Symbol** lastSymbol;
    1.83 +  int     usefulSymbols;
    1.84 +  int     numExternalSymbols;
    1.85 +  StrSet exclusions;
    1.86 +  u_long lowestSymbolAddr;
    1.87 +  u_long highestSymbolAddr;
    1.88 +
    1.89 +  LoadMapEntry* loadMap;
    1.90 +
    1.91 +  bool collect_last;
    1.92 +  int  collect_start;
    1.93 +  int  collect_end;
    1.94 +
    1.95 +  StrSet roots;
    1.96 +  StrSet includes;
    1.97 +
    1.98 +  void usageError();
    1.99 +
   1.100 +  void LoadMap();
   1.101 +
   1.102 +  void analyze(int thread);
   1.103 +
   1.104 +  void dumpEntryToLog(malloc_log_entry* lep);
   1.105 +
   1.106 +  void insertAddress(u_long address, malloc_log_entry* lep);
   1.107 +  void removeAddress(u_long address, malloc_log_entry* lep);
   1.108 +
   1.109 +  void displayStackTrace(FILE* out, malloc_log_entry* lep);
   1.110 +
   1.111 +  Symbol ** ExtendSymbols(int num);
   1.112 +  void ReadSymbols(const char* fileName, u_long aBaseAddress);
   1.113 +  void ReadSharedLibrarySymbols();
   1.114 +  void setupSymbols(const char* fileName);
   1.115 +  Symbol* findSymbol(u_long address);
   1.116 +  bool excluded(malloc_log_entry* lep);
   1.117 +  bool included(malloc_log_entry* lep);
   1.118 +  const char* indexToName(int idx) {return externalSymbols[idx]->name;}
   1.119 +
   1.120 +  private:
   1.121 +  void generateReportHTML(FILE *fp, int *countArray, int count, int thread);
   1.122 +  int  findSymbolIndex(u_long address);
   1.123 +};
   1.124 +
   1.125 +#endif /* __leaky_h_ */

mercurial