UNW_GET_PROC_INFO(3libunwind)
π UNW_GET_PROC_INFO π
okay so bestie, welcome to unw_get_proc_info(3libunwind) β it's a little function from the libunwind programming library and it's literally here to spill the tea about whatever procedure made a stack frame. sit down, grab a boba, we're doing this. π§
β¨ NAME β¨
unw_get_proc_info β get info on current procedure
πΈ SYNOPSIS πΈ
#include <libunwind.h>
int unw_get_proc_info(unw_cursor_t *cp, unw_proc_info_t *pip);
π¦ DESCRIPTION π¦
so the unw_get_proc_info() routine hands you back the auxiliary info about the procedure that created the stack frame your argument cp is pointing at. the pip argument is a pointer to a structure of type unw_proc_info_t, and that's where all the info goes to live. no cap.
and unw_proc_info_t has these members, okay, let's go one by one because she's got range:
unw_word_t start_ipβ the address of the very first instruction of the procedure. if this address can't be figured out (like, say, there's no unwind information to work with π), thenstart_ipgets cleared to0.unw_word_t end_ipβ the address of the first instruction beyond the end of the procedure (so, like, one past the finish line, not the last instruction itself π ). if this address can't be determined (again, e.g. because of missing unwind information),end_ipgets cleared to0.unw_word_t lsdaβ the address of the language-specific data area (LSDA). this area normally holds language-specific stuff that's needed during exception handling. if the procedure doesn't have one of those areas, this member is cleared to0.unw_word_t handlerβ the address of the exception handler routine. sometimes people call this the personality routine. if the procedure doesn't define a personality routine,handlergets cleared to0.unw_word_t gpβ the global pointer of the procedure. on platforms that don't use a global pointer, this member may hold an undefined value π. on all other platforms, it must be set either to the correct global pointer value of the procedure, or to0if the proper global pointer can't be obtained for some reason.unw_word_t flagsβ a set of flags. rn there are no target-independent flags. for the IA-64 target tho, the flagUNW_PI_FLAG_IA64_RBS_SWITCHis set if the procedure may switch the register backing store.int formatβ the format of the unwind info for this procedure. if the unwind info is dynamic procedure info,formatequalsUNW_INFO_FORMAT_DYNAMIC. if the unwind info is a (target-specific) unwind table, it equalsUNW_INFO_FORMAT_TABLE. all other values are reserved for future use by libunwind. this member exists for thefind_proc_info()callback to use (peepunw_create_addr_space(3libunwind)). and heads up βunw_get_proc_info()may return an undefined value in this member. πint unwind_info_sizeβ the size of the unwind info in bytes. this member exists for use by thefind_proc_info()callback (again, seeunw_create_addr_space(3libunwind)). and again,unw_get_proc_info()may return an undefined value in this member.void *unwind_infoβ the pointer to the unwind info. if no unwind info is available, this member must be set toNULL. this member exists for thefind_proc_info()callback to use (yes,unw_create_addr_space(3libunwind)). and yep,unw_get_proc_info()may return an undefined value in this member.
also, important vibe check: for libunwind's purposes, the code of a procedure is assumed to occupy a single, contiguous range of addresses. that's why it's always possible to describe the extent of a procedure with thestart_ipandend_ipmembers. if one single function/routine gets split into multiple discontiguous pieces, libunwind just treats each piece as its own separate procedure. periodt. π
β RETURN VALUE β
on successful completion, unw_get_proc_info() returns 0. otherwise, the negative value of one of the error codes listed below comes back at you. π
π«Ά THREAD AND SIGNAL SAFETY π«Ά
unw_get_proc_info() is thread safe, slay. and if cursor cp is in the local address space, this routine is also safe to use from a signal handler. iconic behaviour honestly.
π ERRORS π
UNW_EUNSPECβ an unspecified error occurred. (the classic "something happened, idk what" π)UNW_ENOINFOβ libunwind was unable to locate unwind info for the procedure.UNW_EBADVERSIONβ the unwind info for the procedure has a version or format that libunwind does not understand.
on top of all that, unw_get_proc_info() may also return any error returned by the access_mem() callback (see unw_create_addr_space(3libunwind)).
π SEE ALSO π
libunwind(3libunwind), unw_create_addr_space(3libunwind), unw_get_proc_name(3libunwind)
π AUTHOR π
David Mosberger-Tang Email: dmosberger@gmail.com WWW: http://www.nongnu.org/libunwind/
and that's the whole page bestie!! this Programming Library moment was brought to you by the 29 August 2023 era of the libunwind manual, and honestly she ate. go forth and unwind your stacks responsibly πβ¨π
π¦ where this page comes from
- debian trixie: libunwind-dev 1.8.1-0.1 Β· MIT
- ubuntu questing: libunwind-dev 1.8.1-0.1ubuntu1
- ubuntu resolute: libunwind-dev 1.8.3-0ubuntu1 Β· MIT
- ubuntu stonking: libunwind-dev 1.8.3-0ubuntu1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms