DWARF_GET_ABBREV_ENTRY(3)

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

πŸ’– NAME πŸ’–

dwarf_get_abbrev_entry β€” retrieve attribute information from an abbreviation descriptor, but make it cute πŸ’…βœ¨

omg hi bestie!! This is the page for DWARF_GET_ABBREV_ENTRY(3), and it lives in the DWARF Access Library (libdwarf, -ldwarf) 🫢. Yes, that whole library name is a mouthful, but we move.

🫢 LIBRARY 🫢

DWARF Access Library (libdwarf, -ldwarf) πŸ’–

✨ SYNOPSIS ✨

#include <libdwarf.h>

int
dwarf_get_abbrev_entry(Dwarf_Abbrev abbrev, Dwarf_Signed ndx,
    Dwarf_Half *code, Dwarf_Signed *form, Dwarf_Off *offset,
    Dwarf_Error *err);

🌸 DESCRIPTION 🌸

Okay so dwarf_get_abbrev_entry() is the function that retrieves attribute information from a DWARF abbreviation descriptor πŸ’…. She's giving very focused, very useful energy.

  • abbrev β€” should be a valid abbreviation descriptor, as returned by function dwarf_get_abbrev(3) πŸŽ€.
  • ndx β€” the 0-based index of the attribute. Need the total count of the attributes contained in the abbreviation entry? That can be retrieved using function dwarf_get_abbrev(3) β€” yes, same function, she's multitasking ✨.
  • code β€” should point to a location which will hold a returned attribute code πŸ’–.
  • form β€” should point to a location which will hold the returned form of the attribute πŸ¦‹.
  • offset β€” should point to a location which will hold a returned offset, relative to the β€œ.debug_abbrev” section, for the specified attribute 🌸.
  • err β€” if err is not NULL, it will be used to return an error descriptor in case of an error πŸ™ˆ.

πŸŽ€ RETURN VALUES πŸŽ€

Function dwarf_get_abbrev_entry() returns DW_DLV_OK when it succeeds, bestie πŸ’š.

It returns DW_DLV_NO_ENTRY if the attribute index specified by argument ndx is out of range πŸ‘€.

In case of an error, it returns DW_DLV_ERROR and sets the argument err πŸ’€.

πŸ¦‹ EXAMPLES πŸ¦‹

Wanna loop through all the attribute entries contained in the abbreviation section? Here's the example, kept exact because code deserves its main character moment πŸ‘‘:

             Dwarf_Debug dbg;
             Dwarf_Abbrev ab;
             Dwarf_Off aboff, atoff;
             Dwarf_Signed form;
             Dwarf_Half attr;
             Dwarf_Unsigned length, attr_count;
             Dwarf_Error de;
             int i, ret;

             /* ...allocate 'dbg' using dwarf_init(3) ... */

             while ((ret = dwarf_next_cu_header(dbg, NULL, NULL, &aboff,
                 NULL, NULL, &de)) ==  DW_DLV_OK) {
                     while ((ret = dwarf_get_abbrev(dbg, aboff, &ab, &length,
                         &attr_count, &de)) == DW_DLV_OK) {
                             if (length == 1)        /* Last entry. */
                                     break;
                             aboff += length;
                             for (i = 0; (Dwarf_Unsigned) i < attr_count; i++) {
                                     if (dwarf_get_abbrev_entry(ab, i,
                                         &attr, &form, &atoff, &de) != DW_DLV_OK) {
                                             warnx("dwarf_get_abbrev_entry failed:"
                                                 " %s", dwarf_errmsg(de));
                                             continue;
                                     }
                                     /* .. use the retrieved information ... */
                             }
                     }

                     if (ret != DW_DLV_OK)
                             warnx("dwarf_get_abbrev: %s", dwarf_errmsg(de));
             }

             if (ret == DW_DLV_ERROR)
                     warnx("dwarf_next_cu_header: %s", dwarf_errmsg(de));

πŸ’… ERRORS πŸ’…

Function dwarf_get_abbrev_entry() can fail with:

  • [DW_DLE_ARGUMENT] β€” One of the arguments abbrev, code, form or offset was NULL 😭.
  • [DW_DLE_NO_ENTRY] β€” The attribute index specified by argument ndx was out of range πŸ™ˆ.

🌈 SEE ALSO 🌈

dwarf(3), dwarf_get_abbrev(3) πŸ¦‹πŸ’–


That's the whole page, bestie 🫢 β€” signing off from DWARF_GET_ABBREV_ENTRY(3) with Debian energy, dated April 02, 2011 βœ¨πŸŽ€πŸ’œ

πŸ“¦ where this page comes from