UNW_GET...N_RANGE(3libunwind)

πŸ’– UNW_GET...N_RANGE β€” bestie edition πŸ’–

okay so this is a page from libunwind, section 3libunwind β€” the programming library zone. Grab a strawberry πŸ“ and let's get into it.


✨ NAME ✨

unw_get_proc_info_in_range β€” bestie, it gets you procedure info inside an IP range plus a frame index table. That's the whole vibe.


🌸 SYNOPSIS 🌸

#include <libunwind.h>

int unw_get_proc_info_in_range(unw_word_t start_ip, unw_word_t end_ip,
unw_word_t eh_frame_table, unw_word_t eh_frame_table_len, unw_word_t
exidx_frame_table, unw_word_t exidx_frame_table_len,, unw_addr_space_t
*as, void *arg);
ngl, yes, there really are two commas in a row up there in the original signature (exidx_frame_table_len,,). Not a typo I made. I'm just the messenger πŸ’… copy it as-is, bestie.

πŸ¦‹ DESCRIPTION πŸ¦‹

So unw_get_proc_info_in_range() hands you back the same kind of auxiliary info about a procedure that unw_get_proc_info_by_ip() does. Same flavor, same energy. 🫢

The difference? It looks the info up in an instruction pointer (IP) range and a frame table, instead of just at a single IP. That's it, that's the twist.

And the way this is equally flexible is that you can look up the info for any arbitrary procedure β€” even one that is not part of the current call chain. Iconic, honestly. Main character energy for a lookup function.

But βœ‹ and this is the part where I hold your hand β€” because it's more flexible, it also tends to run slower than unw_get_proc_info(). And not like a lil slower. often much slower. 😭 So like… know what you're signing up for.


πŸ’… RETURN VALUE πŸ’…

  • On a successful completion, unw_get_proc_info_in_range() returns 0. Slay.
  • Otherwise it returns the negative value of one of the error codes listed below. Not slay, but informative.

🧚 THREAD AND SIGNAL SAFETY 🧚

unw_get_proc_info_in_range() is thread safe. Periodt. πŸ’–

And bonus: if the local address space is passed in the argument as, then this routine is also safe to use from a signal handler. Little treat for you. πŸŽ€


πŸ‘‘ ERRORS πŸ‘‘

  • UNW_EUNSPEC β€” an unspecified error occurred. Vague, mysterious, unhelpful. πŸ’€
  • UNW_ENOINFO β€” libunwind was unable to locate unwind-info for the procedure. It went looking, it found nothing. πŸ•΅οΈ
  • UNW_EBADVERSION β€” the unwind-info for the procedure has a version or format that is not understood by libunwind. It's giving "I don't speak that language." 😭
  • UNW_EINVAL β€” an unsupported table encoding was specified. Bestie. Check your encoding.

Plus: unw_get_proc_info_by_ip() may return any error returned by the access_mem() callback β€” go see unw_create_addr_space(3libunwind) for that whole situation.


🌈 SEE ALSO 🌈


⭐ AUTHOR ⭐

David Mosberger-Tang Email: dmosberger@gmail.com WWW: http://www.nongnu.org/libunwind/


okay that's the whole page, you ate it, go forth and unwind (or like, don't, but with correct error handling) πŸ’œ

This gem came out of the Programming Library manual set, dated 29 August 2023, filed under UNW_GET...N_RANGE(3libunwind). Bye bestie! πŸ¦‹βœ¨