---
name: "dwarf_loclist_from_expr"
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_loclist_from_expr"
---

# dwarf\_loclist\_from\_expr(3)

translate DWARF location expression bytes

## NAME

**dwarf\_loclist\_from\_expr**, **dwarf\_loclist\_from\_expr\_a**, **dwarf\_loclist\_from\_expr\_b** – translate DWARF location expression bytes

## LIBRARY

library “libdwarf”

## SYNOPSIS

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

*int*\

**dwarf\_loclist\_from\_expr**(*Dwarf\_Debug dbg*, *Dwarf\_Ptr bytes\_in*, *Dwarf\_Unsigned bytes\_len*, *Dwarf\_Locdesc \*\*llbuf*, *Dwarf\_Signed \*listlen*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_loclist\_from\_expr\_a**(*Dwarf\_Debug dbg*, *Dwarf\_Ptr bytes\_in*, *Dwarf\_Unsigned bytes\_len*, *Dwarf\_Half addr\_size*, *Dwarf\_Locdesc \*\*llbuf*, *Dwarf\_Signed \*listlen*, *Dwarf\_Error \*err*);

*int*\

**dwarf\_loclist\_from\_expr\_b**(*Dwarf\_Debug dbg*, *Dwarf\_Ptr bytes\_in*, *Dwarf\_Unsigned bytes\_len*, *Dwarf\_Half addr\_size*, *Dwarf\_Half offset\_size*, *Dwarf\_Small version*, *Dwarf\_Locdesc \*\*llbuf*, *Dwarf\_Signed \*listlen*, *Dwarf\_Error \*error*);

## DESCRIPTION

Function **dwarf\_loclist\_from\_expr**() translates DWARF location expression bytes into a *Dwarf\_Locdesc* descriptor. The size for address related data is taken to be the default address size for the object being read.

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

Argument *bytes\_in* should point to an array of DWARF location expression bytes.

Argument *bytes\_len* should specify the number of the location expression bytes to be translated.

Argument *llbuf* should point to a location which will be set to a pointer to a returned *Dwarf\_Locdesc* descriptor.

Argument *listlen* should point to a location which will hold the number of the *Dwarf\_Locdesc* descriptors returned. In this case it is always set to 1.

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

Function **dwarf\_loclist\_from\_expr\_a**() is identical to function **dwarf\_loclist\_from\_expr**(), except that it requires one additional argument *addr\_size*, which specifies the address size to use when translating the location expression bytes.

Function **dwarf\_loclist\_from\_expr\_b**() is identical to function **dwarf\_loclist\_from\_expr\_a**() except that it requires two additional arguments for translating the location expression bytes. Argument *offset\_size* specifies the offset size, and argument *version* specifies the DWARF version. These values are required to correctly translate the DW\_OP\_GNU\_implicit\_pointer opcode.

### Memory Management

The memory area used for the descriptor returned in argument *llbuf* is allocated by library “libdwarf”. When the descriptor is no longer needed, application code should use function [dwarf\_dealloc(3)](/dwarf_dealloc/3.md) to free the memory area in two steps:

1. First, the array of *Dwarf\_Loc* descriptors pointed to by the *ld\_s* field of the *Dwarf\_Locdesc* descriptor should be deallocated using the allocation type DW\_DLA\_LOC\_BLOCK.

2. Next, the application should free the *llbuf* pointer using the allocation type DW\_DLA\_LOCDESC.

## 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 *dbg*, *bytes\_in*, *llbuf* or *listlen* was NULL.

- \[DW\_DLE\_ARGUMENT\]

  Argument *bytes\_len* was 0.

- \[DW\_DLE\_ARGUMENT\]

  The value of argument *addr\_size* was invalid.

- \[DW\_DLE\_LOC\_EXPR\_BAD\]

  An unknown or invalid operation was found in the location expression bytes provided in argument *bytes\_in*.

- \[DW\_DLE\_MEMORY\]

  An out of memory condition was encountered during the execution of this function.

## SEE ALSO

[dwarf(3)](/dwarf/3.md), [dwarf\_dealloc(3)](/dwarf_dealloc/3.md), [dwarf\_get\_fde\_info\_for\_all\_regs3(3)](/dwarf_get_fde_info_for_all_regs3/3.md), [dwarf\_get\_fde\_info\_for\_cfa\_reg3(3)](/dwarf_get_fde_info_for_cfa_reg3/3.md), [dwarf\_get\_fde\_info\_for\_reg3(3)](/dwarf_get_fde_info_for_reg3/3.md), [dwarf\_get\_loclist\_entry(3)](/dwarf_get_loclist_entry/3.md), [dwarf\_loclist\_n(3)](/dwarf_loclist_n/3.md)
