1UNW_BACKTRACE(3)             Programming Library              UNW_BACKTRACE(3)
2
3
4

NAME

6       unw_backtrace -- return backtrace for the calling program
7

SYNOPSIS

9       #include <libunwind.h>
10
11       int unw_backtrace(void **buffer, int size);
12       int  unw_backtrace2(void  **buffer,  int size, unw_context_t *ctxt, int
13       flag);
14
15       #include <execinfo.h>
16
17       int backtrace(void **buffer, int size);
18

DESCRIPTION

20       unw_backtrace() is a convenient routine for obtaining the backtrace for
21       the  calling program. The routine fills up to size addresses in the ar‐
22       ray pointed by buffer.  The routine is only available for local unwind‐
23       ing.
24
25       Note  that  many  (but not all) systems provide a practically identical
26       function called backtrace().  The prototype for this function  is  usu‐
27       ally  obtained by including the <execinfo.h> header file -- a prototype
28       for backtrace() is not provided by libunwind.  libunwind weakly aliases
29       backtrace()  to  unw_backtrace(), so when a program calling backtrace()
30       is linked against libunwind, it may end up calling unw_backtrace().
31
32       In case you want to obtain the backtrace from a specific unw_context_t,
33       you  can  call unw_backtrace2 with that context passing 0 for flag.  If
34       the unw_context_t is known to be a signal frame (i.e., from  the  third
35       argument  in  a sigaction handler on linux), unw_backtrace2 can be used
36       to collect  only  the  frames  before  the  signal  frame  passing  the
37       UNW_INIT_SIGNAL_FRAME flag.
38

RETURN VALUE

40       The routine returns the number of addresses stored in the array pointed
41       by buffer.  The return value may be zero to indicate that no  addresses
42       were stored.
43

SEE ALSO

45       libunwind(3), unw_step(3)
46

AUTHOR

48       David Mosberger-Tang
49       Email: dmosberger@gmail.com
50       WWW: http://www.nongnu.org/libunwind/.
51
52
53
54Programming Library             05 January 2023               UNW_BACKTRACE(3)
Impressum