UNW_BACKTRACE(3libunwind)
π UNW_BACKTRACE π
okay bestie, welcome to unw_backtrace from the libunwind programming library β she returns a backtrace for the calling program and honestly? iconic behaviour. let's get into it π«Ά
β¨ NAME β¨
unw_backtrace β return backtrace for the calling program π
π SYNOPSIS π
#include <libunwind.h>
int unw_backtrace(void **buffer, int size);
int unw_backtrace2(void **buffer, int size, unw_context_t *ctxt, int
flag);
#include <execinfo.h>
int backtrace(void **buffer, int size);
π¦ DESCRIPTION π¦
so unw_backtrace() is basically the convenience queen of getting a backtrace for the calling program. she fills up to size addresses into the array that buffer points at. no cap. the one thing to remember: she's only available for local unwinding β that's her whole lane, periodt.
π heads up bestie: lots of systems (but not all of them) ship a practically identical function calledbacktrace(). the prototype for it usually comes from including the<execinfo.h>header file β and ngl,libunwinddoes not hand you a prototype forbacktrace(). instead,libunwindweakly aliasesbacktrace()tounw_backtrace(), so if a program that's callingbacktrace()gets linked againstlibunwind, it may lowkey end up callingunw_backtrace()instead. it's giving surprise main character swap π.
and if you want the backtrace from a specific unw_context_t? that's what unw_backtrace2 is for, babe β call it with that context and pass 0 for flag. now if that unw_context_t is known to be a signal frame (like, say, the third argument in a sigaction handler on linux), then unw_backtrace2 can be used to collect only the frames before the signal frame by passing the UNW_INIT_SIGNAL_FRAME flag. slay. β¨
πΈ RETURN VALUE πΈ
the routine returns the number of addresses stored in the array pointed at by buffer. and yes, that return value may be 0, which is just her way of saying no addresses were stored. it's not a vibe fail, it's just data π
π SEE ALSO π
π AUTHOR π
- David Mosberger-Tang
- Email:
dmosberger@gmail.com - WWW:
http://www.nongnu.org/libunwind/
okay that's the whole page, bestie β go forth and unwind responsibly π§ this was the Programming Library era of the manual, dated 29 August 2023, and fr fr you ate reading the whole thing. mwah πππ¦
π¦ where this page comes from
- alpine 3.22: libunwind-doc 1.8.1-r0 Β· MIT
- alpine 3.23: libunwind-doc 1.8.1-r0 Β· MIT
- alpine 3.24: libunwind-doc 1.8.3-r0 Β· MIT
- arch rolling: libunwind 1.8.3-1 Β· MIT
- epel 10: libunwind-devel 1.8.0-4.el10_0 Β· MIT
- epel 9: libunwind-devel 1.8.0-4.el9 Β· MIT
- fedora 43: libunwind-devel 1.8.1-3.fc43 Β· MIT
- fedora 43: libunwind-devel 1.8.1-3.fc43 Β· MIT
- fedora 43: libunwind-devel 1.8.3-4.fc43 Β· MIT
- fedora 43: libunwind-devel 1.8.3-4.fc43 Β· MIT
- fedora 44: libunwind-devel 1.8.3-1.fc44 Β· MIT
- fedora 44: libunwind-devel 1.8.3-1.fc44 Β· MIT
- fedora 44: libunwind-devel 1.8.3-4.fc44 Β· MIT
- fedora 44: libunwind-devel 1.8.3-4.fc44 Β· MIT
- nixpkgs unstable: libunwind 1.8.3-devman
- opensuse-leap 16.0: libunwind-devel 1.8.1-160000.2.2 Β· MIT
- opensuse-leap 16.0: libunwind-devel 1.8.1-160000.2.2 Β· MIT
- opensuse-leap 16.0: libunwind-devel 1.8.1-160000.2.2 Β· MIT
- opensuse-leap 16.0: libunwind-devel 1.8.1-160000.2.2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms