libproc.3lib revision 43051d2742bbe5911de73322064cb573b6aff975

This file and its contents are supplied under the terms of the
Common Development and Distribution License ("CDDL"), version 1.0.
You may only use this file in accordance with the terms of version
1.0 of the CDDL.

A full copy of the text of the CDDL should have accompanied this
source. A copy of the CDDL is also available via the Internet at
http://www.illumos.org/license/CDDL.


Copyright 2015 Joyent, Inc.

.Dd May 08, 2016 .Dt LIBPROC 3LIB .Os .Sh NAME .Nm libproc .Nd process control library .Sh SYNOPSIS .Lb libproc n libproc.h .Sh DESCRIPTION The .Nm library provides consumers a general series of interfaces to inspect and control both live processes and core files. It is intended for introspection tools such as debuggers by providing a high-level interface to the /proc file system

f ( Xr proc 4 ) .

p The .Nm library provides interfaces that focus on: l -bullet -offset indent t Creating and attaching to live process, core files, and arbitrary ELF objects. t Interrogating the state of a process or core file. t Manipulating the current state of a process or thread. t Interrogating the state of threads of a process or core file. t Running system calls in the context of another process. t Various utilities for iterating process and core file file descriptors, mappings, symbols, and more. t Various utilities to support debugging tools. .El .Ss Live Processes The .Nm library can be used to manipulate running processes and to create new ones. To manipulate an existing process first .Em grab it with the .Em Pgrab function. A process is generally stopped as a side effect of grabbing it. Callers must exercise caution, as if they do not use the library correctly, or they terminate unexpectedly, a process may remain stopped.

p Unprivileged users may only grab their own processes. Users with the privilege .Sy PRIV_PROC_OWNER may manipulate processes that they do not own; however, additional restrictions as described in .Xr privileges 5 apply.

p In addition, the .Fn Pcreate and .Fn Pxcreate functions may be used to create processes which are always controlled by the library. .Ss Core Files The .Nm library has the ability to open and interpret core files produced by processes on the system. Process core dump generation is controlled by the .Xr coreadm 1M command. In addition, the library has the ability to understand and interpret core dumps generated by Linux kernel and can provide a subset of its functionality on such core files, provided the original binary is also present.

p Not all functions in the .Nm library are valid for core files. In general, none of the commands which manipulate the current state of a process or thread or that try to force system calls on a victim process will work. Furthermore several of the information and iteration interfaces are limited based on the data that is available in the core file. For example, if the core file is of a process that omits the frame pointer, the ability to iterate the stack will be limited.

p Use the .Fn Pgrab_core or .Fn Pfgrab_core function to open a core file. Use the .Fn Pgrab_file function to open an ELF object file. This is useful for obtaining information stored in ELF headers and sections. .Ss Debug Information Many of the operations in the library rely on debug information being present in a process and its associated libraries. The library leverages symbol table information, CTF data

f ( Xr CTF 4 ) sections, and frame unwinding information based on the use of an ABI defined frame pointer, eg. .Sy %ebp and .Sy %rbp on x86 systems.

p Some software providers strip programs of this information or build their executables such that the information will not be present in a core dump. To deal with this fact, the library is able to consume information that is not present in the core file or the running process. It can both consume it from the underlying executable and it also supports finding it from related ELF objects that are linked to it via the .Sy .gnu_debuglink and the .Sy .note.gnu.build-id ELF sections. .Ss Iteration Interfaces The .Nm library provides the ability to iterate over the following aspects of a process or core file: l -bullet -offset indent t Active threads t Active and zombie threads t All non-system processes t All process mappings t All objects in a process t The environment t The symbol table t Stack frames t File Descriptors .El .Ss System Call Injection The .Nm library allows the caller to force system calls to be executed in the context of the running process. This can be used both as a tool for introspection, allowing one to get information outside its current context as well as performing modifications to a process.

