On 7/24/19 5:16 , ngadre via dtrace-discuss wrote:
> Hi,
> 
> I come from Linux background, and currently working on Dtrace on FreeBSD.
> Having worked on SystemTap on Linux, I worked with para-callgraph.stp a lot 
> to trace user-space function calls, of user defined functions to understand 
> new utilities.
> 
> Is there a utility like para-callgraph.stp available in dtrace. If not, is it 
> feasible to create one (provided there are constructs available).
> 
> #!/usr/bin/stap
> 
> function trace(entry_p, extra) {
>   %( $# > 1 %? if (tid() in trace) %)
>   printf("%s%s%s %s\n",
>          thread_indent (entry_p),
>          (entry_p>0?"->":"<-"),
>          ppfunc (),
>          extra)
> }
> 
> 
> %( $# > 1 %?
> global trace
> probe $2.call {
>   trace[tid()] = 1
> }
> probe $2.return {
>   delete trace[tid()]
> }
> %)
> 
> probe $1.call   { trace(1, $$parms) }
> probe $1.return { trace(-1, $$return) }
> 
> I was trying to rewrite this for dtrace, dtrace understands conditional 
> compilation as well. So will this work for tracing call-graphs of user space 
> programs if written as a dtrace script.

The dtrace -F option (flowindent) I believe does the indenting that you
want. And the pid provider allows you to specify aribtrary parts of
userland. So, I believe that something like is a pretty close approximation:

dtrace -F -n 'pid$target:a.out::entry,pid$target:a.out::return' -c /bin/ls

You'll have to modify it for various parts of functions and libraries
you want and pick a number of explicit parameters.

Robert

------------------------------------------
DTrace: dtrace-discuss
Permalink: 
https://dtrace.topicbox.com/groups/dtrace-discuss/T97a77925c6df6847-M2018b5baa1de95f16403762a
Delivery options: https://dtrace.topicbox.com/groups/dtrace-discuss/subscription

Reply via email to