From 797c2fddf2f88fa14e9a401c349d2aa8213130a4 Mon Sep 17 00:00:00 2001 From: "alecf%flett.org" Date: Tue, 17 Jun 2003 23:01:46 +0000 Subject: [PATCH] minor warnings cleanup, make a htmlStartTable() method to consolidate some code not part of the build git-svn-id: svn://10.0.0.236/trunk@143823 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/tools/trace-malloc/bloatblame.c | 1 + mozilla/tools/trace-malloc/spacetrace.c | 82 +++++++++++++++---------- mozilla/tools/trace-malloc/tmreader.c | 6 +- 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/mozilla/tools/trace-malloc/bloatblame.c b/mozilla/tools/trace-malloc/bloatblame.c index 678e052f441..b3fcb450cc0 100644 --- a/mozilla/tools/trace-malloc/bloatblame.c +++ b/mozilla/tools/trace-malloc/bloatblame.c @@ -55,6 +55,7 @@ extern int optind; #include "prlog.h" #include "prprf.h" #include "plhash.h" +#include "pldhash.h" #include "nsTraceMalloc.h" #include "tmreader.h" diff --git a/mozilla/tools/trace-malloc/spacetrace.c b/mozilla/tools/trace-malloc/spacetrace.c index dafa7e057a0..9153504ce9d 100644 --- a/mozilla/tools/trace-malloc/spacetrace.c +++ b/mozilla/tools/trace-malloc/spacetrace.c @@ -2387,6 +2387,22 @@ htmlNotFound(STRequest * inRequest) htmlFooter(inRequest); } +void +htmlStartTable(STRequest* inRequest, const char* table_class, const char * const headers[], PRUint32 header_length) +{ + PRUint32 i; + + PR_fprintf(inRequest->mFD, + "\n" + " \n", table_class ? table_class : ""); + + for (i=0; i< header_length; i++) + PR_fprintf(inRequest->mFD, + " \n", headers[i]); + + PR_fprintf(inRequest->mFD, "\n"); +} + /* ** callsiteArrayFromCallsite ** @@ -2684,19 +2700,22 @@ displayTopAllocations(STRequest * inRequest, STRun * aRun, int aWantCallsite) PRUint32 loop = 0; STAllocation *current = NULL; - PR_fprintf(inRequest->mFD, "
%s
\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - if (0 != aWantCallsite) { - PR_fprintf(inRequest->mFD, "\n"); - } - PR_fprintf(inRequest->mFD, "\n"); + static const char* const headers[] = { + "Rank", "Index", "Byte Size", "Lifespan (sec)", + "Weight", "Heap Op (sec)" + }; + + static const char* const headers_callsite[] = { + "Rank", "Index", "Byte Size", "Lifespan (sec)", + "Weight", "Heap Op (sec)", "Origin Callsite" + }; + if (aWantCallsite) + htmlStartTable(inRequest, NULL, headers_callsite, + sizeof(headers_callsite) / sizeof(headers_callsite[0])); + else + htmlStartTable(inRequest, NULL, headers, + sizeof(headers) / sizeof(headers[0])); /* ** Loop over the items, up to some limit or until the end. */ @@ -2805,16 +2824,13 @@ displayMemoryLeaks(STRequest * inRequest, STRun * aRun) PRUint32 displayed = 0; STAllocation *current = NULL; - PR_fprintf(inRequest->mFD, "
RankIndexByte SizeLifespan SecondsWeightHeap Operation SecondsOrigin Callsite
\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); - PR_fprintf(inRequest->mFD, "\n"); + static const char * headers[] = { + "Rank", "Index", "Byte Size", "Lifespan (sec)", + "Weight", "Heap Op (sec)", "Origin Callsite" + }; + + htmlStartTable(inRequest, NULL, headers, + sizeof(headers) / sizeof(headers[0])); /* ** Loop over all of the items, or until we've displayed enough. @@ -2959,16 +2975,16 @@ displayCallsites(STRequest * inRequest, tmcallsite * aCallsite, int aFollow, if (0 == headerDisplayed) { headerDisplayed = __LINE__; - PR_fprintf(inRequest->mFD, - "
RankIndexByte SizeLifespan SecondsWeightHeap Operation SecondsOrigin Callsite
\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n"); + static const char* const headers[] = { + "Callsite", + "C. Size", + "C. Seconds", + "C. Weight", + "H.O. Count", + "C.H. Operation (sec)" + }; + htmlStartTable(inRequest, NULL, headers, + sizeof(headers)/sizeof(headers[0])); } /* @@ -5726,7 +5742,7 @@ handleClient(void *inArg) */ PR_fprintf(aFD, "HTTP/1.1 200 OK%s", crlf); PR_fprintf(aFD, "Server: %s%s", - "$Id: spacetrace.c,v 1.45 2003-06-17 21:10:48 alecf%flett.org Exp $", + "$Id: spacetrace.c,v 1.46 2003-06-17 23:01:45 alecf%flett.org Exp $", crlf); PR_fprintf(aFD, "Content-type: "); if (NULL != strstr(start, ".png")) { diff --git a/mozilla/tools/trace-malloc/tmreader.c b/mozilla/tools/trace-malloc/tmreader.c index 5d8146af5aa..6761f97ba08 100644 --- a/mozilla/tools/trace-malloc/tmreader.c +++ b/mozilla/tools/trace-malloc/tmreader.c @@ -307,7 +307,7 @@ static PLHashEntry *callsite_allocentry(void *pool, const void *key) return (PLHashEntry*)arena_alloc(pool, sizeof(tmcallsite)); } -static init_graphnode(tmgraphnode* node) +static void init_graphnode(tmgraphnode* node) { node->in = node->out = NULL; node->up = node->down = node->next = NULL; @@ -639,6 +639,8 @@ int tmreader_eventloop(tmreader *tmr, const char *filename, hash = hash_serial(key); hep = PL_HashTableRawLookup(tmr->callsites, hash, key); he = *hep; + + /* there should not be an entry here! */ PR_ASSERT(!he); if (he) exit(2); @@ -684,7 +686,7 @@ int tmreader_eventloop(tmreader *tmr, const char *filename, case TM_EVENT_REALLOC: { tmcallsite *site; uint32 size, oldsize; - double delta, sqdelta, sqszdelta; + double delta, sqdelta, sqszdelta = 0; tmgraphnode *comp, *lib; tmmethodnode *meth;
CallsiteC. SizeC. SecondsC. WeightH.O. CountC.H. Operation (sec)