p These functions run in the context of the calling process. This is often an easier way of getting non-exported information about a process from the system. For example, the .Xr pfiles 1 command uses this interface to get more detailed information about a process's open file descriptors, which it would not have access to otherwise. .Sh INTERFACES The shared object .Sy libproc.so.1 provides the public interfaces defined below. See .Xr Intro 3 for additional information on shared object interfaces. Functions are organized into categories that describe their purpose. Individual functions are documented in their own manual pages. .Ss Creation, Grabbing, and Releasing The following routines are related to creating library handles, grabbing cores, processes, and threads, and releasing those resources. l -column -offset indent ".Sy Pmapping_iter_resolved" ".Sy Psymbol_iter_by_addr" t Sy Lfree Ta Sy Lgrab t Sy Lgrab_error Ta Sy Pcreate t Sy Pcreate_agent Ta Sy Pcreate_callback t Sy Pcreate_error Ta Sy Pdestroy_agent t Sy Pfgrab_core Ta Sy Pfree t Sy Pgrab Ta Sy Pgrab_core t Sy Pgrab_error Ta Sy Pgrab_file t Sy Pgrab_ops Ta Sy Prelease t Sy Preopen Ta Sy Pxcreate .El .Ss Process interrogation and manipulation The following routines obtain information about a process and allow manipulation of the process itself. l -column -offset indent ".Sy Pmapping_iter_resolved" ".Sy Psymbol_iter_by_addr" t Sy Paddr_to_ctf Ta Sy Paddr_to_loadobj t Sy Paddr_to_map Ta Sy Paddr_to_text_map t Sy Pasfd Ta Sy Pclearfault t Sy Pclearsig Ta Sy Pcontent t Sy Pcred Ta Sy Pctlfd t Sy Pdelbkpt Ta Sy Pdelwapt t Sy Pdstop Ta Sy Pexecname t Sy Pfault Ta Sy Pfgcore t Sy Pgcore Ta Sy Pgetareg t Sy Pgetauxval Ta Sy Pgetauxvec t Sy Pgetenv Ta Sy Pisprocdir t Sy Pissyscall_prev Ta Sy Plmid t Sy Plmid_to_loadobj Ta Sy Plmid_to_map t Sy Plookup_by_addr Ta Sy Plookup_by_name t Sy Plwp_alt_stack Ta Sy Plwp_getfpregs t Sy Plwp_getpsinfo Ta Sy Plwp_getregs t Sy Plwp_getspymaster Ta Sy Plwp_main_stack t Sy Plwp_setfpregs Ta Sy Plwp_setregs t Sy Plwp_stack Ta Sy Pname_to_ctf t Sy Pname_to_loadobj Ta Sy Pname_to_map t Sy Pobjname Ta Sy Pobjname_resolved t Sy Pplatform Ta Sy Ppltdest t Sy Ppriv Ta Sy Ppsinfo t Sy Pputareg Ta Sy Prd_agent t Sy Pread Ta Sy Pread_string t Sy Preset_maps Ta Sy Psetbkpt t Sy Psetcred Ta Sy Psetfault t Sy Psetflags Ta Sy Psetpriv t Sy Psetrun Ta Sy Psetsignal t Sy Psetsysentry Ta Sy Psetsysexit t Sy Psetwapt Ta Sy Psetzoneid t Sy Psignal Ta Sy Pstate t Sy Pstatus Ta Sy Pstop t Sy Pstopstatus Ta Sy Psync t Sy Psysentry Ta Sy Psysexit t Sy Puname Ta Sy Punsetflags t Sy Pupdate_maps Ta Sy Pupdate_syms t Sy Pwait Ta Sy Pwrite t Sy Pxecbkpt Ta Sy Pxecwapt t Sy Pxlookup_by_addr Ta Sy Pxlookup_by_addr_resolved t Sy Pxlookup_by_name Ta Sy Pzonename t Sy Pzonepath Ta Sy Pzoneroot .El .Ss Thread interrogation and manipulation The following routines obtain information about a thread and allow manipulation of the thread itself. l -column -offset indent ".Sy Pmapping_iter_resolved" ".Sy Psymbol_iter_by_addr" t Sy Lalt_stack Ta Sy Lclearfault t Sy Lclearsig Ta Sy Lctlfd t Sy Ldstop Ta Sy Lgetareg t Sy Lmain_stack Ta Sy Lprochandle t Sy Lpsinfo Ta Sy Lputareg t Sy Lsetrun Ta Sy Lstack t Sy Lstate Ta Sy Lstatus t Sy Lstop Ta Sy Lsync t Sy Lwait Ta Sy Lxecbkpt t Sy Lxecwapt Ta "" .El .Ss System Call Injection The following routines are used to inject specific system calls and have them run in the context of a process. l -column -offset indent ".Sy Pmapping_iter_resolved" ".Sy Psymbol_iter_by_addr" t Sy pr_access Ta Sy pr_close t Sy pr_creat Ta Sy pr_door_info t Sy pr_exit Ta Sy pr_fcntl t Sy pr_fstat Ta Sy pr_fstat64 t Sy pr_fstatvfs Ta Sy pr_getitimer t Sy pr_getpeername Ta Sy pr_getpeerucred t Sy pr_getprojid Ta Sy pr_getrctl t Sy pr_getrlimit Ta Sy pr_getrlimit64 t Sy pr_getsockname Ta Sy pr_getsockopt t Sy pr_gettaskid Ta Sy pr_getzoneid t Sy pr_ioctl Ta Sy pr_link t Sy pr_llseek Ta Sy pr_lseek t Sy pr_lstat Ta Sy pr_lstat64 t Sy pr_memcntl Ta Sy pr_meminfo t Sy pr_mmap Ta Sy pr_munmap t Sy pr_open Ta Sy pr_processor_bind t Sy pr_rename Ta Sy pr_setitimer t Sy pr_setrctl Ta Sy pr_setrlimit t Sy pr_setrlimit64 Ta Sy pr_settaskid t Sy pr_sigaction Ta Sy pr_stat t Sy pr_stat64 Ta Sy pr_statvfs t Sy pr_unlink Ta Sy pr_waitid .El .Ss Iteration routines These routines are used to iterate over the contents of a process. l -column -offset indent ".Sy Pmapping_iter_resolved" ".Sy Psymbol_iter_by_addr" t Sy Penv_iter Ta Sy Plwp_iter t Sy Plwp_iter_all Ta Sy Pmapping_iter t Sy Pmapping_iter_resolved Ta Sy Pobject_iter t Sy Pobject_iter_resolved Ta Sy Pstack_iter t Sy Psymbol_iter Ta Sy Psymbol_iter_by_addr t Sy Psymbol_iter_by_lmid Ta Sy Psymbol_iter_by_name t Sy Pxsymbol_iter Ta Sy Pfdinfo_iter .El .Ss Utility routines The following routines are utilities that are useful to consumers of the library. l -column -offset indent ".Sy Pmapping_iter_resolved" ".Sy Psymbol_iter_by_addr" t Sy Perror_printf Ta Sy proc_arg_grab t Sy proc_arg_psinfo Ta Sy proc_arg_xgrab t Sy proc_arg_xpsinfo Ta Sy proc_content2str t Sy proc_finistdio Ta Sy proc_fltname t Sy proc_fltset2str Ta Sy proc_flushstdio t Sy proc_get_auxv Ta Sy proc_get_cred t Sy proc_get_priv Ta Sy proc_get_psinfo t Sy proc_get_status Ta Sy proc_initstdio t Sy proc_lwp_in_set Ta Sy proc_lwp_range_valid t Sy proc_signame Ta Sy proc_sigset2str t Sy proc_str2content Ta Sy proc_str2flt t Sy proc_str2fltset Ta Sy proc_str2sig t Sy proc_str2sigset Ta Sy proc_str2sys t Sy proc_str2sysset Ta Sy proc_sysname t Sy proc_sysset2str Ta Sy proc_unctrl_psinfo t Sy proc_walk Ta "" .El .Ss x86 Specific Routines The following routines are specific to the x86, 32-bit and 64-bit, versions of the .Nm library. l -column -offset indent ".Sy Pmapping_iter_resolved" ".Sy Psymbol_iter_by_addr" t Sy Pldt Ta Sy proc_get_ldt .El .Ss SPARC specific Routines The following functions are specific to the SPARC, 32-bit and 64-bit, versions of the .Nm library. l -column -offset indent ".Sy Pmapping_iter_resolved" ".Sy Psymbol_iter_by_addr" t Sy Plwp_getgwindows Ta Sy Plwp_getxregs t Sy Plwp_setxregs Ta Sy "" .El

