DWARF_GET_FDE_INFO_FOR_CFA_REG3(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… DWARF_GET_FDE_INFO_FOR_CFA_REGS3 πŸ’…

okay so bestie, this one lives in the Library Functions Manual (section 3, the "functions" girlies) and it's all about digging CFA register rules out of libdwarf. also real quick β€” the page lowkey spells the function two ways (dwarf_get_fde_info_for_cfa_regs3 up top, dwarf_get_fde_info_for_cfa_reg3 everywhere else) and honestly? not me fixing it. we keep it exactly as the docs serve it. 🫢


✨ NAME ✨

dwarf_get_fde_info_for_cfa_regs3 β€” retrieve a CFA register rule πŸ’«

πŸ“š LIBRARY πŸ“š

DWARF Access Library (libdwarf, -ldwarf) β€” that's the vibe check for linking, bestie.

🧚 SYNOPSIS 🧚

#include <libdwarf.h>

int
dwarf_get_fde_info_for_cfa_regs3(Dwarf_Fde fde, Dwarf_Addr pc,
    Dwarf_Small *type, Dwarf_Signed *offset_relevant,
    Dwarf_Signed *register_num, Dwarf_Signed *offset_or_block_len,
    Dwarf_Ptr *block_ptr, Dwarf_Addr *row_pc, Dwarf_Error *err);

πŸ’– DESCRIPTION πŸ’–

So. Function dwarf_get_fde_info_for_cfa_reg3() retrieves the CFA register rule for a given program counter address, straight out of the register rule table that's associated with an FDE descriptor. it's giving "look up the row, hand you the tea." πŸ“

Argument fde should reference a valid DWARF FDE descriptor. no cap, it has to be valid.

Argument pc should hold the program counter address β€” that's the thing used to locate the desired register rule row. like a little address treasure hunt πŸ”₯

On successful execution, dwarf_get_fde_info_for_cfa_reg3() stores info about the CFA register rule it found into the locations pointed to by the arguments type, offset_relevant, register_num, offset_or_block_len, block_ptr and row_pc. that's a whole lot of out-params, and every single one of them is the main character πŸ’…

Argument type should point to a location which will hold the type code of the register rule found. the returned value is one of the DW_EXPR_* contants defined in the header file <libdwarf.h>. (yes, "contants" β€” that's the spelling the page gives us, and we respect the lore πŸ™ˆ)

If there's an offset value associated with the CFA register rule, the location pointed to by argument offset_relevant gets set to 1. that's it, that's the whole flag. slay.

Argument register_num should point to a location which will hold the register number associated with the CFA register rule. iconique.

Now the fun one β€” if the CFA register rule is of type DW_EXPR_OFFSET or DW_EXPR_VAL_OFFSET, the location pointed to by argument offset_or_block_len will be set to the offset value associated with the register rule, or to 0 if the register rule does not have an offset value. but if the type code is DW_EXPR_EXPRESSION or DW_EXPR_VAL_EXPRESSION, that same location pointed to by argument offset_or_block_len gets set to the length in bytes of the DWARF expression block associated with the register rule. same pointer, two completely different jobs β€” it's giving versatility, it's giving multifunctional queen πŸ‘‘

Argument block_ptr should point to a location which will be set to a pointer to the content of the DWARF expression block associated with the CFA register rule. πŸ¦‹

Argument row_pc should point to a location which will be set to the lowest program counter address associated with the register rule found. lowkey important detail, don't sleep on it.

If argument err is not NULL, it will be used to return an error descriptor in case of an error. so if you care about why it went wrong, hand it a real pointer, bestie.

🌈 RETURN VALUES 🌈

Function dwarf_get_fde_info_for_cfa_reg3() returns DW_DLV_OK when it succeeds. πŸŽ‰ In case of an error, it returns DW_DLV_ERROR and sets the argument err.

πŸ’€ ERRORS πŸ’€

Function dwarf_get_fde_info_for_cfa_reg3() can fail with:

  • [DW_DLE_ARGUMENT] β€” one of the arguments block_ptr, fde, offset_or_block_len, offset_relevant, register_num, row_pc, or type was NULL. yeah, any single one of them. it's a whole list. check your pointers bestie 😭
  • [DW_DLE_PC_NOT_IN_FDE_RANGE] β€” the program counter value provided in argument pc did not fall in the range covered by argument fde. wrong address, wrong neighborhood, no row for you πŸ™ˆ
⚠️ fr fr β€” pass NULL for any of those seven out-params plus fde, or hand it a pc that lives outside the FDE's range, and you're getting DW_DLV_ERROR with a whole error descriptor. not a drill. πŸ’…

πŸŽ€ SEE ALSO πŸŽ€

all the sisters are linked, go read them too, iykyk 🌸


✨ and that's the page! ✨ shoutout to the Debian packagers who shipped this β€” the footer's dated June 12, and the year got straight-up cut off mid-digit (20… and then nothing 😭), so if you're a time traveler asking "which June 12," bestie i genuinely cannot help you. either way: happy CFA rule hunting, go get that row πŸ§šπŸ’œ

πŸ“¦ where this page comes from