DWARF_ADD_EXPR_GEN(3)

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

πŸ¦‹ NAME πŸ¦‹

dwarf_add_expr_gen β€” add an operator to a location expression descriptor

okay bestie, this is DWARF_ADD_EXPR_GEN(3) from the Library Functions Manual, and it is <highkey>literally</highkey> here to help you add one operator to a location expression descriptor. no cap 🫢


πŸ“š LIBRARY πŸ“š

DWARF Access Library (libdwarf, -ldwarf)


✨ SYNOPSIS ✨

#include <libdwarf.h>

Dwarf_Unsigned
dwarf_add_expr_gen(Dwarf_P_Expr expr, Dwarf_Small opcode,
    Dwarf_Unsigned val1, Dwarf_Unsigned val2, Dwarf_Error *err);

πŸ’… DESCRIPTION πŸ’…

Call dwarf_add_expr_gen() when you need to drop a location expression operator into the location expression descriptor that argument expr references. it's giving one little opcode moment, but make it official ✨

Argument expr should reference a location expression descriptor that was allocated using the function dwarf_new_expr(3). don't just vibe in with some random descriptor, okay? πŸ’–

Argument opcode specifies the operation code of the location expression operator. valid values for this argument are those denoted by the DW_OP_* constants defined in <libdwarf.h>. periodt.

🚨 tiny but important plot twist: to generate a DW_OP_addr operation, application code should instead use dwarf_add_expr_addr_b(3). not this function. iykyk.

Argument val1 specifies the first operand of the location expression operator.

Argument val2 specifies the second operand of the location expression operator.

If argument err is not NULL, it will be used to store error information in case of an error. so if you pass it, it is ready to catch the drama 😭


🌈 RETURN VALUES 🌈

On success, function dwarf_add_expr_gen() returns the size in bytes of the location expression byte stream generated. slay. πŸ”₯

In case of an error, function dwarf_add_expr_gen() returns DW_DLV_NOCOUNT and sets the argument err. not the happy ending, but at least you get the error info πŸ’€


πŸ“ ERRORS πŸ“

Function dwarf_add_expr_gen() can fail with:

  • [DW_DLE_ARGUMENT] β€” argument expr was NULL.
  • [DW_DLE_LOC_EXPR_BAD] β€” the operation code specified in argument opcode was invalid.
  • [DW_DLE_MEMORY] β€” an out of memory condition was encountered during the execution of the function.

πŸŽ€ SEE ALSO πŸŽ€

dwarf(3), dwarf_add_AT_location_expr(3), dwarf_add_expr_addr(3), dwarf_add_expr_addr_b(3), dwarf_expr_current_offset(3), dwarf_expr_into_block(3), dwarf_new_expr(3)


xoxo bestie, this page is from Debian, dated September 9, 2011, and it is DWARF_ADD_EXPR_GEN(3) β€” bye and slay your DWARF expressions πŸ’…πŸ’–

πŸ“¦ where this page comes from