[dtrace-discuss] Losing self-> variables set to timestamp and vtimestamp
Jonathan Adams
jonathan.adams at sun.com
Tue May 26 13:43:21 PDT 2009
On Tue, May 26, 2009 at 01:32:56PM -0700, James Siler wrote:
> Sorry to post this in multiple forums. I posted it earlier in a Sun
> forum before noticing an admonision to post to this forum.
>
> That said ...
>
> When running the following code I seem to lose the setting to self->t,
> self->t2, self->v, and self->v2. Looking at the output, they all seem
> to get set properly at BEGIN, but the first time we fire a probe they
> are all reset to zero.
>
> If I use global variables instead of thread locals, everything seems
> fine (see dummy2.d and output2, below).
>
> I know I'm probably doing something dumb, but I'll be damned if I can
> see what.
The BEGIN probe fires in an unspecified thread's context. That thread will
almost certainly not be a thread in your program. You can't set up thread-local
variables in BEGIN; you have to set them up the first time you use them.
In this case, you could just change "BEGIN" to "dummy$target::main:entry" (so
that it fires before any of your other probes, and everything should work.
Cheers,
- jonathan
More information about the dtrace-discuss
mailing list