tools/jprof/leaky.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef __leaky_h_
     6 #define __leaky_h_
     8 #include "config.h"
     9 #include <stdio.h>
    10 #include <string.h>
    11 #include <sys/types.h>
    12 #include "libmalloc.h"
    13 #include "strset.h"
    14 #include "intcnt.h"
    16 typedef unsigned int u_int;
    18 struct Symbol;
    19 struct leaky;
    21 class FunctionCount : public IntCount
    22 {
    23 public:
    24   void printReport(FILE *fp, leaky *lk, int parent, int total);
    25 };
    27 struct Symbol {
    28   char* name;
    29   u_long address;
    30   int    timerHit;
    31   FunctionCount cntP, cntC;
    33   int regChild(int id) {return cntC.countAdd(id, 1);}
    34   int regParrent(int id) {return cntP.countAdd(id, 1);}
    35   void regClear() {cntC.clear(); cntP.clear();}
    37   Symbol() : timerHit(0) {}
    38   void Init(const char* aName, u_long aAddress) {
    39     name = aName ? strdup(aName) : (char *)"";
    40     address = aAddress;
    41   }
    42 };
    44 struct LoadMapEntry {
    45   char* name;			// name of .so
    46   u_long address;		// base address where it was mapped in
    47   LoadMapEntry* next;
    48 };
    50 struct leaky {
    51   leaky();
    52   ~leaky();
    54   void initialize(int argc, char** argv);
    55   void open(char *arg);
    57   char*  applicationName;
    58   int    logFileIndex;
    59   int    numLogFiles;
    60   char*  progFile;
    61   FILE*  outputfd;
    63   bool  quiet;
    64   bool  showAddress;
    65   bool  showThreads;
    66   bool  cleo;
    67   u_int stackDepth;
    68   int   onlyThread;
    69   char* output_dir;
    71   int   mappedLogFile;
    72   malloc_log_entry* firstLogEntry;
    73   malloc_log_entry* lastLogEntry;
    75   int    stacks;
    77   int sfd;
    78   Symbol** externalSymbols;
    79   Symbol** lastSymbol;
    80   int     usefulSymbols;
    81   int     numExternalSymbols;
    82   StrSet exclusions;
    83   u_long lowestSymbolAddr;
    84   u_long highestSymbolAddr;
    86   LoadMapEntry* loadMap;
    88   bool collect_last;
    89   int  collect_start;
    90   int  collect_end;
    92   StrSet roots;
    93   StrSet includes;
    95   void usageError();
    97   void LoadMap();
    99   void analyze(int thread);
   101   void dumpEntryToLog(malloc_log_entry* lep);
   103   void insertAddress(u_long address, malloc_log_entry* lep);
   104   void removeAddress(u_long address, malloc_log_entry* lep);
   106   void displayStackTrace(FILE* out, malloc_log_entry* lep);
   108   Symbol ** ExtendSymbols(int num);
   109   void ReadSymbols(const char* fileName, u_long aBaseAddress);
   110   void ReadSharedLibrarySymbols();
   111   void setupSymbols(const char* fileName);
   112   Symbol* findSymbol(u_long address);
   113   bool excluded(malloc_log_entry* lep);
   114   bool included(malloc_log_entry* lep);
   115   const char* indexToName(int idx) {return externalSymbols[idx]->name;}
   117   private:
   118   void generateReportHTML(FILE *fp, int *countArray, int count, int thread);
   119   int  findSymbolIndex(u_long address);
   120 };
   122 #endif /* __leaky_h_ */

mercurial