1UNW_GETCONTEXT(3) Programming Library UNW_GETCONTEXT(3)
2
3
4
6 unw_getcontext -- get initial machine-state
7
9 #include <libunwind.h>
10
11 int unw_getcontext(unw_context_t *ucp);
12
14 The unw_getcontext() routine initializes the context structure pointed
15 to by ucp with the machine-state of the call-site. The exact set of
16 registers stored by unw_getcontext() is platform-specific, but, in gen‐
17 eral, at least all preserved (``callee-saved'') and all frame-related
18 registers, such as the stack-pointer, will be stored.
19
20 This routine is normally implemented as a macro and applications should
21 not attempt to take its address.
22
24 On IA-64, unw_context_t has a layout that is compatible with that of
25 ucontext_t and such structures can be initialized with getcontext()
26 instead of unw_getcontext(). However, the reverse is not true and it
27 is not safe to use structures initialized by unw_getcontext() in places
28 where a structure initialized by getcontext() is expected. The reason
29 for this asymmetry is that unw_getcontext() is optimized for maximum
30 performance and does not, for example, save the signal mask.
31
33 On successful completion, unw_getcontext() returns 0. Otherwise, a
34 value of -1 is returned.
35
37 unw_getcontext() is thread-safe as well as safe to use from a signal
38 handler.
39
41 libunwind(3), unw_init_local(3)
42
44 David Mosberger-Tang
45 Email: dmosberger@gmail.com
46 WWW: http://www.nongnu.org/libunwind/.
47
48
49
50Programming Library 16 August 2007 UNW_GETCONTEXT(3)