From: Sepherosa Ziehau Date: Sun, 26 Apr 2015 12:18:51 +0000 (+0800) Subject: ktrdump: Fix caller chain support X-Git-Url: https://gitweb.dragonflybsd.org/~nant/dragonfly.git/commitdiff_plain/35ef12056da56825329360bffd23a811c7cc0e74 ktrdump: Fix caller chain support And set default kernel file to /boot/kernel/kernel, if sysctl kern.bootfile fails. --- diff --git a/usr.bin/ktrdump/ktrdump.c b/usr.bin/ktrdump/ktrdump.c index 5b69cdf343..784cf2a71e 100644 --- a/usr.bin/ktrdump/ktrdump.c +++ b/usr.bin/ktrdump/ktrdump.c @@ -756,7 +756,7 @@ read_symbols(const char *file) char cmd[256]; size_t buflen = sizeof(buf); FILE *fp; - struct symdata *sym; + struct symdata *sym = NULL; char *s1; char *s2; char *s3; @@ -765,7 +765,7 @@ read_symbols(const char *file) if (file == NULL) { if (sysctlbyname("kern.bootfile", buf, &buflen, NULL, 0) < 0) - file = "/boot/kernel"; + file = "/boot/kernel/kernel"; else file = buf; } @@ -782,13 +782,19 @@ read_symbols(const char *file) sym->symname = strdup(s3); if (strcmp(s3, "kernbase") == 0) symbegin = sym->symaddr; - if (strcmp(s3, "end") == 0) + if (strcmp(s3, "end") == 0 || strcmp(s3, "_end") == 0) symend = sym->symaddr; TAILQ_INSERT_TAIL(&symlist, sym, link); } } pclose(fp); } + if (symend == NULL) { + if (sym != NULL) + symend = sym->symaddr; + else + symend = (char *)-1; + } symcache = TAILQ_FIRST(&symlist); }