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");
+}
+
/*
** callsiteArrayFromCallsite
**
@@ -2684,19 +2700,22 @@ displayTopAllocations(STRequest * inRequest, STRun * aRun, int aWantCallsite)
PRUint32 loop = 0;
STAllocation *current = NULL;
- 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, "\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,
- "\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;