Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Aug 2015 10:03:10 +0430
From:      HeTak <hetakcoder@gmail.com>
To:        Mark Johnston <markj@freebsd.org>
Cc:        freebsd-dtrace@freebsd.org
Subject:   Re: How to get functions' local variables?
Message-ID:  <CAGyHxXVAY1Nv8r4s3cv497Oagd76JaZ=8vN9C60cZOYFPOe-Hw@mail.gmail.com>
In-Reply-To: <20150802185533.GC59626@raichu>
References:  <CAGyHxXWpAsk5NcucOYMCj13keOjAZ1JCEUV0VrTfMStxp2Zjgg@mail.gmail.com> <20150802185533.GC59626@raichu>

next in thread | previous in thread | raw e-mail | index | archive | help
Thank you for the answer, Mark :)

It sounds kinda tricky to do so.. but maybe I give it a try ;)

Cheerio
HeTak

On Sun, Aug 2, 2015 at 11:25 PM, Mark Johnston <markj@freebsd.org> wrote:

> 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?CAGyHxXVAY1Nv8r4s3cv497Oagd76JaZ=8vN9C60cZOYFPOe-Hw>