Date: Sat, 18 Sep 2010 20:26:36 +0200 From: Attilio Rao <attilio@freebsd.org> To: Andriy Gapon <avg@icyb.net.ua> Cc: freebsd-hackers@freebsd.org Subject: Re: KDB_TRACE and no backend Message-ID: <AANLkTingR6k6xdQJ3cZH8EkJeCWnq5vzeEjGHNaDv8AT@mail.gmail.com> In-Reply-To: <4C94A138.8050905@icyb.net.ua> References: <4C94A138.8050905@icyb.net.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
2010/9/18 Andriy Gapon <avg@icyb.net.ua>: > > Here's a small patch that adds support for printing stack trace in form o= f frame > addresses when KDB_TRACE is enabled, but there is no debugger backend con= figured. > 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 @@ > =C2=A0#include <sys/pcpu.h> > =C2=A0#include <sys/proc.h> > =C2=A0#include <sys/smp.h> > +#include <sys/stack.h> > =C2=A0#include <sys/sysctl.h> > > =C2=A0#include <machine/kdb.h> > @@ -295,10 +296,16 @@ > =C2=A0void > =C2=A0kdb_backtrace(void) > =C2=A0{ > + =C2=A0 =C2=A0 =C2=A0 struct stack st; > + =C2=A0 =C2=A0 =C2=A0 int i; > > - =C2=A0 =C2=A0 =C2=A0 if (kdb_dbbe !=3D NULL && kdb_dbbe->dbbe_trace != =3D NULL) { > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("KDB: stack bac= ktrace:\n"); > + =C2=A0 =C2=A0 =C2=A0 printf("KDB: stack backtrace:\n"); > + =C2=A0 =C2=A0 =C2=A0 if (kdb_dbbe !=3D NULL && kdb_dbbe->dbbe_trace != =3D NULL) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0kdb_dbbe->dbbe_tra= ce(); > + =C2=A0 =C2=A0 =C2=A0 else { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 stack_save(&st); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for (i =3D 0; i < st.d= epth; i++) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 printf("#%d %p\n", i, (void*)(uintptr_t)st.pcs[i]); > =C2=A0 =C2=A0 =C2=A0 =C2=A0} > =C2=A0} 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 --=20 Peace can only be achieved by understanding - A. Einstein
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTingR6k6xdQJ3cZH8EkJeCWnq5vzeEjGHNaDv8AT>