p The following functions are specific to the 64-bit SPARC version of the .Nm library. l -column -offset indent ".Sy Pmapping_iter_resolved" ".Sy Psymbol_iter_by_addr" t Sy Plwp_getasrs Ta Sy Plwp_setasrs .El .Sh PROCESS STATES Every process handle that exists in .Nm has a state. In some cases, such as for core files, these states are static. In other cases, such as handles that correspond to a running process or a created process, these states are dynamic and change based on actions taken in the library. The state can be obtained with the .Xr Pstate 3PROC function.

p The various states are: l -tag -width Dv -offset indent t Dv PS_RUN An actively running process. This may be a process that was obtained by creating it with functions such as .Xr Pcreate 3PROC or by grabbing an existing process such as .Xr Pgrab 3PROC . t Dv PS_STOP An active process that is no longer executing. A process may stop for many reasons such as an explicit stop request (through .Xr pstop 1 for example) or if a tracing event is hit.

p The reason a process is stopped may be obtained through the thread's .Sy lwpstatus_t structure read directly from /proc or obtained through the .Xr Lstatus 3PROC function. t Dv PS_LOST Control over the process has been lost. This may happen when the process executes a new image requiring a different set of privileges. To resume control call .Xr Preopen 3PROC . For more information on losing control of a process, see .Xr proc 4 . t DV PS_UNDEAD A zombie process. It has terminated, but it has not been cleaned up yet by its parent. For more on the conditions of becoming a zombie, see .Xr exec 2 . t DV_PS_DEAD Processes in this state are always core files. See the earlier section .Sx Core Files for more information on working with core files. t Dv PS_IDLE A process that has never been run. This is always the case for handles that refer to files as the files cannot be executed. Those process handles are obtained through calling .Xr Pgrab_file 3PROC . .El

p Many functions relating to tracing processes, for example .Xr Psignal 3PROC , .Xr Psetsignal 3PROC , .Xr Psetfault 3PROC , .Xr Psetentry 3PROC , and others, mention that they only act upon .Em Active Processes . This specifically refers to processes whose state are in .Dv PS_RUN and .Dv PS_STOP . Process handles in the other states have no notion of settable tracing flags, though core files

f ( type Dv PS_DEAD ) , ======= may have a read-only snapshot of their tracing settings available. .Sh TYPES The .Nm library uses many types that come from the /proc file system

f ( Xr proc 4 ) and the ELF format

