Go to main content

man pages section 3: Extended Library Functions, Volume 3

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

Pstack_iter (3PROC)

Name

Pstack_iter - walk a process or lwp stack

Synopsis

#include <libproc.h>
typedef int proc_stack_f(
         void *arg,          /* the cookie given to Pstack_iter() */
         prgregset_t regs,   /* the frame's registers */
         uint_t argc,        /* argc for the frame's function */
         const long *argv,   /* argv for the frame's function */
         int flags,          /* flags describing the frame (see below) */
         int sig);           /* a signal number */
int Pstack_iter(ps_prochandle_t *Pr, const prgregset_t regs,
         proc_stack_f *func, void *arg);

Description

The Pr argument identifies a victim process or core file attached to the controlling process by the create and grab interfaces. For more information, see the Pcreate(3PROC) and Pgrab(3PROC) man pages.

The Pstack_iter() function iterates over the stack frames of the lwp whose registers are referenced by the regs argument. The register set referenced by the regs argument is normally the register set of the representative lwp when the process is stopped. However, it can be the register set of any one of the lwps in the process when that lwp is stopped.

For each stack frame, the specified function is called and is passed the arguments shown above in the proc_stack_f() type declaration. The flags argument is a bit-wise OR of zero or more of these flags:

PR_SIGNAL_FRAME

Called by a signal handler

PR_FOUND_SIGNAL

The sig argument is valid

If the specified function returns non-zero, the iteration is terminated. Else, the iteration continues until all stack frames have been visited.

Return Values

The Pstack_iter() function returns zero if all stack frames are visited. Else, it returns the non-zero value returned by the specified function call that caused the iteration to terminate.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
Unsafe

See Also

libproc.h(3HEAD), libproc(3LIB), Pcreate(3PROC), Pgrab(3PROC), proc(5)

Notes

Determining the number and values of the arguments for each frame, as well as the values of all of the registers, is somewhat heuristic. Therefore, the values in the regs, argc, and argv arguments passed to the call-back() function are not guaranteed to be correct.