summaryrefslogtreecommitdiffstats
path: root/usr.bin/kdump
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2007-01-05 21:04:37 +0000
committerjhb <jhb@FreeBSD.org>2007-01-05 21:04:37 +0000
commit2381a2638d59d94f6a92b35901910f95dd1ee8df (patch)
tree21c041caff5ce922bcee4aa7c3413a3a65acf485 /usr.bin/kdump
parent45243cfb24d4bbffa5f68feeaa19e0e8cb327a53 (diff)
downloadFreeBSD-src-2381a2638d59d94f6a92b35901910f95dd1ee8df.zip
FreeBSD-src-2381a2638d59d94f6a92b35901910f95dd1ee8df.tar.gz
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
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r--usr.bin/kdump/kdump.c31
1 files changed, 30 insertions, 1 deletions
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
OpenPOWER on IntegriCloud