DWARF_GET_LOCLIST_ENTRY(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’– DWARF_GET_LOCLIST_ENTRY(3) πŸ’–

okay bestie, welcome to the Library Functions Manual side of the group chat πŸ’… this page is all about grabbing a DWARF location list entry, and yes it’s giving very niche but very iconic energy. πŸ¦‹

🌸 NAME 🌸

dwarf_get_loclist_entry β€” retrieve DWARF location list entry. That’s the whole assignment, no cap. πŸŽ€

πŸŽ€ LIBRARY πŸŽ€

DWARF Access Library (libdwarf, -ldwarf) ✨ link it, love it, keep it close.

✨ SYNOPSIS ✨

#include <libdwarf.h>

int
dwarf_get_loclist_entry(Dwarf_Debug dbg, Dwarf_Unsigned offset,
    Dwarf_Addr *hipc, Dwarf_Addr *lopc, Dwarf_Ptr *data,
    Dwarf_Unsigned *entry_len, Dwarf_Unsigned *next_entry,
    Dwarf_Error *err);

🫢 DESCRIPTION 🫢

Function dwarf_get_loclist_entry() retrieves a location list entry from the DWARF section .debug_loc. Main character behavior tbh. πŸ’œ

  • dbg β€” should reference a DWARF debug context allocated using dwarf_init(3).
  • offset β€” an offset, relative to the .debug_loc section, to the start of the desired location list entry.
  • hipc β€” should point to a location which will hold the offset, relative to the base address of the location list entry, of the highest program counter value for the entry.
  • lopc β€” heads up, the original DESCRIPTION literally says lowpc here πŸ™ˆ it should point to a location which will hold the offset, relative to the base address of the location list entry, of the lowest program counter value for the entry.
  • data β€” should point to a location which will be set to a pointer to the location list data.
  • entry_len β€” should point to a location which will hold the length in bytes of the location list data returned in argument data.
  • next_entry β€” should point to a location which will hold the offset of the next location list entry.
  • err β€” if it is not NULL, it will be used to store error information in case of an error.

πŸ”₯ RETURN VALUES πŸ”₯

Function dwarf_get_loclist_entry() returns DW_DLV_OK when it succeeds. It returns DW_DLV_NO_ENTRY if there is no location list at the specified offset offset. In case of an error, it returns DW_DLV_ERROR and sets the argument err. slay, but also mind the error path bestie 🌈

🌈 EXAMPLES 🌈

To iterate through all the location list entries in the .debug_loc section, use:

Dwarf_Debug dbg;
Dwarf_Unsigned off, len, next;
Dwarf_Addr hipc, lopc;
Dwarf_Ptr data;
Dwarf_Error de;
int ret;

off = 0;
while ((ret = dwarf_get_loclist_entry(dbg, off, &hipc, &lopc, &data,
    &len, &next, &de)) == DW_DLV_OK) {
        /* ... use loclist entry ... */
        off = next;
}
if (ret == DW_DLV_ERROR)
        warnx("dwarf_get_loclist_entry failed: %s", dwarf_errmsg(de));

πŸ’€ ERRORS πŸ’€

Function dwarf_get_loclist_entry() can fail with:

  • [DW_DLE_ARGUMENT] β€” one of the arguments dbg, hipc, lopc, data, entry_len or next_entry was NULL.
  • [DW_DLE_NO_ENTRY] β€” there is no location list at the specified offset offset.

🧚 SEE ALSO 🧚

dwarf(3), dwarf_loclist(3), dwarf_loclist_from_expr(3), dwarf_loclist_from_expr_a(3), dwarf_loclist_n(3).


and that’s the whole DWARF_GET_LOCLIST_ENTRY(3) page, bestie β€” from the Debian source, dated July 6, 2011 πŸ’œπŸ«ΆπŸ“

πŸ“¦ where this page comes from