summaryrefslogtreecommitdiff
path: root/source/fitz/memento.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-03-07 13:34:31 +0000
committerRobin Watts <robin.watts@artifex.com>2016-03-07 15:05:29 +0000
commitf721244bb170b4924e8ebc334f1c64b24d8acd29 (patch)
treea1e9ae7a1c48d72d4fe6f684c93d3f81a8df7e19 /source/fitz/memento.c
parentc80f5c848a22366275587d4d692fd32e938e2e02 (diff)
downloadmupdf-f721244bb170b4924e8ebc334f1c64b24d8acd29.tar.xz
Memento: List block details at closedown.
Diffstat (limited to 'source/fitz/memento.c')
-rw-r--r--source/fitz/memento.c58
1 files changed, 35 insertions, 23 deletions
diff --git a/source/fitz/memento.c b/source/fitz/memento.c
index 8a673135..9108496b 100644
--- a/source/fitz/memento.c
+++ b/source/fitz/memento.c
@@ -1215,12 +1215,45 @@ void Memento_stats(void)
Memento_endStats();
}
+#ifdef MEMENTO_DETAILS
+static void showInfo(Memento_BlkHeader *b, void *arg)
+{
+ Memento_BlkDetails *details;
+
+ fprintf(stderr, "0x%p:(size=%d,num=%d)",
+ MEMBLK_TOBLK(b), (int)b->rawsize, b->sequence);
+ if (b->label)
+ fprintf(stderr, " (%s)", b->label);
+ fprintf(stderr, "\nEvents:\n");
+
+ details = b->details;
+ while (details)
+ {
+ fprintf(stderr, " Event %d (%s)\n", details->sequence, eventType[(int)details->type]);
+ Memento_showStacktrace(details->stack, details->count);
+ details = details->next;
+ }
+}
+#endif
+
+void Memento_listBlockInfo(void)
+{
+#ifdef MEMENTO_DETAILS
+ fprintf(stderr, "Details of allocated blocks:\n");
+ Memento_appBlocks(&globals.used, showInfo, NULL);
+#endif
+}
+
static void Memento_fin(void)
{
Memento_checkAllMemory();
Memento_endStats();
if (globals.used.head != NULL) {
Memento_listBlocks();
+#ifdef MEMENTO_DETAILS
+ fprintf(stderr, "\n");
+ Memento_listBlockInfo();
+#endif
Memento_breakpoint();
}
if (globals.segv) {
@@ -1319,27 +1352,6 @@ static int Memento_containsAddr(Memento_BlkHeader *b,
return 0;
}
-#ifdef MEMENTO_DETAILS
-static void showInfo(Memento_BlkHeader *b)
-{
- Memento_BlkDetails *details;
-
- fprintf(stderr, "0x%p:(size=%d,num=%d)",
- MEMBLK_TOBLK(b), (int)b->rawsize, b->sequence);
- if (b->label)
- fprintf(stderr, " (%s)", b->label);
- fprintf(stderr, "\nEvents:\n");
-
- details = b->details;
- while (details)
- {
- fprintf(stderr, " Event %d (%s)\n", details->sequence, eventType[(int)details->type]);
- Memento_showStacktrace(details->stack, details->count);
- details = details->next;
- }
-}
-#endif
-
void Memento_info(void *addr)
{
#ifdef MEMENTO_DETAILS
@@ -1350,12 +1362,12 @@ void Memento_info(void *addr)
data.flags = 0;
Memento_appBlocks(&globals.used, Memento_containsAddr, &data);
if (data.blk != NULL)
- showInfo(data.blk);
+ showInfo(data.blk, NULL);
data.blk = NULL;
data.flags = 0;
Memento_appBlocks(&globals.free, Memento_containsAddr, &data);
if (data.blk != NULL)
- showInfo(data.blk);
+ showInfo(data.blk, NULL);
#else
printf("Memento not compiled with details support\n");
#endif