DWARF_ADD_FILE_DECL(3)

๐Ÿ“ฆ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

๐Ÿ’– 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 arguments dbg or name was NULL. yeah, one of them was just... not there ๐Ÿซ 
  • [DW_DLE_ARGUMENT] โ€” The length of the NUL-teminated string pointed to by argument name was 0. 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