4.1.2.7 stack

stack stack(int nframes)
stack stack(void)

The stack action records a kernel stack trace to the directed buffer. The kernel stack is nframes in depth. If nframes is not specified, the number of stack frames recorded is the number that is specified by the stackframes option. The dtrace command reports frames, either up to the root frame or until the nframes limit has been reached, whichever comes first:

# dtrace -n gettimeofday:entry'{stack()}'
dtrace: description 'gettimeofday:entry' matched 1 probe
CPU     ID                    FUNCTION:NAME
  0    196               gettimeofday:entry 
              vmlinux`pollwake
              vmlinux`dtrace_stacktrace+0x30
              vmlinux`__brk_limit+0x1e1832d7
              vmlinux`__brk_limit+0x1e1913a1
              vmlinux`pollwake
              vmlinux`do_gettimeofday+0x1a
              vmlinux`ktime_get_ts+0xad
              vmlinux`systrace_syscall+0xde
              vmlinux`audit_syscall_entry+0x1d7
              vmlinux`system_call_fastpath+0x16

  0    196               gettimeofday:entry 
              vmlinux`dtrace_stacktrace+0x30
              vmlinux`__brk_limit+0x1e1832d7
              vmlinux`__brk_limit+0x1e1913a1
              vmlinux`security_file_permission+0x8b
              vmlinux`systrace_syscall+0xde
              vmlinux`audit_syscall_entry+0x1d7
              vmlinux`system_call_fastpath+0x16

...

The stack action, having a non-void return value, can also be used as the key to an aggregation, for example:

# dtrace -n execve:entry'{@[stack()] = count()}'
dtrace: description 'execve:entry' matched 1 probe
^C


              vmlinux`dtrace_stacktrace+0x30
              vmlinux`__brk_limit+0x1e1832d7
              vmlinux`__brk_limit+0x1e1913a1
              vmlinux`dtrace_execve+0xcd
              vmlinux`audit_syscall_entry+0x1d7
              vmlinux`dtrace_stub_execve+0x6c
                2

              vmlinux`dtrace_stacktrace+0x30
              vmlinux`__brk_limit+0x1e1832d7
              vmlinux`__brk_limit+0x1e1913a1
              vmlinux`do_sigaction+0x13a
              vmlinux`dtrace_execve+0xcd
              vmlinux`audit_syscall_entry+0x1d7
              vmlinux`dtrace_stub_execve+0x6c
               13

...