f ( Xr elf 3ELF ) . However, it also defines the following types:

p .Sy struct ps_prochandle

p The .Sy struct ps_prochandle is an opaque handle to the library and the core element of control for a process. Consumers obtain pointers to a handle through the use of the .Fn Pcreate , .Fn Pgrab , and related functions. When a caller is done with a handle, then it should call one of the .Fn Pfree and .Fn Prelease functions to relinquish the handle, release associated resources, and potentially set the process to run again.

p .Sy struct ps_lwphandle

p The .Sy struct ps_lwphandle is analogous to the .Sy struct ps_prochandle , but it represents the control of an individual thread, rather than a process. Consumers obtain pointers to a handle through the .Fn Lgrab function and relinquish it with the .Fn Lfree function.

p .Sy core_content_t

p The .Sy core_content_t is a value which describes the various content types of core files. These are used in functions such as .Xr Pcontent 3PROC and .Xr Pgcore 3PROC to describe and control the types of content that get included. Various content types may be included together through a bitwise-inclusive-OR. The default system core contents are controlled with the .Xr coreadm 1M tool. The following table lists the current set of core contents in the system, though the set may increase over time. The string after the macro is the human readable string that corresponds with the constant and is used by .Xr coreadm 1M , .Xr proc_content2str 3PROC , and .Xr proc_str2content 3PROC . l -tag -offset indent -width indent t Dv CC_CONTENT_STACK ("stack") The contents include the process stack. Note, this only covers the main thread's stack. The stack of other threads is covered by .Dv CC_CONTENT_ANON . t Dv CC_CONTENT_HEAP ("heap") The contents include the process heap. t Dv CC_CONTENT_SHFILE ("shfile") The contents include shared mappings that are backed by files (e.g. mapped through .Xr mmap 2 with the .Dv MAP_SHARED flag). t Dv CC_CONTENT_SHANNON ("shannon") The contents include shared mappings that are backed by anonymous memory (e.g. mapped through .Xr mmap 2 with the .Dv MAP_SHARED and .Dv MAP_ANON flags). t Dv CC_CONTENT_RODATA ("rodata") The contents include private read-only file mappings, such as shared library text. t Dv CC_CONTENT_ANON ("anon") The contents include private anonymous mappings. This includes the stacks of threads which are not the main thread. t Dv CC_CONTENT_SHM ("shm") The contents include system V shared memory. t Dv CC_CONTENT_ISM ("ism") The contents include ISM (intimate shared memory) mappings. t Dv CC_CONTENT_DISM ("dism") The contents include DISM (dynamic shared memory) mappings. t Dv CC_CONTENT_CTF ("ctf") The contents include .Xr ctf 4 (Compact C Type Format) information. Note, not all objects in the process may have CTF information available. t Dv CC_CONTENT_SYMTAB ("symtab") The contents include the symbol table. Note, not all objects in the process may have a symbol table available. t Dv CC_CONTENT_ALL ("all") This value indicates that all of the above content values are present. Note that additional values may be added in the future, in which case the value of the symbol will be updated to include them. Comparisons with .Dv CC_CONTENT_ALL should validate all the expected bits are set by an expression such as .Li (c & CC_CONTENT_ALL) == CC_CONTENT_ALL . t Dv CC_CONTENT_NONE ("none") This value indicates that there is no content present. t Dv CC_CONTENT_DEFAULT ("default") The content includes the following set of default values: .Dv CC_CONTENT_STACK , .Dv CC_CONTENT_HEAP , .Dv CC_CONTENT_ISM , .Dv CC_CONTENT_DISM , .Dv CC_CONTENT_SHM , .Dv CC_CONTENT_SHANON , .Dv CC_CONTENT_TEXT , .Dv CC_CONTENT_DATA , .Dv CC_CONTENT_RODATA , .Dv CC_CONTENT_ANON , .Dv CC_CONTENT_CTF , and .Dv CC_CONTENT_SYMTAB. Note that the default may change. Comparisons with CC_CONTENT_DEFAULT should validate that all of the expected bits are set with an expression such as .Li (c & CC_CONTENT_DEFAULT) == CC_CONTENT_DEFAULT. t Dv CC_CONTENT_INVALID This indicates that the contents are invalid. .El

p .Sy prfdinfo_t

p The .Sy prfdinfo_t structure is used with the .Fn Pfdinfo_iter function which describes information about a file descriptor. The structure is defined as follows: d -literal typedef struct prfdinfo { int pr_fd; mode_t pr_mode; uid_t pr_uid; gid_t pr_gid; major_t pr_major; /* think stat.st_dev */ minor_t pr_minor; major_t pr_rmajor; /* think stat.st_rdev */ minor_t pr_rminor; ino64_t pr_ino; off64_t pr_offset; off64_t pr_size; int pr_fileflags; /* fcntl(F_GETXFL), etc */ int pr_fdflags; /* fcntl(F_GETFD), etc. */ char pr_path[MAXPATHLEN]; } prfdinfo_t; .Ed

