---
name: "dwarf_srcfiles"
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_srcfiles"
---

# dwarf\_srcfiles(3)

retrieve source file information

## NAME

**dwarf\_srcfiles** – retrieve source file information

## LIBRARY

library “libdwarf”

## SYNOPSIS

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

*int*\

**dwarf\_srcfiles**(*Dwarf\_Die die*, *char \*\*\*filenames*, *Dwarf\_Signed \*filenamecount*, *Dwarf\_Error \*err*);

## DESCRIPTION

Function **dwarf\_srcfiles**() returns the source file names associated with a compilation unit. Source file names are returned as an array of NUL-terminated strings.

Argument *die* should reference a DWARF debugging information entry descriptor with source file information, see [dwarf(3)](/dwarf/3.md). Argument *filenames* should point to a location that will hold a pointer to the returned array of file names. Argument *filenamecount* should point to a location that will hold the number of file names returned. If argument *err* is not NULL, it will be used to store error information in case of an error.

### Memory Management

The memory areas used for the file names and for array of pointers being returned are managed by the DWARF(3) library. The application should not attempt to directly free these memory areas. Portable code should indicate that the memory areas are to be freed by using [dwarf\_dealloc(3)](/dwarf_dealloc/3.md).

## RETURN VALUES

Function **dwarf\_srcfiles**() returns DW\_DLV\_OK when it succeeds. In case of an error, it returns DW\_DLV\_ERROR and sets the argument *err*.

## ERRORS

Function **dwarf\_srcfiles**() can fail with:

- \[DW\_DLE\_ARGUMENT\]

  One of the arguments *die*, *filenames* or *filenamecount* was NULL.

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

  The compilation unit referenced by argument *die* does not have associated source file information.

- \[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\_srclines(3)](/dwarf_srclines/3.md)
