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/. */
11 #include <sys/types.h>
12 #include "libmalloc.h"
16 typedef unsigned int u_int
;
21 class FunctionCount
: public IntCount
24 void printReport(FILE *fp
, leaky
*lk
, int parent
, int total
);
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 *)"";
45 char* name
; // name of .so
46 u_long address
; // base address where it was mapped in
54 void initialize(int argc
, char** argv
);
57 char* applicationName
;
72 malloc_log_entry
* firstLogEntry
;
73 malloc_log_entry
* lastLogEntry
;
78 Symbol
** externalSymbols
;
81 int numExternalSymbols
;
83 u_long lowestSymbolAddr
;
84 u_long highestSymbolAddr
;
86 LoadMapEntry
* 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
;}
118 void generateReportHTML(FILE *fp
, int *countArray
, int count
, int thread
);
119 int findSymbolIndex(u_long address
);
122 #endif /* __leaky_h_ */