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
{
23 void printReport(FILE* fp
, leaky
* lk
, int parent
, int total
);
30 FunctionCount cntP
, cntC
;
32 int regChild(int id
) { return cntC
.countAdd(id
, 1); }
33 int regParrent(int id
) { return cntP
.countAdd(id
, 1); }
39 Symbol() : timerHit(0) {}
40 void Init(const char* aName
, u_long aAddress
) {
41 name
= aName
? strdup(aName
) : (char*)"";
47 char* name
; // name of .so
48 u_long address
; // base address where it was mapped in
56 void initialize(int argc
, char** argv
);
59 char* applicationName
;
74 malloc_log_entry
* firstLogEntry
;
75 malloc_log_entry
* lastLogEntry
;
80 Symbol
** externalSymbols
;
83 int numExternalSymbols
;
85 u_long lowestSymbolAddr
;
86 u_long highestSymbolAddr
;
88 LoadMapEntry
* loadMap
;
101 void analyze(int thread
);
103 void dumpEntryToLog(malloc_log_entry
* lep
);
105 void insertAddress(u_long address
, malloc_log_entry
* lep
);
106 void removeAddress(u_long address
, malloc_log_entry
* lep
);
108 void displayStackTrace(FILE* out
, malloc_log_entry
* lep
);
110 Symbol
** ExtendSymbols(int num
);
111 void ReadSymbols(const char* fileName
, u_long aBaseAddress
);
112 void ReadSharedLibrarySymbols();
113 void setupSymbols(const char* fileName
);
114 Symbol
* findSymbol(u_long address
);
115 bool excluded(malloc_log_entry
* lep
);
116 bool included(malloc_log_entry
* lep
);
117 const char* indexToName(int idx
) { return externalSymbols
[idx
]->name
; }
120 void generateReportHTML(FILE* fp
, int* countArray
, int count
, int thread
);
121 int findSymbolIndex(u_long address
);
124 #endif /* __leaky_h_ */