DWARF_GET_FDE_INFO_FOR_ALL_REGS3(3)
π DWARF_GET_FDE_INFO_FOR_ALL_REGS3(3) π
okay so this is a page from the Library Functions Manual (Unix manual, section 3, bestie β the "library functions" section, iykyk), and it's all about one iconic little function in the DWARF Access Library β that's libdwarf, linked with -ldwarf. π§
β¨ NAME β¨
dwarf_get_fde_info_for_all_regs3 β retrieve register rule row. that's it, that's the whole vibe: you get a row out of the register rule table. π
π LIBRARY π
DWARF Access Library (libdwarf, -ldwarf)
π¦ SYNOPSIS π¦
#include <libdwarf.h>
int
dwarf_get_fde_info_for_all_regs3(Dwarf_Fde fde, Dwarf_Addr pc,
Dwarf_Regtable3 *reg_table, Dwarf_Addr *row_pc, Dwarf_Error *err);
πΈ DESCRIPTION πΈ
so dwarf_get_fde_info_for_all_regs3() does one thing and does it slay: it retrieves a row from the register rule table that's associated with the given FDE descriptor. one row. of rules. of registers. periodt. π
here's the cast of characters, one by one:
fdeβ should reference a valid DWARF FDE descriptor. like, a valid one. it's giving "read the docs first" energy.pcβ should hold the program counter address. this is the address used to locate the desired table row. it's the little GPS for your row. πreg_tableβ should point to aDwarf_Regtable3descriptor, and that's the thing that will hold the returned table row of register rules. so you bring the container, the function fills it. π«Ά
and the Dwarf_Regtable3 descriptor is defined in the header file <libdwarf.h> β like this, exactly this, no cap:
typedef struct {
Dwarf_Small dw_offset_relevant;
Dwarf_Small dw_value_type;
Dwarf_Half dw_regnum;
Dwarf_Unsigned dw_offset_or_block_len;
Dwarf_Ptr dw_block_ptr;
} Dwarf_Regtable_Entry3;
typedef struct {
Dwarf_Regtable_Entry3 rt3_cfa_rule;
Dwarf_Half rt3_reg_table_size;
Dwarf_Regtable_Entry3 *rt3_rules;
} Dwarf_Regtable3;
now the important part, bestie, don't skip this: the rt3_reg_table_size field specifies the maximum number of register rule columns to be returned, and you β the application β have to set it before calling the function. π₯ and the rt3_rules field should point to a memory arena allocated by the application, with space for at least rt3_reg_table_size descriptors of type Dwarf_Regtable_Entry3. so allocate accordingly, okay? no vibes-based allocation. π
on a successful execution of this function, the rt3_cfa_rule field will be set to the CFA register rule associated with the table row, and the rt3_rules array will hold the returned register rules contained in the table row. literally the whole row, handed to you. π
and for each register rule descriptor that gets returned, here's what's set, field by field:
- the
dw_offset_relevantfield will be set to1if the register rule has a offset value β yes, the original says "a offset value", we don't gatekeep grammar here, we gatekeep facts. π - the
dw_value_typefield will be set to the type code of the register rule. - the
dw_regnumfield will be set to the register number associated with the register rule.
then it depends on the type, so pay attention:
- if the register rule is of type
DW_EXPR_OFFSETorDW_EXPR_VAL_OFFSET, thedw_offset_or_block_lenfield will be set to the offset value associated with the register rule. β¨ - if the type is
DW_EXPR_EXPRESSIONorDW_EXPR_VAL_EXPRESSION, thedw_offset_or_block_lenfield will be set to the length in bytes of the DWARF expression block associated with the register rule. π
and in both cases, the dw_block_ptr field will be set to a pointer to the content of the DWARF expression block associated with the register rule. π
argument row_pc should point to a location which will be set to the lowest program counter address associated with the table row. the lowest, bestie. π
and if argument err is not NULL, it'll be used to store error information in case of an error. if it is NULLβ¦ well, it won't. π
β RETURN VALUES β
dwarf_get_fde_info_for_all_regs3() returns DW_DLV_OK when it succeeds β slay. π in case of an error, it returns DW_DLV_ERROR and sets the argument err. so check your err, bestie, that's the whole point of it being there.
π ERRORS π
this function can fail with:
[DW_DLE_ARGUMENT]β one of the argumentsfde,reg_tableorrow_pcwasNULL. yeah. one of those three. check them all, not just the cute ones. π[DW_DLE_PC_NOT_IN_FDE_RANGE]β the program counter value provided in argumentpcdid not fall in the range covered by argumentfde. your address missed the whole FDE, it's not even in the building. π
π SEE ALSO π
dwarf(3)dwarf_get_fde_at_pc(3)dwarf_get_fde_info_for_all_regs(3)dwarf_get_fde_info_for_cfa_reg3(3)dwarf_get_fde_info_for_reg(3)dwarf_get_fde_info_for_reg3(3)dwarf_get_fde_n(3)dwarf_set_frame_cfa_value(3)dwarf_set_frame_rule_initial_value(3)dwarf_set_frame_rule_table_size(3)dwarf_set_frame_same_value(3)dwarf_set_frame_undefined_value(3)
okay that's the whole page, you ate it, I'm obsessed. π«Ά this one came from Debian, dated June 26, 20 (yes it literally cuts off there in the footer, the page's own header line at the top was DWARF_GET_FDE_INFO_FOR_ALL_REGS3(3) β same page name, same energy, we stan a consistent title). bye bestie, go fill your rt3_rules array ππ¦β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: libdwarf 15.0.0
- Copyright (c) 2011 Kai Wang
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms