UNW_SET_FPREG(3libunwind)

✨ UNW_SET_FPREG ✨

okay bestie, gather round, because today we're setting floating-point registers and honestly? it's giving main character energy πŸ’… this one lives in libunwind (the programming library, she's fancy), and no cap, she's a whole vibe.


🌸 NAME 🌸

unw_set_fpreg β€” set contents of floating-point register πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

#include <libunwind.h>

int unw_set_fpreg(unw_cursor_t *cp, unw_regnum_t reg, unw_fpreg_t val);

πŸ¦‹ DESCRIPTION πŸ¦‹

so what does unw_set_fpreg() actually do, you ask? she sets the value of register reg in the stack frame that the cursor cp is pointing at, and she sets it to whatever you passed in val. that's it. that's the whole job. iconic behavior, truly. ✨

now, the register numbering? target-dependent, babes. like, it's described in separate manual pages β€” for example libunwind-ia64(3libunwind) if you're on the IA-64 target. every target has its own lore, iykyk.

also! the exact set of registers you can actually reach may depend on what kind of frame cp is referring to. for ordinary stack frames, you can normally only access the preserved (``callee-saved'') registers and the frame-related registers (stuff like the stack-pointer). like, she's a little exclusive, ok? BUT β€” for signal frames (peep unw_is_signal_frame(3libunwind) for that one), it's usually possible to access all the registers. full VIP access, slay. πŸ‘‘

heads up bestie: unw_set_fpreg() can only write the contents of floating-point registers. if you need to write registers that fit in a single word, go see unw_set_reg(3libunwind). different function, different task, no overlap. πŸ’–

🌈 RETURN VALUE 🌈

on successful completion, unw_set_fpreg() returns 0. πŸŽ‰ otherwise she hands you back the negative value of one of the error codes listed down below. yes, negative. that's just how she is. 😭


πŸ’œ THREAD AND SIGNAL SAFETY πŸ’œ

unw_set_fpreg() is thread safe and safe to use from a signal handler. double certified. queen shit. πŸ‘‘βœ¨


πŸ”₯ ERRORS πŸ”₯

  • UNW_EUNSPEC β€” an unspecified error occurred. like, she's not gonna tell you what happened. mysterious. πŸ’€
  • UNW_EBADREG β€” an attempt was made to write a register that is either invalid or not accessible in the current frame. (rude of you, honestly πŸ™ˆ)
  • UNW_EREADONLY β€” an attempt was made to write to a read-only register. bestie. she said no. 🚫

plus, unw_set_fpreg() may return any error returned by the access_mem(), access_reg(), and access_fpreg() callbacks (go check unw_create_addr_space(3libunwind) for the deets). so many ways to fail, so little time. πŸ’…


🫢 SEE ALSO 🫢


⭐ AUTHOR ⭐

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


and that's the tea πŸ“ this page came from the Programming Library, dated 29 August 2023, filed under UNW_SET_FPREG(3libunwind). go set some registers, bestie, you've got this πŸ’–βœ¨πŸŽ€
πŸ“¦ where this page comes from