p The structure has similar information to that found in the .Sy stat structure that's used as part of the stat family of system calls, defined in .Xr stat 2 . The member .Sy pr_fd contains the number of the file descriptor of the file. The members .Sy pr_mode , .Sy pr_uid , .Sy pr_gid , .Sy pr_ino , and .Sy pr_size are the same as the members .Sy st_mode , .Sy st_uid , .Sy st_gid , .Sy st_ino , and .Sy st_size in the .Sy stat structure.

p The .Sy pr_major and .Sy pr_minor members contain the major and minor numbers of the device containing the directory for this file. This is similar to the .Sy st_dev member of the .Sy stat structure, except that it is broken out into its major and minor components. The .Sy pr_rmajor and .Sy pr_rminor members are similar in spirit to .Sy pr_major and .Sy pr_minor ; however, they are equivalent to the .Sy st_rdev member of the .Sy stat structure and thus have meaning for special character and block files.

p The .Sy pr_offset member contains the current seek offset of the file descriptor. The .Sy pr_fileflags and .Sy pr_fdflags members contain the flags that would have been returned by a call to .Xr fcntl 2 with the arguments .Dv F_GETXFL and .Dv F_GETFD respectively.

p .Sy prsyminfo_t

p The .Sy prsyminfo_t structure is used with the various symbol look up functions .Fn Pxlookup_by_name , .Fn Pxlookup_by_addr , and .Fn Pxlookup_by_addr_resolved which describes additional information about a symbol. The structure is defined as follows: d -literal typedef struct prsyminfo { const char *prs_object; /* object name */ const char *prs_name; /* symbol name */ Lmid_t prs_lmid; /* link map id */ uint_t prs_id; /* symbol id */ uint_t prs_table; /* symbol table id */ } prsyminfo_t; .Ed

p The member .Sy prs_object points to a string that contains the name of the object file, if known, that the symbol comes from. The member .Sy prs_name points to the name of the symbol, if known. This may be unknown due to a stripped binary that contains no symbol table. The member .Sy prs_lmid indicates the link map identifier that the symbol was found on. For more information on link map identifiers refer to the .Em Linker and Libraries Guide and .Xr dlopen 3C .

p The members .Sy prs_id and .Sy prs_table can be used to determine both the symbol table that the entry came from and which entry in the table it corresponds to. If the value of .Sy prs_table is .Dv PR_SYMTAB then it came from the ELF standard symbol table. However, if it is instead .Dv PR_DYNSYM , then that indicates that it comes from the process's dynamic section.

p .Sy proc_lwp_f

p The .Sy proc_lwp_f is a function pointer type that is used with the .Fn Plwp_iter function. It is defined as .Sy typedef .Ft int .Fo proc_lwp_f .Fa "void *" .Fa "const lwpstatus_t *" .Fc . The first argument is a pointer to an argument that the user specifies, while the second has the thread's status information and is defined in .Xr proc 4 . For additional information on using this type, see .Xr Plwp_iter 3PROC .

p .Sy proc_lwp_all_f

p The .Sy proc_lwp_all_f is a function pointer type that is used with the .Fn Plwp_iter_all function. It is defined as .Sy typedef .Ft int .Fo proc_lwp_all_f .Fa "void *" .Fa "const lwpstatus_t *" .Fa "const lwpsinfo_t *" .Fc . The first argument is a pointer to an argument that the user specifies. The second and third arguments contain the thread's status and thread-specific .Xr ps 1 information respectively. Both structures are defined in .Xr proc 4 . For additional information on using this type, see .Xr Plwp_iter_all 3PROC .

p .Sy proc_walk_f

p The .Sy proc_walk_f is a function pointer type that is used with the .Fn proc_walk function. It is defined as .Sy typedef .Ft int .Fo proc_walk_f .Fa "psinfo_t *" .Fa "lwpsinfo_t *" .Fa "void *" .Fc . The first argument contains the process .Xr ps 1 information and the second argument contains the representative thread's .Xr ps 1 information. Both structures are defined in .Xr proc 4 . The final argument is a pointer to an argument that the user specifies. For more information on using this, see .Xr proc_walk 3PROC .

p .Sy proc_map_f

p The .Sy proc_map_f is a function pointer type that is used with the .Fn Pmapping_iter , .Fn Pmapping_iter_resolved , .Fn Pobject_iter , and .Fn Pobject_iter_resolved functions. It is defined as .Sy typedef .Ft int .Fo proc_map_f .Fa "void *" .Fa "const prmap_t *" .Fa "const char *" .Fc . The first argument is a pointer to an argument that the user specifies. The second argument is describes the mapping information and is defined in .Xr proc 4 . The final argument contains the name of the mapping or object file in question. For additional information on using this type, see .Xr Pmapping_iter 3PROC .

p .Sy proc_env_f

