---
name: "dwarf_die_CU_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_die_CU_offset"
---

# dwarf\_die\_CU\_offset(3)

return offsets of DWARF debugging information entries

## NAME

**dwarf\_die\_CU\_offset**, **dwarf\_die\_CU\_offset\_range**, **dwarf\_dieoffset**, **dwarf\_get\_cu\_die\_offset\_given\_cu\_header\_offset**, **dwarf\_get\_cu\_die\_offset\_given\_cu\_header\_offset\_b** – return offsets of DWARF debugging information entries

## LIBRARY

library “libdwarf”

## SYNOPSIS

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

*int*\

**dwarf\_die\_CU\_offset**(*Dwarf\_Die die*, *Dwarf\_Off \*ret\_offset*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_die\_CU\_offset\_range**(*Dwarf\_Die die*, *Dwarf\_Off \*cu\_offset*, *Dwarf\_Off \*cu\_length*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_dieoffset**(*Dwarf\_Die die*, *Dwarf\_Off \*ret\_offset*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_get\_cu\_die\_offset\_given\_cu\_header\_offset**(*Dwarf\_Debug dbg*, *Dwarf\_Off in\_cu\_header\_offset*, *Dwarf\_Off \*out\_cu\_die\_offset*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_get\_cu\_die\_offset\_given\_cu\_header\_offset\_b**(*Dwarf\_Debug dbg*, *Dwarf\_Off in\_cu\_header\_offset*, *Dwarf\_Bool is\_info*, *Dwarf\_Off \*out\_cu\_die\_offset*, *Dwarf\_Error \*err*);

## DESCRIPTION

These functions are used to retrieve offsets for DWARF debugging information entries.

Function **dwarf\_die\_CU\_offset**() returns the offset of the debugging information entry referenced by argument *die* relative to the start of its containing compilation unit. Argument *ret\_offset* should point to the location that is to hold the returned offset. If argument *err* is non-NULL, it will be used to return an error descriptor in case of an error.

Function **dwarf\_die\_CU\_offset\_range**() returns the section-relative offset and length of the compilation unit containing the debugging information entry referenced by argument *die*. Argument *cu\_offset* should point to a location that will hold the returned offset. Argument *cu\_length* should point to a location that will hold the returned length of the compilation unit. If argument *err* is non-NULL, it will be used to return an error descriptor in case of an error.

Function **dwarf\_dieoffset**() retrieves the section-relative offset of the debugging information entry referenced by argument *die*. Argument *ret\_offset* should point to a location that is to hold the returned section-relative offset. If argument *err* is non-NULL, it will be used to return an error descriptor in case of an error.

Function **dwarf\_get\_cu\_die\_offset\_given\_cu\_header\_offset**() returns the offset for the first debugging information entry for a compilation unit, given an offset to the header of the compilation unit. Argument *dbg* should reference a valid debugging context allocated using [dwarf\_init(3)](/dwarf_init/3.md). Argument *in\_cu\_header\_offset* contains the offset to the start of a compilation unit. Argument *out\_cu\_die\_offset* points to a location that will hold the returned offset. If argument *err* is non-NULL, it will be used to return an error descriptor in case of an error.

Function **dwarf\_get\_cu\_die\_offset\_given\_cu\_header\_offset\_b**() behaves identically to the function **dwarf\_get\_cu\_die\_offset\_given\_cu\_header\_offset**() when the argument *is\_info* is non-zero. When the argument *is\_info* is zero, function **dwarf\_get\_cu\_die\_offset\_given\_cu\_header\_offset\_b**() returns the offset for the first debugging information entry for a type unit, given an offset to the header of the type unit in argument *in\_cu\_header\_offset*. Argument *out\_cu\_die\_offset* points to a location that will hold the returned offset. If the argument *err* is non-NULL, it will be used to return an error descriptor in case of an error.

## RETURN VALUES

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

Function **dwarf\_get\_cu\_die\_offset\_given\_cu\_header\_offset**() and **dwarf\_get\_cu\_die\_offset\_given\_cu\_header\_offset\_b**() returns DW\_DLV\_NO\_ENTRY and sets argument *err* if there is no compilation or type unit located at the offset specified in argument *in\_cu\_header\_offset*.

## ERRORS

These functions may fail with the following errors:

- \[DW\_DLE\_ARGUMENT\]

  One of the arguments *cu\_length*, *cu\_offset*, *dbg*, *die*, *out\_cu\_die\_offset* or *ret\_offset* was NULL.

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

  Argument *in\_cu\_header\_offset* specified an unknown offset.

## SEE ALSO

[dwarf(3)](/dwarf/3.md), [dwarf\_next\_cu\_header(3)](/dwarf_next_cu_header/3.md), [dwarf\_offdie(3)](/dwarf_offdie/3.md), [dwarf\_offdie\_b(3)](/dwarf_offdie_b/3.md)
