DWARF_ADD_AT_UNSIGNED_CONST(3)
π dwarf_add_AT_signed_const, dwarf_add_AT_unsigned_const β create and attach constant class attributes
okay so bestie, you're in libdwarf territory now β the DWARF Access Library (libdwarf, link it with -ldwarf) β and this page is all about two lil twin functions that make constant-class attribute descriptors and stick them onto a DIE. iconic behaviour, honestly. β¨
β¨ SYNOPSIS β¨
#include <libdwarf.h>
Dwarf_P_Attribute
dwarf_add_AT_signed_const(Dwarf_P_Debug dbg, Dwarf_P_Die die,
Dwarf_Half attr, Dwarf_Signed value, Dwarf_Error *err);
Dwarf_P_Attribute
dwarf_add_AT_unsigned_const(Dwarf_P_Debug dbg, Dwarf_P_Die die,
Dwarf_Half attr, Dwarf_Unsigned value, Dwarf_Error *err);
πΈ DESCRIPTION πΈ
so these two functions create attribute descriptors that belong to the βconstantβ class, and then attach them to the debugging information entry that argument die points at. that's the whole vibe. π
here's the cast of characters:
- dbg should reference a DWARF producer instance β you get one of those from
dwarf_producer_init(3)ordwarf_producer_init_b(3). - die should reference a debugging information entry β allocate it with
dwarf_new_die(3). - attr is the attribute code of the attribute descriptor you're creating.
now the twins get their own moment:
dwarf_add_AT_signed_const()creates an attribute descriptor carrying the signed value you passed in value. πdwarf_add_AT_unsigned_const()creates an attribute descriptor carrying the unsigned value you passed in value. π
and here's the fun part β the attribute these functions create will have one of the DWARF forms DW_FORM_data1, DW_FORM_data2, DW_FORM_data4 or DW_FORM_data8, depending on the size of the value you put in value. it picks for you, no cap. π¦
one more thing: if err is not NULL, these functions will use it to store error information in case of an error. so pass it if you want the tea. π
π₯ RETURN VALUES π₯
on success, these functions return the created attribute descriptor. slay.
in case of an error, they return DW_DLV_BADADDR and set the argument err. that's your vibe check failing, bestie. π
π§ ERRORS π§
these functions can fail with:
[DW_DLE_ARGUMENT]β either of the arguments dbg or die wasNULL. (like, rude? but okay.)[DW_DLE_MEMORY]β an out of memory condition was encountered during execution. π«
β SEE ALSO β
dwarf(3), dwarf_add_AT_const_value_signedint(3), dwarf_add_AT_const_value_unsignedint(3), dwarf_add_AT_dataref(3), dwarf_add_AT_ref_address(3), dwarf_add_AT_targ_address_b(3), dwarf_new_die(3), dwarf_producer_init(3), dwarf_producer_init_b(3)
okay that's the whole page, you ate that π go forth and attach your constants. this one's from the Debian manual, dated September 4, 2011, and the page itself is DWARF_ADD_AT_SIGNED_CONST(3) β mwah, mwah, periodt ππ
π¦ 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