Bug 1874683 - Part 10: Inline String.prototype.at in CacheIR. r=jandem
[gecko.git] / tools / jprof / leaky.h
blob6c9beb7b4259c0f250baa81aee8ee0c9e03c7219
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 public:
23 void printReport(FILE* fp, leaky* lk, int parent, int total);
26 struct Symbol {
27 char* name;
28 u_long address;
29 int timerHit;
30 FunctionCount cntP, cntC;
32 int regChild(int id) { return cntC.countAdd(id, 1); }
33 int regParrent(int id) { return cntP.countAdd(id, 1); }
34 void regClear() {
35 cntC.clear();
36 cntP.clear();
39 Symbol() : timerHit(0) {}
40 void Init(const char* aName, u_long aAddress) {
41 name = aName ? strdup(aName) : (char*)"";
42 address = aAddress;
46 struct LoadMapEntry {
47 char* name; // name of .so
48 u_long address; // base address where it was mapped in
49 LoadMapEntry* next;
52 struct leaky {
53 leaky();
54 ~leaky();
56 void initialize(int argc, char** argv);
57 void open(char* arg);
59 char* applicationName;
60 int logFileIndex;
61 int numLogFiles;
62 char* progFile;
63 FILE* outputfd;
65 bool quiet;
66 bool showAddress;
67 bool showThreads;
68 bool cleo;
69 u_int stackDepth;
70 int onlyThread;
71 char* output_dir;
73 int mappedLogFile;
74 malloc_log_entry* firstLogEntry;
75 malloc_log_entry* lastLogEntry;
77 int stacks;
79 int sfd;
80 Symbol** externalSymbols;
81 Symbol** lastSymbol;
82 int usefulSymbols;
83 int numExternalSymbols;
84 StrSet exclusions;
85 u_long lowestSymbolAddr;
86 u_long highestSymbolAddr;
88 LoadMapEntry* loadMap;
90 bool collect_last;
91 int collect_start;
92 int collect_end;
94 StrSet roots;
95 StrSet includes;
97 void usageError();
99 void 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; }
119 private:
120 void generateReportHTML(FILE* fp, int* countArray, int count, int thread);
121 int findSymbolIndex(u_long address);
124 #endif /* __leaky_h_ */