DWARF_ADD_FILE_DECL(3)
๐ DWARF_ADD_FILE_DECL ๐
okay so bestie, this is a libdwarf page โ the DWARF Access Library, aka libdwarf, linked with -ldwarf. It's the one that lets you tell a debug-info producer "hey, there's a source file, here's its info" ๐
โจ NAME โจ
dwarf_add_file_decl โ add a source file entry to a producer instance ๐๏ธ
๐ธ LIBRARY ๐ธ
DWARF Access Library (libdwarf, -ldwarf)
๐ฆ SYNOPSIS ๐ฆ
#include <libdwarf.h>
Dwarf_Unsigned
dwarf_add_file_decl(Dwarf_P_Debug dbg, char *name,
Dwarf_Unsigned dirndx, Dwarf_Unsigned mtime, Dwarf_Unsigned size,
Dwarf_Error *err);
๐ DESCRIPTION ๐
So dwarf_add_file_decl() does exactly what it says on the tin โ it adds a source file entry to a producer instance. iconic behavior, no notes ๐ฅ
The dbg argument should reference a DWARF producer instance that you allocated using dwarf_producer_init(3) or dwarf_producer_init_b(3). Like, that's the whole vibe โ you need the producer first, iykyk.
The name argument should point to a NUL-terminated string containing the name of the source file. literally just the filename, bestie ๐
Now here's the part where you gotta pay attention ๐ If the file name in name is not a fully qualified pathname, then dirndx should specify the index of the directory where the source file resides. Otherwise โ if it is fully qualified โ dirndx should be 0. And like, valid directory indices are the ones returned by dwarf_add_directory_decl(3). so don't just make up numbers pls ๐
The mtime argument specifies the time when the file was last modified โฐ
The size argument specifies the size of the file in bytes ๐
And if err is not NULL, it'll be used to store error information in case of an error. (if it is NULL, then no error info for you, bestie โ that's the trade.)
๐ RETURN VALUES ๐
On success, dwarf_add_file_decl() returns the index value generated for the source file. cute, useful, slay โจ
In case of an error, it returns DW_DLV_NOCOUNT and sets the argument err. sad but honest ๐ญ
๐ ERRORS ๐
dwarf_add_file_decl() can fail with:
[DW_DLE_ARGUMENT]โ Either argumentsdbgornamewasNULL. yeah, one of them was just... not there ๐ซ[DW_DLE_ARGUMENT]โ The length of the NUL-teminated string pointed to by argumentnamewas0. empty string energy, and not the fun kind ๐[DW_DLE_MEMORY]โ An out of memory condition was encountered during the execution of the function. the classic ๐ฎโ๐จ
heads up: those first two are both [DW_DLE_ARGUMENT], so don't go thinking they're one error โ they're two separate ways to be wrong ๐
๐ SEE ALSO ๐
dwarf(3), dwarf_add_directory_decl(3), dwarf_add_line_entry(3), dwarf_lne_end_sequence(3), dwarf_lne_set_address(3), dwarf_producer_init(3), dwarf_producer_init_b(3)
okay and that's the whole page, bestie โ go forth and declare your files ๐ง๐
Debian ยท September 17, 2011 ยท DWARF_ADD_FILE_DECL(3) โ mwah, that's the sign-off, dated and sourced and everything ๐๐
๐ฆ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: libdwarf 15.0.0
- Copyright (c) 2011 Kai Wang
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms