UNW_GET...E_BY_IP(3libunwind)
β¨ unw_get_elf_filename_by_ip β bestie edition β¨
okay so you wanna know which elf file some instruction pointer came from? say less. this is from libunwind, manual section 3libunwind, and it's giving detective energy but for addresses. π΅οΈβοΈπ
πΈ NAME πΈ
unw_get_elf_filename_by_ip β get the backing elf filename by instruction pointer. literally that's the whole job. no cap.
π SYNOPSIS π
#include <libunwind.h>
int unw_get_elf_filename_by_ip(unw_addr_space_t as, unw_word_t ip, char
*bufp, size_t len, unw_word_t *offp, void *arg);
π¦ DESCRIPTION π¦
so unw_get_elf_filename_by_ip() hands you the backing elf filename for an instruction pointer β exactly like unw_get_elf_filename() does, bestie, with one glow-up: the name gets looked up by instruction pointer (IP) instead of by a cursor. same vibe, different lookup key. π
here's what you gotta feed it, argument by argument:
asβ the address-space where the instruction pointer should be looked up. if you're looking things up in the local address-space, you can just passunw_local_addr_spacehere and call it a day.ipβ the instruction-pointer you want the elf filename for. the main character of this whole operation, honestly. β¨bufpβ a pointer to a character buffer that's at leastlenbytes long. this is where the elf filename gets returned. make sure it's big enough or things get spicy (seeUNW_ENOMEMbelow π).lenβ how long that buffer is, in bytes.offpβ a pointer to a word used to return the byte offset of the instruction-pointer relative to the start of the elf filename. cute little positional receipt. π§Ύargβ the address space argument used when accessing the address space. it has the same purpose as the argument of the same name forunw_init_remote().
β οΈ important bestie moment: when you're accessing the local address space (i.e. the first argument isunw_local_addr_space), you must passNULLforarg. not optional.NULL. periodt.
π RETURN VALUE π
on successful completion, unw_get_elf_filename_by_ip() returns 0. slay. π
otherwise, it returns the negative value of one of the error codes listed below. so like, negative. remember that.
π₯ THREAD AND SIGNAL SAFETY π₯
unw_get_elf_filename_by_ip() is thread safe. π
and if the local address-space is passed in argument as, this routine is also safe to use from a signal handler. iconic behaviour, truly.
π ERRORS π
UNW_EUNSPECβ an unspecified error occurred. mystery error, no further info, we move. πUNW_ENOINFOβ libunwind was unable to determine the elf filename of the instruction pointer. it tried, bestie. it just doesn't know. πUNW_ENOMEMβ the elf filename is too long to fit in the buffer you provided. heads up: a truncated version of the name has been returned. so you got something, just not all of it. π
π SEE ALSO π
libunwind(3libunwind)unw_get_elf_filename(3libunwind)unw_create_addr_space(3libunwind)unw_init_remote(3libunwind)
π AUTHOR π
Xiang Lin Email: myd.xia@gmail.com
Programming Library Β· 15 September 2023 Β· UNW_GET...E_BY_IP(3libunwind)
and that's the whole page, bestie β go look up some elf filenames, you've got this π π«Άβ¨
π¦ 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