p The .Sy proc_env_f is a function pointer type that is used with the .Fn Penv_iter function. It is defined as .Sy typedef .Ft int .Fo proc_env_f .Fa "void *" .Fa "struct ps_prochandle *" .Fa "uintptr_t" .Fa "const char *" .Fc . The first argument is a pointer to an argument that the user specifies. The second argument is a pointer to the .Sy struct ps_prochandle that the callback was passed to. The third argument is the address of the environment variable in the process. The fourth argument is the environment variable. Values in the environment follow the convention of the form .Em variable=value . For more information on environment variables see .Xr exec 2 and .Xr environ 5 . For additional information on using this type, see .Xr Penv_iter 3PROC .

p .Sy proc_sym_f

p The .Sy proc_sym_f is a function pointer type that is used with the .Fn Psmbol_iter , .Fn Psymbol_iter_by_addr , .Fn Psymbol_iter_by_name , and .Fn Psymbol_iter_by_lmid functions. It is defined as .Sy typedef .Ft int .Fo proc_sym_f .Fa "void *" .Fa "const GElf_Sym *" .Fa "const char *" .Fc . The first argument is a pointer to an argument that the user supplies. The second argument is a pointer to the ELF symbol information in a 32-bit and 64-bit neutral form. See .Xr elf 3ELF and .Xr gelf 3ELF for more information on it. The final argument points to a character string that has the name of the symbol. For additional information on using this type, see .Xr Psymbol_iter 3PROC , .Xr Psymbol_iter_by_addr 3PROC , .Xr Psymbol_iter_by_name 3PROC , and .Xr Psymbol_iter_by_lmid 3PROC .

p .Sy proc_xsym_f

p The .Sy proc_xsym_f is a function pointer type that is used with the .Fn Pxsymbol_iter function. It is defined as .Sy typedef .Ft int .Fo proc_xsym_f .Fa "void *" .Fa "const GElf_Sym *" .Fa "const char *" .Fa "const prsyminfo_t *" .Fc . The first three arguments are identical to those of .Sy proc_sym_f . The final argument contains additional information about the symbol itself. The members of the .Sy prsyminfo_t are defined earlier in this section. For additional information on using this type, see .Xr Pxsymbol_iter 3PROC .

p .Sy proc_stack_f

p The .Sy proc_stack_f is a function pointer type that is used with the .Fn Pstack_iter function. It is defined as .Sy typedef .Ft int .Fo proc_stack_f .Fa "void *" .Fa "prgregset_t" .Fa "uint_t" .Fa "const long *" .Fc . The first argument is a pointer to an argument that the user specifies. The second argument's contents are platform specific. The registers that contain stack information, usually the stack pointer and frame pointer, will be filled in to point to an entry. The .Sy prgregset_t is defined in .Xr proc 4 .

p The third argument contains the number of arguments to the current stack frame and the fourth argument contains an array of addresses that correspond to the arguments to that stack function. The value of the third argument dictates the number of entries in the fourth argument. For additional information on using this type, see .Xr Pstack_iter 3PROC .

p .Sy proc_fdinfo_f

p The .Sy proc_fdinfo_f is a function pointer type that is used with the .Fn Pfdinfo_iter function. It is defined as .Sy typedef .Ft int .Fo proc_fdinfo_f .Fa "void *" .Fa "prfdinfo_t *" .Fc . The first argument is a pointer to an argument that the user specifies. The second argument contains information about an open file descriptor. The members of the .Sy prfdinfo_t are defined earlier in this section. For additional information on using this type, see .Xr Pfdinfo_iter 3PROC . .Sh PROGRAMMING NOTES When working with live processes, whether from the .Xr Pgrab or .Xr Pcreate family of functions, there are some additional considerations. Importantly, if a process calls any of the .Xr exec 2 suite of functions, much of the state information that is obtained, particularly that about mappings in the process will be invalid. Callers must ensure that they call .Xr Preset_maps 3PROC when they hold a process handle across an exec. In addition, users of the library should familiarize themselves with the .Sy PROGRAMMING NOTES section of the .Xr proc 4 manual page, which discusses issues of privileges and security. .Sh DEBUGGING The library provides a means for obtaining additional debugging information. The output itself is not part of the .Nm library's stable interface. Setting the environment variable .Ev LIBPROC_DEBUG to some value will print information to standard error. For example, .Ev LIBPROC_DEUBG Ns = Ns Em please . .Sh LOCKING Most functions operate on a handle to a process in the form of a .Vt "struct ps_prochandle *" . Unless otherwise indicated, the library does not provide any synchronization for different routines that are operating on the .Sy same .Nm library handle. It is up to the caller to ensure that only a single thread is using a handle at any given time. Multiple threads may call .Nm library routines at the same time as long as each thread is using a different handle.

p Each individual function notes its .Sy MT-Level section. The MT-Level of a routine that matches the above description will refer to this manual page. If it does not, then it refers to the standard attributes in .Xr attributes 5 . .Sh INTERFACE STABILITY .Sy Uncommitted

