Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Mar 2009 17:09:55 +0800
From:      "beezarliu" <beezarliu@yahoo.com.cn>
To:        "=?gb2312?B?TWFyaXVzX078bm5lcmljaA==?=" <marius@nuenneri.ch>, "Robert Watson" <rwatson@freebsd.org>
Cc:        George Kumar <grgkumar4@gmail.com>, "freebsd-current@freebsd.org" <freebsd-current@freebsd.org>
Subject:   Re: Re: how to dump kernel function trace in freebsd
Message-ID:  <200903061709532188555@yahoo.com.cn>
References:  <5f695cd0903050937h320e72dbrfef1d9e1a1d3b543@mail.gmail.com>, <alpine.BSF.2.00.0903051830030.31079@fledge.watson.org>, <b649e5e0903051200g6e82be95x329969070a09e54a@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help


I also uses db_trace_thread() to print other (not curthread) kthreads' function  stack.

2009-03-06 



beezarliu 



发件人: Marius_N黱nerich 
发送时间: 2009-03-06  04:01:05 
收件人: Robert Watson 
抄送: George Kumar; freebsd-current@freebsd.org 
主题: Re: how to dump kernel function trace in freebsd 
 
On Thu, Mar 5, 2009 at 19:32, Robert Watson  <rwatson@freebsd.org > wrote:
> On Thu, 5 Mar 2009, George Kumar wrote:
>
> > In Linux I could use dump_stack() this to see how a function was called -
> > (In essence stack trace back ),
> >
> > Function() {
> > dump_stack();
> > .....
> > ...
> > }
> > What is the equivalent to dump_stack() in freebsd ?
> >
> > Is it kdb_backtrace() ? But for this I need to have kdb, ddb and kdb_trace
> > options in the config file ? is that correct ?
>
> For debugging purposes, kdb_backtrace() is the preferred interface, and as
> you point out, it depends on the kernel debugger being present.
>
> For more general (read: production) use, you can also capture, print, and
> generally manage stack traces using the stack(9) kernel interfaces. 燭his
> requires "options STACK" to be in the kernel configuration, but this is the
> default in 7.x and 8.x as it is required for procstat's -k command line
> option to work (which allows userspace to print out kernel stacks without
> using the kernel debugger). 燳ou can print stack traces to the console,
> print them to sbuf's to be used elsewhere, etc. 燢eep in mind that you'll
> want to resolve the symbols (using a string conversion function) fairly soon
> after the stack is captured so that symbol names in kernel modules are
> resolved before there's an opportunity for the module to be unloaded.

As said in the forums a fairly elegant solution is to use DTrace for
this task. Just add a SDT probe to the code in question and use
stack() in your DTrace script. Maybe the FBT provider already provides
an appropriate probe so you don't even need to add a SDT probe.
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903061709532188555>