---
name: "dwarf_type_die_offset"
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_types"
---

# dwarf\_type\_die\_offset(3)

retrieve information about user-defined types

Part of [dwarf\_get\_types(3)](/dwarf_get_types/3.md).

## NAME

**dwarf\_get\_types**, **dwarf\_type\_cu\_offset**, **dwarf\_type\_die\_offset**, **dwarf\_type\_name\_offsets**, **dwarf\_typename** – retrieve information about user-defined types

## LIBRARY

library “libdwarf”

## SYNOPSIS

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

*int*\

**dwarf\_get\_types**(*Dwarf\_Debug dbg*, *Dwarf\_Type \*\*types*, *Dwarf\_Signed \*ntypes*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_type\_cu\_offset**(*Dwarf\_Type type*, *Dwarf\_Off \*cu\_offset*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_type\_die\_offset**(*Dwarf\_Type type*, *Dwarf\_Off \*die\_offset*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_type\_name\_offsets**(*Dwarf\_Type type*, *char \*\*name*, *Dwarf\_Off \*die\_offset*, *Dwarf\_Off \*cu\_die\_offset*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_typename**(*Dwarf\_Type type*, *char \*\*name*, *Dwarf\_Error \*err*);

## DESCRIPTION

These APIs retrieve information about user-defined types from the SGI-specific “.debug\_typenames” section.

Standards-conformant applications should use the functions [dwarf\_get\_pubtypes(3)](/dwarf_get_pubtypes/3.md), [dwarf\_pubtype\_cu\_offset(3)](/dwarf_pubtype_cu_offset/3.md), [dwarf\_pubtype\_die\_offset(3)](/dwarf_pubtype_die_offset/3.md), [dwarf\_pubtype\_name\_offsets(3)](/dwarf_pubtype_name_offsets/3.md) and [dwarf\_pubtypename(3)](/dwarf_pubtypename/3.md), which operate on the equivalent “.debug\_pubtypes” section defined by the DWARF3 standard.

Information about user-defined types is returned using opaque descriptors of type *Dwarf\_Type*. Applications need to use the functions described below to retrieve the name and offset information contained in these descriptors.

Function **dwarf\_get\_types**() retrieves descriptors for all user-defined types associated with the DWARF debug context specified by argument *dbg*. The argument *types* should point to a location that will be set to a pointer to an array of *Dwarf\_Type* descriptors. The argument *ntypes* should point to a location that will be set to the number of descriptors returned.

Function **dwarf\_type\_cu\_offset**() returns the offset, relative to the “.debug\_info” section, of the compilation unit that contains the debugging information entry associated with the argument *type*. Argument *cu\_offset* should point to a location that will hold the returned offset.

Function **dwarf\_type\_die\_offset**() retrieves the offset, relative to the “.debug\_info” section, of the debugging information entry associated with the argument *type*, and stores it into the location pointed to by the argument *die\_offset*.

Function **dwarf\_type\_name\_offsets**() retrieves the name and offsets for the debugging information entry for argument *type*. Argument *name* should point to a location which will be set to a pointer to a NUL-terminated string containing the name of the associated debugging information entry. Argument *die\_offset* should point to a location which will be set to the offset, relative to the “.debug\_info” section, of the associated debugging information entry. Argument *cu\_die\_offset* should point to a location which will be set to a offset, relative to the “.debug\_info” section, of the first debugging information entry in the compilation unit associated with argument *type*.

Function **dwarf\_typename**() sets the location pointed to by argument *name* to a pointer to a NUL-terminated string holding the name of the debugging information entry associated with the argument *type*.

### Memory Management

The memory area used for the array of *Dwarf\_Type* descriptors returned in argument *types* by function **dwarf\_get\_types**() is owned by the library “libdwarf”. Application code should not attempt to directly free this pointer. Portable code should instead use the function [dwarf\_types\_dealloc(3)](/dwarf_types_dealloc/3.md) to indicate that the memory area may be freed.

The memory area used for the string returned in the *name* argument to functions **dwarf\_type\_name\_offsets**() and **dwarf\_typename**() is owned by the library “libdwarf”. Portable code should indicate that the memory area can be freed using the [dwarf\_dealloc(3)](/dwarf_dealloc/3.md) function.

### Error Returns

If argument *err* is not NULL, these functions will use it to store error information, in case of an error.

## RETURN VALUES

On success, these functions returns DW\_DLV\_OK. In case of an error, they return DW\_DLV\_ERROR and set the argument *err*.

## ERRORS

These functions may fail with the following errors:

- \[DW\_DLE\_ARGUMENT\]

  One of the arguments *cu\_die\_offset*, *cu\_offset*, *dbg*, *die\_offset*, *type*, *types*, *name*, or *ntypes* was NULL.

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

  The DWARF debugging context referenced by argument *dbg* did not contain information about user-defined types.

## SEE ALSO

[dwarf(3)](/dwarf/3.md), [dwarf\_get\_cu\_die\_offset\_given\_cu\_header\_offset(3)](/dwarf_get_cu_die_offset_given_cu_header_offset/3.md), [dwarf\_get\_pubtypes(3)](/dwarf_get_pubtypes/3.md), [dwarf\_pubtype\_cu\_offset(3)](/dwarf_pubtype_cu_offset/3.md), [dwarf\_pubtype\_die\_offset(3)](/dwarf_pubtype_die_offset/3.md), [dwarf\_pubtype\_name\_offsets(3)](/dwarf_pubtype_name_offsets/3.md), [dwarf\_pubtypename(3)](/dwarf_pubtypename/3.md), [dwarf\_types\_dealloc(3)](/dwarf_types_dealloc/3.md)