p While the library is considered an uncommitted interface, and is still evolving, changes that break compatibility have been uncommon and this trend is expected to continue. It is documented to allow consumers, whether part of illumos or outside of it, to understand the libarary and make use of it with the understanding that changes may occur which break both source and binary compatibility. .Sh SEE ALSO .Xr gcore 1 , .Xr mdb 1 , .Xr proc 1 , .Xr ps 1 , .Xr coreadm 1M , .Xr exec 2 , .Xr fcntl 2 , .Xr stat 2 , .Xr Intro 3 , .Xr dlopen 3C , .Xr elf 3ELF , .Xr ctf 4 , .Xr proc 4 , .Xr attributes 5 , .Xr environ 5 , .Xr privileges 5

p .Rs .%T Linkers and Libraries Guide .Re

p .Xr Lfree 3PROC , .Xr Lgrab 3PROC , .Xr Lgrab_error 3PROC , .Xr Pcreate 3PROC , .Xr Pcreate_agent 3PROC , .Xr Pcreate_callback 3PROC , .Xr Pcreate_error 3PROC , .Xr Pdestroy_agent 3PROC , .Xr Pfgrab_core 3PROC , .Xr Pfree 3PROC , .Xr Pgrab 3PROC , .Xr Pgrab_core 3PROC , .Xr Pgrab_error 3PROC , .Xr Pgrab_file 3PROC , .Xr Pgrab_ops 3PROC , .Xr Prelease 3PROC , .Xr Preopen 3PROC , .Xr Pxcreate 3PROC

p .Xr Paddr_to_ctf 3PROC , .Xr Paddr_to_loadobj 3PROC , .Xr Paddr_to_map 3PROC , .Xr Paddr_to_text_map 3PROC , .Xr Pasfd 3PROC , .Xr Pclearfault 3PROC , .Xr Pclearsig 3PROC , .Xr Pcontent 3PROC , .Xr Pcred 3PROC , .Xr Pctlfd 3PROC , .Xr Pdelbkpt 3PROC , .Xr Pdelwapt 3PROC , .Xr Pdstop 3PROC , .Xr Pexecname 3PROC , .Xr Pfault 3PROC , .Xr Pfgcore 3PROC , .Xr Pgcore 3PROC , .Xr Pgetareg 3PROC , .Xr Pgetauxval 3PROC , .Xr Pgetauxvec 3PROC , .Xr Pgetenv 3PROC , .Xr Pisprocdir 3PROC , .Xr Pissyscall_prev 3PROC , .Xr Plmid 3PROC , .Xr Plmid_to_loadobj 3PROC , .Xr Plmid_to_map 3PROC , .Xr Plookup_by_addr 3PROC , .Xr Plookup_by_name 3PROC , .Xr Plwp_alt_stack 3PROC , .Xr Plwp_getfpregs 3PROC , .Xr Plwp_getpsinfo 3PROC , .Xr Plwp_getregs 3PROC , .Xr Plwp_getspymaster 3PROC , .Xr Plwp_main_stack 3PROC , .Xr Plwp_setfpregs 3PROC , .Xr Plwp_setregs 3PROC , .Xr Plwp_stack 3PROC , .Xr Pname_to_ctf 3PROC , .Xr Pname_to_loadobj 3PROC , .Xr Pname_to_map 3PROC , .Xr Pobjname 3PROC , .Xr Pobjname_resolved 3PROC , .Xr Pplatform 3PROC , .Xr Ppltdest 3PROC , .Xr Ppriv 3PROC , .Xr Ppsinfo 3PROC , .Xr Pputareg 3PROC , .Xr Prd_agent 3PROC , .Xr Pread 3PROC , .Xr Pread_string 3PROC , .Xr Preset_maps 3PROC , .Xr Psetbkpt 3PROC , .Xr Psetcred 3PROC , .Xr Psetfault 3PROC , .Xr Psetflags 3PROC , .Xr Psetpriv 3PROC , .Xr Psetrun 3PROC , .Xr Psetsignal 3PROC , .Xr Psetsysentry 3PROC , .Xr Psetsysexit 3PROC , .Xr Psetwapt 3PROC , .Xr Psetzoneid 3PROC , .Xr Psignal 3PROC , .Xr Pstate 3PROC , .Xr Pstatus 3PROC , .Xr Pstop 3PROC , .Xr Pstopstatus 3PROC , .Xr Psync 3PROC , .Xr Psysentry 3PROC , .Xr Psysexit 3PROC , .Xr Puname 3PROC , .Xr Punsetflags 3PROC , .Xr Pupdate_maps 3PROC , .Xr Pupdate_syms 3PROC , .Xr Pwait 3PROC , .Xr Pwrite 3PROC , .Xr Pxecbkpt 3PROC , .Xr Pxecwapt 3PROC , .Xr Pxlookup_by_addr 3PROC , .Xr Pxlookup_by_addr_resolved 3PROC , .Xr Pxlookup_by_name 3PROC , .Xr Pzonename 3PROC , .Xr Pzonepath 3PROC , .Xr Pzoneroot 3PROC

