dtrace -c doesn't work?

Mark Johnston markj at freebsd.org
Thu Oct 17 15:40:20 UTC 2013


On Thu, Oct 17, 2013 at 10:14:44AM +0300, Andriy Gapon wrote:
> on 17/10/2013 06:34 Mark Johnston said the following:
> > My guess is that the /bin/echo on your system is stripped. dtrace(1) on
> > FreeBSD will set a breakpoint on main() in the victim process and
> > register the script with the kernel when that breakpoint fires. If
> > libproc can't find the address of main(), the breakpoint won't fire, and
> > your script won't run. If /bin/echo isn't stripped, your example works
> > properly on my laptop. Adding '-x evaltime=postinit' to the dtrace(1)
> > flags should also allow the script to run properly.
> > 
> > avg@ tried to fix this a little while ago by changing dtrace to
> > instead put a breakpoint on r_debug_state in rtld (r248644). This works
> > for your example, but breaks USDT since that breakpoint apparently fires
> > before ELF ctors run, and thus before dtrace_dof_init() can run (which is
> > needed for USDT to work).
> 
> That's exactly what happened.
> My idea of fixing that was to move r_debug_state call to after preinit_main.
> But Kostik told me that that was a terrible idea.  Unfortunately I can't recall
> right now why. 

I suppose this would make it impossible to use gdb to step through init
functions?

> I've been meaning to restore my knowledge and memory of the code
> and discuss the issue again.
> 
> > I'm not sure what the best way to fix this is. Perhaps we could add a
> > second breakpoint to rtld for use by dtrace, or maybe there's some way
> > to set a breakpoint on the DOF init code.
> 
> Kostik also suggested this.

You mean adding a second breakpoint function to rtld? Perhaps something
like r_debug_state_postinit(), called after objlist_call_init().

-Mark


More information about the freebsd-dtrace mailing list