From 2381a2638d59d94f6a92b35901910f95dd1ee8df Mon Sep 17 00:00:00 2001 From: jhb Date: Fri, 5 Jan 2007 21:04:37 +0000 Subject: Add code to parse the utrace(2) entries generated by malloc(3) in a more human-readable format. Note that we report 'realloc(p, 0)' as 'free(p)' since both cases are encoded the same way and 'free()' is more common than a realloc() to 0. MFC after: 1 week --- usr.bin/kdump/kdump.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 3480997..5854ba8 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -975,9 +975,39 @@ ktrcsw(struct ktr_csw *cs) cs->user ? "user" : "kernel"); } +struct utrace_malloc { + void *p; + size_t s; + void *r; +}; + +void +ktruser_malloc(int len, unsigned char *p) +{ + struct utrace_malloc *ut = (struct utrace_malloc *)p; + + if (ut->p == NULL) { + if (ut->s == 0 && ut->r == NULL) + printf("malloc_init()\n"); + else + printf("%p = malloc(%zu)\n", ut->r, ut->s); + } else { + if (ut->s == 0) + printf("free(%p)\n", ut->p); + else + printf("%p = realloc(%p, %zu)\n", ut->r, ut->p, ut->s); + } +} + void ktruser(int len, unsigned char *p) { + + if (len == sizeof(struct utrace_malloc)) { + ktruser_malloc(len, p); + return; + } + (void)printf("%d ", len); while (len--) if (decimal) @@ -985,7 +1015,6 @@ ktruser(int len, unsigned char *p) else (void)printf(" %02x", *p++); (void)printf("\n"); - } void -- cgit v1.1