p .Xr Lalt_stack 3PROC , .Xr Lclearfault 3PROC , .Xr Lclearsig 3PROC , .Xr Lctlfd 3PROC , .Xr Ldstop 3PROC , .Xr Lgetareg 3PROC , .Xr Lmain_stack 3PROC , .Xr Lprochandle 3PROC , .Xr Lpsinfo 3PROC , .Xr Lputareg 3PROC , .Xr Lsetrun 3PROC , .Xr Lstack 3PROC , .Xr Lstate 3PROC , .Xr Lstatus 3PROC , .Xr Lstop 3PROC , .Xr Lsync 3PROC , .Xr Lwait 3PROC , .Xr Lxecbkpt 3PROC , .Xr Lxecwapt 3PROC

p .Xr pr_access 3PROC , .Xr pr_close 3PROC , .Xr pr_creat 3PROC , .Xr pr_door_info 3PROC , .Xr pr_exit 3PROC , .Xr pr_fcntl 3PROC , .Xr pr_fstat 3PROC , .Xr pr_fstat64 3PROC , .Xr pr_fstatvfs 3PROC , .Xr pr_getitimer 3PROC , .Xr pr_getpeername 3PROC , .Xr pr_getpeerucred 3PROC , .Xr pr_getprojid 3PROC , .Xr pr_getrctl 3PROC , .Xr pr_getrlimit 3PROC , .Xr pr_getrlimit64 3PROC , .Xr pr_getsockname 3PROC , .Xr pr_getsockopt 3PROC , .Xr pr_gettaskid 3PROC , .Xr pr_getzoneid 3PROC , .Xr pr_ioctl 3PROC , .Xr pr_link 3PROC , .Xr pr_llseek 3PROC , .Xr pr_lseek 3PROC , .Xr pr_lstat 3PROC , .Xr pr_lstat64 3PROC , .Xr pr_memcntl 3PROC , .Xr pr_meminfo 3PROC , .Xr pr_mmap 3PROC , .Xr pr_munmap 3PROC , .Xr pr_open 3PROC , .Xr pr_processor_bind 3PROC , .Xr pr_rename 3PROC , .Xr pr_setitimer 3PROC , .Xr pr_setrctl 3PROC , .Xr pr_setrlimit 3PROC , .Xr pr_setrlimit64 3PROC , .Xr pr_settaskid 3PROC , .Xr pr_sigaction 3PROC , .Xr pr_stat 3PROC , .Xr pr_stat64 3PROC , .Xr pr_statvfs 3PROC , .Xr pr_unlink 3PROC , .Xr pr_waitid 3PROC ,

p .Xr Penv_iter 3PROC , .Xr Plwp_iter 3PROC , .Xr Plwp_iter_all 3PROC , .Xr Pmapping_iter 3PROC , .Xr Pmapping_iter_resolved 3PROC , .Xr Pobject_iter 3PROC , .Xr Pobject_iter_resolved 3PROC , .Xr Pstack_iter 3PROC , .Xr Psymbol_iter 3PROC , .Xr Psymbol_iter_by_addr 3PROC , .Xr Psymbol_iter_by_lmid 3PROC , .Xr Psymbol_iter_by_name 3PROC , .Xr Pxsymbol_iter 3PROC , .Xr Pfdinfo_iter 3PROC

p .Xr Perror_printf 3PROC , .Xr proc_arg_grab 3PROC , .Xr proc_arg_psinfo 3PROC , .Xr proc_arg_xgrab 3PROC , .Xr proc_arg_xpsinfo 3PROC , .Xr proc_content2str 3PROC , .Xr proc_finistdio 3PROC , .Xr proc_fltname 3PROC , .Xr proc_fltset2str 3PROC , .Xr proc_flushstdio 3PROC , .Xr proc_get_auxv 3PROC , .Xr proc_get_cred 3PROC , .Xr proc_get_priv 3PROC , .Xr proc_get_psinfo 3PROC , .Xr proc_get_status 3PROC , .Xr proc_initstdio 3PROC , .Xr proc_lwp_in_set 3PROC , .Xr proc_lwp_range_valid 3PROC , .Xr proc_signame 3PROC , .Xr proc_sigset2str 3PROC , .Xr proc_str2content 3PROC , .Xr proc_str2flt 3PROC , .Xr proc_str2fltset 3PROC , .Xr proc_str2sig 3PROC , .Xr proc_str2sigset 3PROC , .Xr proc_str2sys 3PROC , .Xr proc_str2sysset 3PROC , .Xr proc_sysname 3PROC , .Xr proc_sysset2str 3PROC , .Xr proc_unctrl_psinfo 3PROC , .Xr proc_walk 3PROC

p .Xr Pldt 3PROC , .Xr proc_get_ldt 3PROC ,

p .Xr Plwp_getgwindows 3PROC , .Xr Plwp_getxregs 3PROC , .Xr Plwp_setxregs 3PROC ,

p .Xr Plwp_getasrs 3PROC , .Xr Plwp_setasrs 3PROC