2

What is the difference between arg0 and arg1 when using dtrace.

dtrace -n 'profile-997 /arg0/ { @[stack()] = count() }
dtrace -n 'profile-997 /arg1/ { @[ustack()] = count() }

For example, the two scripts above record number of each stack. I just wonder why arg0 indicate it is a kernel stack while arg1 a user space stack.

double-beep
  • 5,031
  • 17
  • 33
  • 41
shengshan zhang
  • 538
  • 8
  • 16
  • I think i found the answer, http://dtrace.org/guide/chp-profile.html#chp-profile in Section 19.3, arg0 and arg1 is the built-in variable which indicate which level the CPU is running on. – shengshan zhang Feb 25 '19 at 12:12
  • Yes, that's typical of Sun Microsystem products. Extremely useful/powerful/maybe even dangerous features mentioned once in passing, deeply buried in the specifics of the documentation. "What do you mean I voided my warranty and caused my server to melt itself?" "That's documented on page 1525 of the man pages, section 1M, in the 3rd footnote to paragraph 17c. When combined with the data listed in Table 42, page 964 of the section 5 man pages, that behavior is clearly expected." – Andrew Henle Feb 26 '19 at 11:01

1 Answers1

2

That's by design.

The profile provider receives two arguments, arg0 is set to the PC in case the CPU is running in kernel mode while arg1 has the PC in case the CPU is running in userland. The other argument is set to zero so that makes a very simple way to detect the CPU state.

jlliagre
  • 29,783
  • 6
  • 61
  • 72