UNW_SET_REG(3libunwind)
β¨ UNW_SET_REG β¨
okay bestie, welcome to the libunwind corner of the 3libunwind manual, where we're talking about unw_set_reg β yes, it does exactly what it sounds like, it sets register contents π
πΈ NAME πΈ
unw_set_reg -- set register contents. that's it, that's the vibe. you're writing a value into a register. iconic behavior, honestly.
π SYNOPSIS π
#include <libunwind.h>
int unw_set_reg(unw_cursor_t *cp, unw_regnum_t reg, unw_word_t val);
like, three args, no drama. we love a low-maintenance signature π«Ά
π DESCRIPTION π
so here's the tea: unw_set_reg() sets the value of register reg in the stack frame identified by cursor cp to the value passed in val. that's the whole plot. no plot twist. slay β¨
the register numbering is target dependent, and it's described in separate manual pages (for example, libunwind-ia64(3libunwind) for the IA-64 target). so like, don't assume the numbers mean the same thing everywhere, bestie, go read your target's page π
also?? the exact set of accessible registers may depend on the type of frame that cp is referring to. for ordinary stack frames, it is normally possible to access only the preserved (``callee-saved'') registers and frame-related registers (such as the stack pointer). but for signal frames (see unw_is_signal_frame(3libunwind)), it is usually possible to access all registers. so signal frames are the ones with main character energy and full access, and ordinary frames are the ones gatekeeping their register list π
not me being the bearer of bad news but:unw_set_reg()can only write the contents of registers whose values fit in a single word. seeunw_set_fpreg(3libunwind)for a way to write registers which do not fit this constraint. one word. that's the limit. periodt π
π RETURN VALUE π
on successful completion, unw_set_reg() returns 0. otherwise, the negative value of one of the error codes below is returned. yes, negative. keep an eye on that sign, bestie, it's giving "surprise" if you don't π₯
π¦ THREAD AND SIGNAL SAFETY π¦
unw_set_reg() is thread-safe as well as safe to use from a signal handler. fully unbothered, moisturized, in her lane, thriving π
π ERRORS π
UNW_EUNSPECβ an unspecified error occurred. like, we don't know what happened either. mystery era πUNW_EBADREGβ an attempt was made to write a register that is either invalid or not accessible in the current frame. girl said no βUNW_EREADONLYβ an attempt was made to write to a read-only register. read-only means read-only, babes, respect the boundary π«
in addition, unw_set_reg() may return any error returned by the access_mem(), access_reg(), and access_fpreg() callbacks (see unw_create_addr_space(3libunwind)). so like, the callback squad can also hand you an error. checks out π«‘
β SEE ALSO β
libunwind(3libunwind)libunwind-ia64(3libunwind)unw_get_reg(3libunwind)unw_is_signal_frame(3libunwind)unw_set_fpreg(3libunwind)
go read them, iykyk π
π AUTHOR π
David Mosberger-Tang Email: dmosberger@gmail.com WWW: http://www.nongnu.org/libunwind/
and that's the whole page bestie!! this one's from the Programming Library era, dated 29 August 2023, and it lives under UNW_SET_REG(3libunwind). go set some registers responsibly, mwah πβ¨π
π¦ 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