More graph work

This commit is contained in:
kipp%netscape.com 1999-09-30 21:22:16 +00:00
parent c5af3f5d7f
commit 57481c7e75
4 changed files with 45 additions and 12 deletions

View File

@ -90,7 +90,7 @@ leaky::~leaky()
void leaky::usageError()
{
fprintf(stderr,
"Usage: %s [-aAEdfgqx] [-e name] [-s depth] [-h hash-buckets] prog log\n",
"Usage: %s [-aAEdfgqx] [-e name] [-s depth] [-h hash-buckets] [-r root] prog log\n",
(char*) applicationName);
exit(-1);
}
@ -107,7 +107,7 @@ void leaky::initialize(int argc, char** argv)
int arg;
int errflg = 0;
while ((arg = getopt(argc, argv, "adEe:fgh:s:tqx")) != -1) {
while ((arg = getopt(argc, argv, "adEe:fgh:r:s:tqx")) != -1) {
switch (arg) {
case '?':
errflg++;
@ -132,6 +132,9 @@ void leaky::initialize(int argc, char** argv)
dumpGraph = TRUE;
if (dumpAll) errflg++;
break;
case 'r':
roots.add(optarg);
break;
case 'h':
buckets = atoi(optarg);
if ((buckets < 0) || (buckets > MaxBuckets)) {
@ -480,8 +483,13 @@ void leaky::buildLeakGraph()
Symbol* sym = findSymbol((u_long) *pcp);
TreeNode* node = sym->root;
if (!node) {
displayStackTrace(stderr, lep);
sym->root = node = new TreeNode(sym);
// Add root to list of roots
if (roots.IsEmpty()) {
node->nextRoot = rootList;
rootList = node;
}
}
pcp--;
@ -498,6 +506,14 @@ void leaky::buildLeakGraph()
nextNode = node->AddDescendant(sym);
}
// See if the symbol is to be a user specified root. If it is,
// and we haven't already stuck it on the root-list do so now.
if (!sym->root && !roots.IsEmpty() && roots.contains(sym->name)) {
sym->root = nextNode;
nextNode->nextRoot = rootList;
rootList = nextNode;
}
if (pcp == basepcp) {
nextNode->bytesLeaked += lep->size;
}
@ -532,6 +548,8 @@ void leaky::dumpLeakGraph()
printf("<span class=b>Bytes directly leaked</span><br>\n");
printf("<span class=d>Bytes leaked by descendants</span></div>\n");
}
#if 0
Symbol* base = externalSymbols;
Symbol* end = externalSymbols + usefulSymbols;
while (base < end) {
@ -540,6 +558,13 @@ void leaky::dumpLeakGraph()
dumpLeakTree(sym->root, 0);
base = sym + 1;
}
#else
TreeNode* root = rootList;
while (root) {
dumpLeakTree(root, 0);
root = root->nextRoot;
}
#endif
if (dumpHTML) {
printf("</body></html>\n");
}

View File

@ -29,6 +29,7 @@ struct TreeNode {
symbol = aSymbol;
nextSibling = NULL;
descendants = NULL;
nextRoot = NULL;
}
TreeNode* GetDirectDescendant(Symbol* aSymbol);
@ -41,6 +42,7 @@ struct TreeNode {
TreeNode* descendants;
TreeNode* nextSibling;
TreeNode* nextRoot;
Symbol* symbol;
u_long bytesLeaked;
@ -113,6 +115,10 @@ struct leaky {
LoadMapEntry* loadMap;
TreeNode* rootList;
StrSet roots;
void usageError();
void LoadMap();

View File

@ -3,8 +3,9 @@ function I(event) {
var it = event.target;
if (it) {
var s = it.src;
var s1 = s.replace(".gif", "-over.gif");
it.src = s1;
s = s.replace("-over", ""); // just in case
s = s.replace(".gif", "-over.gif");
it.src = s;
lastIn = it;
}
}
@ -12,8 +13,8 @@ function O(event) {
var it = lastIn;
if (it) {
var s = it.src;
var s1 = s.replace("-over", "");
it.src = s1;
s = s.replace("-over", "");
it.src = s;
lastIn = null;
}
}

View File

@ -14,13 +14,14 @@
#define __strset_h_
struct StrSet {
StrSet();
StrSet();
void add(const char* string);
int contains(const char* string);
void add(const char* string);
int contains(const char* string);
bool IsEmpty() const { return 0 == numstrings; }
char** strings;
int numstrings;
char** strings;
int numstrings;
};
#endif /* __strset_h_ */