---
name: "dwarf_attrval_flag"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/dwarf_attrval_flag"
---

# dwarf\_attrval\_flag(3)

retrieve the value of an attribute within a DWARF debugging information entry

## NAME

**dwarf\_attrval\_flag**, **dwarf\_attrval\_signed**, **dwarf\_attrval\_string**, **dwarf\_attrval\_unsigned** – retrieve the value of an attribute within a DWARF debugging information entry

## LIBRARY

library “libdwarf”

## SYNOPSIS

**#include \<libdwarf.h\>**

*int*\

**dwarf\_attrval\_flag**(*Dwarf\_Die die*, *Dwarf\_Half attr*, *Dwarf\_Bool \*ret*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_attrval\_signed**(*Dwarf\_Die die*, *Dwarf\_Half attr*, *Dwarf\_Signed \*ret*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_attrval\_string**(*Dwarf\_Die die*, *Dwarf\_Half attr*, *const char \*\*ret*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_attrval\_unsigned**(*Dwarf\_Die die*, *Dwarf\_Half attr*, *Dwarf\_Unsigned \*ret*, *Dwarf\_Error \*err*);

## DESCRIPTION

These functions search the debugging information entry referenced by argument *die* for the attribute named by argument *attr*. If the named attribute is found, the functions set the location pointed to by argument *ret* to the value of the attribute. The argument *err*, if non NULL, will be used to return an error descriptor in case of an error.

Function **dwarf\_attrval\_flag**() sets the location pointed to by argument *ret* to either 0 or 1. If the form of the attribute named by argument *attr* is DW\_FORM\_flag, function **dwarf\_attrval\_flag**() sets the location pointed to by argument *ret* to 1 if the attribute has a non-zero value, or to 0 otherwise. If the form of the attribute named by argument *attr* is DW\_FORM\_flag\_present, function **dwarf\_attrval\_flag**() unconditionally sets the location pointed to by argument *ret* to 1. The form of the attribute must be one of DW\_FORM\_flag or DW\_FORM\_flag\_present.

Function **dwarf\_attrval\_signed**() stores the value for the attribute named by argument *attr*, into the location pointed to by argument *ret*. The attribute's value is treated as a signed integral quantity and is sign-extended as needed. The attribute named by the argument *attr* must belong to the CONSTANT class and must have one of the following forms: DW\_FORM\_data1, DW\_FORM\_data2, DW\_FORM\_data4, DW\_FORM\_data8 or DW\_FORM\_sdata.

Function **dwarf\_attrval\_string**() sets the location pointed to by argument *ret* to a pointer to a NUL-terminated string that is the value of the attribute named by argument *attr*. The form of the attribute must be one of DW\_FORM\_string or DW\_FORM\_strp.

Function **dwarf\_attrval\_unsigned**() stores the value for the attribute named by argument *attr* into the location pointed to by argument *ret*. The attribute's value is treated as an unsigned integral quantity, and is zero-extended as needed. The named attribute must belong to one of the CONSTANT, ADDRESS or REFERENCE classes and must have one of the following forms: DW\_FORM\_addr, DW\_FORM\_data1, DW\_FORM\_data2, DW\_FORM\_data4, DW\_FORM\_data8, DW\_FORM\_udata, DW\_FORM\_ref1, DW\_FORM\_ref2, DW\_FORM\_ref4, DW\_FORM\_ref8, or DW\_FORM\_ref\_udata.

If the attribute named by argument *attr* is DW\_AT\_type and is not present in the debugging information entry referenced by argument *die*, and if a DW\_AT\_abstract\_origin or DW\_AT\_specification attribute is present in the debugging information entry, function **dwarf\_attrval\_unsigned**() will search for the named attribute in the debugging information entry referenced by the DW\_AT\_abstract\_origin or DW\_AT\_specification attribute.

## RETURN VALUES

On success, these functions returns DW\_DLV\_OK. If the named attribute was not found in the specified debugging information entry descriptor these functions return DW\_DLV\_NO\_ENTRY and set argument *err*. For other errors, these functions return DW\_DLV\_ERROR and set argument *err*.

## COMPATIBILITY

These functions are extensions added by this implementation of the DWARF(3) API.

## ERRORS

These functions may fail with the following errors:

- \[DW\_DLE\_ARGUMENT\]

  Either of the arguments *die* or *ret* was NULL.

- \[DW\_DLE\_NO\_ENTRY\]

  Argument *die* did not contain an attribute corresponding to the value in argument *attr*.

- \[DW\_DLE\_ATTR\_FORM\_BAD\]

  The attribute named by argument *attr* was not of a permitted form.

## SEE ALSO

[dwarf(3)](/dwarf/3.md), [dwarf\_attr(3)](/dwarf_attr/3.md), [dwarf\_hasattr(3)](/dwarf_hasattr/3.md)
