Date: Sat, 18 Sep 2010 14:23:36 +0300 From: Andriy Gapon <avg@icyb.net.ua> To: freebsd-hackers@FreeBSD.org Subject: KDB_TRACE and no backend Message-ID: <4C94A138.8050905@icyb.net.ua>
next in thread | raw e-mail | index | archive | help
Here's a small patch that adds support for printing stack trace in form of frame addresses when KDB_TRACE is enabled, but there is no debugger backend configured. The patch is styled after "cheap" variant of stack_ktr. What do you think (useful/useless, correct, etc) ? --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -37,6 +37,7 @@ #include <sys/pcpu.h> #include <sys/proc.h> #include <sys/smp.h> +#include <sys/stack.h> #include <sys/sysctl.h> #include <machine/kdb.h> @@ -295,10 +296,16 @@ void kdb_backtrace(void) { + struct stack st; + int i; - if (kdb_dbbe != NULL && kdb_dbbe->dbbe_trace != NULL) { - printf("KDB: stack backtrace:\n"); + printf("KDB: stack backtrace:\n"); + if (kdb_dbbe != NULL && kdb_dbbe->dbbe_trace != NULL) kdb_dbbe->dbbe_trace(); + else { + stack_save(&st); + for (i = 0; i < st.depth; i++) + printf("#%d %p\n", i, (void*)(uintptr_t)st.pcs[i]); } } -- Andriy Gapon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C94A138.8050905>