One of the most useful (for me) options in DTrace is flowindent. All it does is indent the entry to each function with “->”, and mark the return from this function with “<-“. Doesn’t seem like much, does it? But just look at the results!
The following example catches all the probes of the fbt provided. By default (that’s our case since we’re not changing any other options but flowindent), DTrace registers and prints to the standard output all the probes matched in the tracing process.
Here is our script:
#!/usr/sbin/dtrace -s fbt::: /execname == "dtrace"/ { }
And this is the output we’ll get by running this script:
dtrace: script './try5.d' matched 32659 probes CPU ID FUNCTION:NAME 1 2027 xc_sync:entry 1 819 xc_do_call:entry 1 1210 mutex_vector_enter:entry 1 1238 lock_set_spl:entry 1 2353 splx:entry 1 15484 apic_setspl:entry 1 15485 apic_setspl:return 1 2354 splx:return 1 1239 lock_set_spl:return 1 1211 mutex_vector_enter:return 1 821 xc_common:entry 1 15510 apic_send_ipi:entry 1 15511 apic_send_ipi:return ...
But if we only add the flowindent option to our script (you can also achieve the same result by using -F dtrace command line option), the output is going to appear much more readable and easy to follow:
Our new script:
#!/usr/sbin/dtrace -s #pragma D option flowindent fbt::: /execname == "dtrace"/ { }
And this is the output we’ll get:
dtrace: script './try5.d' matched 32659 probes CPU FUNCTION 1 -> xc_sync 1 -> xc_do_call 1 -> mutex_vector_enter 1 -> lock_set_spl 1 -> splx 1 -> apic_setspl 1 <- apic_setspl 1 <- splx 1 <- lock_set_spl 1 <- mutex_vector_enter 1 -> xc_common 1 -> apic_send_ipi 1 <- apic_send_ipi ...
Leave a Reply