---
name: "dwarf_get_abbrev"
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_get_abbrev"
---

# dwarf\_get\_abbrev(3)

retrieve abbreviation information

## NAME

**dwarf\_get\_abbrev** – retrieve abbreviation information

## LIBRARY

library “libdwarf”

## SYNOPSIS

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

*int*\

**dwarf\_get\_abbrev**(*Dwarf\_Debug dbg*, *Dwarf\_Unsigned offset*, *Dwarf\_Abbrev \*ret\_abbrev*, *Dwarf\_Unsigned \*length*, *Dwarf\_Unsigned \*attr\_count*, *Dwarf\_Error \*err*);

## DESCRIPTION

Function **dwarf\_get\_abbrev**() retrieves information about an abbreviation from the DWARF abbreviations section, “.debug\_abbrev”. Abbreviation information is returned using an opaque descriptor of type *Dwarf\_Abbrev*. The returned *Dwarf\_Abbrev* descriptor may then be passed to the other abbreviation related APIs in the DWARF(3) API to retrieve specific information about the abbreviation.

Argument *dbg* should reference a DWARF debug context allocated using [dwarf\_init(3)](/dwarf_init/3.md).

Argument *offset* should be an offset, relative to the “.debug\_abbrev” section, to the start of an abbreviation entry.

Argument *ret\_abbrev* should point to a location that will hold a pointer to the returned *Dwarf\_Abbrev* descriptor.

Argument *length* should point to a location that will hold the number of bytes used by the abbrevation in the DWARF “.debug\_abbrev” section.

Argument *attr\_count* should point to a location that will hold the number of attributes in the abbrevation.

If argument *err* is not NULL, it will be used to store error information in case of an error.

### Memory Management

The memory area used for the *Dwarf\_Abbrev* descriptor returned in argument *ret\_abbrev* is allocated by the library “libdwarf”. Application code should use function **dwarf\_dealloc**() with the allocation type DW\_DLA\_ABBREV to free the memory area when the *Dwarf\_Abbrev* descriptor is no longer needed.

### Application Programming Notes

The last abbreviation entry in a standard DWARF abbreviation section will have a special length value of 1.

## RETURN VALUES

Function **dwarf\_get\_abbrev**() returns DW\_DLV\_OK when it succeeds. It returns DW\_DLV\_NO\_ENTRY if there is no abbreviation information at offset *offset*. In case of an error, it returns DW\_DLV\_ERROR and sets the argument *err*.

## EXAMPLES

To loop through all the abbreviation information associated with a DWARF debug context, use:

```
Dwarf_Debug dbg;
Dwarf_Abbrev ab;
Dwarf_Off aboff;
Dwarf_Unsigned length, attr_count;
Dwarf_Half tag;
Dwarf_Error de;
int ret;
while ((ret = dwarf_next_cu_header(dbg, NULL, NULL, &aboff,
    NULL, NULL, &de)) ==  DW_DLV_OK) {
	while ((ret = dwarf_get_abbrev(re->dbg, aboff, &ab, &length,
	    &attr_count, &de)) == DW_DLV_OK) {
		if (length == 1)	/* Last entry. */
			break;
		aboff += length;
		if (dwarf_get_abbrev_tag(ab, &tag, &de) != DW_DLV_OK) {
			warnx("dwarf_get_abbrev_tag failed: %s",
			    dwarf_errmsg(de));
			continue;
		}
	if (ret != DW_DLV_OK)
		warnx("dwarf_get_abbrev: %s", dwarf_errmsg(de));
}
if (ret == DW_DLV_ERROR)
	warnx("dwarf_next_cu_header: %s", dwarf_errmsg(de));
```

## ERRORS

Function **dwarf\_get\_abbrev**() can fail with:

- \[DW\_DLE\_ARGUMENT\]

  One of the arguments *dbg*, *ret\_abbrev*, *length* or *attr\_count* was NULL.

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

  There is no abbreviation information at offset *offset*.

## SEE ALSO

[dwarf(3)](/dwarf/3.md), [dwarf\_dealloc(3)](/dwarf_dealloc/3.md), [dwarf\_get\_abbrev\_children\_flag(3)](/dwarf_get_abbrev_children_flag/3.md), [dwarf\_get\_abbrev\_code(3)](/dwarf_get_abbrev_code/3.md), [dwarf\_get\_abbrev\_entry(3)](/dwarf_get_abbrev_entry/3.md), [dwarf\_get\_abbrev\_tag(3)](/dwarf_get_abbrev_tag/3.md)
