UNW_AP...G_STATE(3libunwind)

πŸ’– unw_apply_reg_state β€” bestie, let's update that cursor πŸ’–

okay so real talk, this is page UNW_AP...G_STATE(3libunwind) from the libunwind manual (section 3, programming library energy ✨). It's the one that takes a register state you already scooped up and applies it. Let's go 🫢


✨ NAME ✨

unw_apply_reg_state β€” apply a register state update to a cursor

Like, you've got a cursor, you've got some register state data, and this function is the matchmaker. πŸ’…


🌸 SYNOPSIS 🌸

#include <libunwind.h>

int unw_apply_reg_state(unw_cursor_t *cp, void *reg_states_data);

πŸ¦‹ DESCRIPTION πŸ¦‹

The unw_apply_reg_state() routine updates the register values of a cursor according to the instructions in reg_states_data, which have been obtained by calling unw_reg_states_iterate.

That's it. That's the whole vibe. You got the data from unw_reg_states_iterate, and now you're feeding it back in to actually move the cursor's registers where they need to go. Cursor gets a glow-up. 🌈


πŸ‘‘ RETURN VALUE πŸ‘‘

On successful completion, unw_apply_reg_state() returns 0. Otherwise the negative value of one of the error codes below is returned.

So like, zero is the slay outcome. Anything negative? Not slay. Check the list. 😭

πŸ”₯ THREAD AND SIGNAL SAFETY πŸ”₯

unw_apply_reg_state() is thread safe. If cursor cp is in the local address space, this routine is also safe to use from a signal handler.

Translation bestie: threads? fine. Signal handler? only if cp is living in the local address space. Periodt. πŸ’€


πŸ’œ ERRORS πŸ’œ

  • UNW_EUNSPEC β€” An unspecified error occurred. (Mystery error. No further info. It's giving cryptic. πŸ™ˆ)
  • UNW_ENOINFO β€” Libunwind was unable to locate unwind-info for the procedure.
  • UNW_EBADVERSION β€” The unwind info for the procedure has version or format that is not understood by libunwind.

In addition, unw_apply_reg_state() may return any error returned by the access_mem() call-back (see unw_create_addr_space(3libunwind)).

ngl that last one is the sneaky one β€” the callback can hand you back its own errors and this function will just pass them along. iykyk.

πŸŽ€ SEE ALSO πŸŽ€


⭐ AUTHOR ⭐

David Mosberger-Tang

Email: dmosberger@gmail.com

WWW: http://www.nongnu.org/libunwind/


and that's the whole page, bestie πŸ’– it's from the Programming Library, dated 29 August 2023, filed under UNW_AP...G_STATE(3libunwind) β€” go forth and apply those register states, you absolute icon πŸ‘‘βœ¨