Date: Sun, 2 Aug 2015 11:55:33 -0700 From: Mark Johnston <markj@FreeBSD.org> To: HeTak <hetakcoder@gmail.com> Cc: freebsd-dtrace@freebsd.org Subject: Re: How to get functions' local variables? Message-ID: <20150802185533.GC59626@raichu> In-Reply-To: <CAGyHxXWpAsk5NcucOYMCj13keOjAZ1JCEUV0VrTfMStxp2Zjgg@mail.gmail.com> References: <CAGyHxXWpAsk5NcucOYMCj13keOjAZ1JCEUV0VrTfMStxp2Zjgg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Aug 02, 2015 at 10:22:39AM +0430, HeTak wrote: > Hi there, > > My question is: How I can check a function's local varibales' value using > dtrace? > > I'm a newbie in using dtrace and it's a bit weird for me..I went through > manuals and so, but did not get that. :( > > What I could find out is that via args, I can get functions' input > arguments. But I could not find out how I can check the value of a variable > which is defined inside my goal function's scope. Isn't this feature > available in Dtrace? No, DTrace doesn't support that feature. It can be approximated for userland programs using the PID provider, since that lets you effectively place breakpoints on arbitrary instructions, and using curthread->td_intr_frame, you can retrieve the register set of the interrupted thread. So if you could map a source line number and local variable name to a function offset and register (or stack offset), you should be able to retrieve the variable's value. But as far as I know, nothing exists to do this automatically. I'm not sure how hard it would be to write a program to use DWARF info to generate a D script which can retrieve a local variable's value. Seems like an interesting experiment? :) -Mark
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150802185533.GC59626>