HP-UX Reference (11i v3 07/02) - 3 Library Functions A-M (vol 6)

_
_UNW_createContextForSelf(3X) _UNW_createContextForSelf(3X)
(Integrity Systems Only)
EXAMPLES
Example 1
Allocate and initialize an _Unwind_Context
for unwinding the currently running process:
#include <unwind.h>
#include <stdio.h>
_Unwind_Context *uc;
_UNW_ReturnCode retcode;
uc = _UNW_createContextForSelf();
if (uc == NULL) {
/* Code to notify user of low memory problem */
}
if (_UNW_getAlertCode(uc) == _UNW_MEMORY_ALLOCATION_ERROR) {
/* Code to notify user of low memory problem */
}
/* Example use of the _Unwind_Context * follows: */
if ((retcode = _UNW_currentContext(uc)) != _UNW_OK) {
/* Notify user: Couldn’t determine current context. */
}
Example 2
Allocate and initialize an _Unwind_Context
for unwinding a process other than the running process:
#include <unwind.h>
#include <stdio.h>
_Unwind_Context *uc;
_UNW_ReturnCode retcode;
extern _UNW_ReadTargetMem my_mem_reader;
extern _UNW_LoadMapFromIP my_dlmodule_info;
uint64_t target_ip; /* Target process instruction pointer */
uc = _UNW_createContext(my_mem_reader, my_dlmodule_info,1);
if (_UNW_getAlertCode(uc) == _UNW_MEMORY_ALLOCATION_ERROR) {
/* Code to notify user of low memory problem */
}
/* Example use of the _Unwind_Context * follows: */
if ((retcode = _UNW_setIP(uc,target_ip)) != _UNW_OK) {
/* Notify user: Initialization problem */
}
AUTHOR
_UNW_createContextForSelf
, _UNW_createContext, and _UNW_destroyContext
were
developed by HP.
SEE ALSO
U_STACK_TRACE(3X), _UNW_currentContext(3X), _UNW_getGR(3X), unwind(5).
HP-UX 11i Version 3: February 2007 3 Hewlett-Packard Company 71