DWARF_NEW_EXPR(3)
DWARF_NEW_EXPR(3) π
okay so welcome to the Library Functions Manual page for DWARF_NEW_EXPR(3) β yes, this is your DWARF girlie era, and we're gonna make a location expression descriptor together, no cap. β¨
πΈ NAME πΈ
dwarf_new_expr β create a location expression descriptor. That's the whole assignment, bestie. π
π¦ LIBRARY π¦
DWARF Access Library (libdwarf, -ldwarf). Iconic. π
β¨ SYNOPSIS β¨
#include <libdwarf.h>
Dwarf_P_Expr
dwarf_new_expr(Dwarf_P_Debug dbg, Dwarf_Error *err);
π§ DESCRIPTION π§
Function dwarf_new_expr() allocates a DWARF location expression descriptor used to build up a location expression stream. Literally the starting point for your expression stream era. π«Ά
Your app can use dwarf_add_expr_gen(3) and dwarf_add_expr_addr_b(3) to add location expression operators to the created descriptor. When you're done, call dwarf_expr_into_block(3) to retrieve the generated byte stream for the location expression, or call dwarf_add_AT_location_expr(3) to create an attribute with the location expression stream as its value. Slay. π
Argument dbg should reference a DWARF producer instance allocated using dwarf_producer_init(3) or dwarf_producer_init_b(3). Keep that in mind, bestie.
If argument err is not NULL, it will be used to store error information in case of an error. So pass it if you want the tea. β
π RETURN VALUES π
On success, function dwarf_new_expr() returns the created location expression descriptor. In case of an error, function dwarf_new_expr() returns DW_DLV_BADADDR and sets the argument err. No cap. π
π EXAMPLES π
To create a location expression descriptor, add location expression operators to it and to retrieve the generated byte stream, use:
Dwarf_P_Debug dbg;
Dwarf_Error de;
Dwarf_P_Expr pe;
Dwarf_Addr buf;
Dwarf_Unsigned len;
/* ...Assume that `dbg' refers to a DWARF producer instance... */
if ((pe = dwarf_new_expr(dbg, &de)) == DW_DLV_BADADDR) {
warnx("dwarf_new_expr failed: %s", dwarf_errmsg(-1));
return;
}
if (dwarf_add_expr_gen(pe, DW_OP_regx, 55, 0, &de) ==
DW_DLV_NOCOUNT) {
warnx("dwarf_add_expr_gen failed: %s", dwarf_errmsg(-1));
return;
}
if ((buf = dwarf_expr_into_block(pe, &len, &de)) ==
DW_DLV_BADADDR) {
warnx("dwarf_expr_into_block failed: %s",
dwarf_errmsg(-1));
return;
}
π¨ ERRORS π¨
Function dwarf_new_expr() can fail with:
[DW_DLE_ARGUMENT]β ArgumentdbgwasNULL.[DW_DLE_MEMORY]β An out of memory condition was encountered during the execution of the function.
The[DW_DLE_ARGUMENT]one is giving "you forgot thedbg, bestie" energy; the[DW_DLE_MEMORY]one is the classic out-of-memory jump scare. π
π SEE ALSO π
dwarf(3), dwarf_add_AT_location_expr(3), dwarf_add_expr_addr(3), dwarf_add_expr_addr_b(3), dwarf_add_expr_gen(3), dwarf_expr_current_offset(3), dwarf_expr_into_block(3), dwarf_producer_init(3), dwarf_producer_init_b(3).
Go read those too, bestie β the whole friend group is linked. π«Ά
Debian, September 8, 2011 β DWARF_NEW_EXPR(3), signing off. Stay iconic, and may your location expressions always be stream-ready. πβ¨
π¦ 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