KDB_TRACE and no backend
Attilio Rao
attilio at freebsd.org
Sat Sep 18 18:26:38 UTC 2010
2010/9/18 Andriy Gapon <avg at icyb.net.ua>:
>
> 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]);
> }
> }
You have to eventually wrap this logic within the 'STACK' option
(opt_stack.h for the check) because stack_save() will be uneffective
otherwise. STACK should be mandatory for DDB I guess, but it is not
for KDB.
Thanks,
Attilio
--
Peace can only be achieved by understanding - A. Einstein
More information about the freebsd-hackers
mailing list