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.

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

mercurial