]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Update per the review
authorPetr Machata <pmachata@redhat.com>
Tue, 4 Nov 2014 16:30:03 +0000 (17:30 +0100)
committerPetr Machata <pmachata@redhat.com>
Tue, 4 Nov 2014 16:30:03 +0000 (17:30 +0100)
NEWS
libdw/dwarf_getmacros.c
libdw/dwarf_getsrclines.c
libdw/libdw.h

diff --git a/NEWS b/NEWS
index aceb3e33eb5394ef047cee26c807ab816b93ccc9..2334646e84659e4d9fdb0420fe311ebbbf8f99d8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+Version 0.161
+
+libdw: dwarf_getmacros will now serve either of .debug_macro and
+       .debug_macinfo transparently.  New interfaces
+       dwarf_getmacros_off, dwarf_macro_getsrcfiles,
+       dwarf_macro_getparamcnt, and dwarf_macro_param are available
+       for more generalized inspection of macros and their parameters.
+
 Version 0.160
 
 libdw: New functions dwarf_cu_getdwarf, dwarf_cu_die.
index 7f889a91fb506e87d4f94f1e14907e5bfd90a032..8d9d78bef8e85bb5fb1aa287cea8b941d4f43543 100644 (file)
@@ -117,10 +117,7 @@ init_macinfo_table (void)
 }
 
 static Dwarf_Macro_Op_Table *
-get_macinfo_table (Dwarf *dbg, Dwarf_Word macoff,
-                  __attribute__ ((unused)) const unsigned char *readp,
-                  __attribute__ ((unused)) const unsigned char *const endp,
-                  Dwarf_Die *cudie)
+get_macinfo_table (Dwarf *dbg, Dwarf_Word macoff, Dwarf_Die *cudie)
 {
   assert (cudie != NULL);
 
@@ -276,7 +273,7 @@ cache_op_table (Dwarf *dbg, int sec_index, Dwarf_Off macoff,
 
   Dwarf_Macro_Op_Table *table = sec_index == IDX_debug_macro
     ? get_table_for_offset (dbg, macoff, startp, endp, cudie)
-    : get_macinfo_table (dbg, macoff, startp, endp, cudie);
+    : get_macinfo_table (dbg, macoff, cudie);
 
   if (table == NULL)
     return NULL;
@@ -436,13 +433,8 @@ dwarf_getmacros_off (Dwarf *dbg, Dwarf_Off macoff,
      -1 also signifies an error, but that's fine, because .debug_macro
      always contains at least three bytes of headers and after
      iterating one opcode, we should never see anything above -4.  */
+  assert (token <= 0);
 
-  if (token > 0)
-    /* A continuation call from DW_AT_macro_info iteration.  */
-    return macro_info_getmacros_off (dbg, macoff, callback, arg, token, NULL);
-
-  /* Either a DW_AT_GNU_macros continuation, or a fresh start
-     thereof.  */
   return gnu_macros_getmacros_off (dbg, macoff, callback, arg, token, true,
                                   NULL);
 }
index 1f460ec26bdfccda2dd74855cb636d56393f63e4..4bb19c2e0de5721b13ddf58e561775234ff9579c 100644 (file)
@@ -778,9 +778,6 @@ __libdw_getsrclines (Dwarf *dbg, Dwarf_Off debug_line_offset,
 const char *
 __libdw_getcompdir (Dwarf_Die *cudie)
 {
-  if (cudie == NULL)
-    return NULL;
-
   Dwarf_Attribute compdir_attr_mem;
   Dwarf_Attribute *compdir_attr = INTUSE(dwarf_attr) (cudie,
                                                      DW_AT_comp_dir,
index cd7f5d15e55a50c77dc63bc83a88fe37e1ed7310..9ac8ea493af3ee1952d3ff8ccd16621c18558656 100644 (file)
@@ -831,8 +831,8 @@ extern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts);
    CALLBACK returns DWARF_CB_OK.  If the callback returns
    DWARF_CB_ABORT, it stops iterating and returns a continuation
    token, which can be used to restart the iteration at the point
-   where it ended.  Returns -1 for errors or 0 if there are no more
-   macro entries.
+   where it ended.  A TOKEN of 0 starts the iteration.  Returns -1 for
+   errors or 0 if there are no more macro entries.
 
    Note that the Dwarf_Macro pointer passed to the callback is only
    valid for the duration of the callback invocation.
@@ -849,10 +849,9 @@ extern ptrdiff_t dwarf_getmacros (Dwarf_Die *cudie,
      __nonnull_attribute__ (2);
 
 /* This is similar in operation to dwarf_getmacros, but selects the
-   unit to iterate through by offset instead of by CU.  This can be
-   used for handling DW_MACRO_GNU_transparent_include's or similar
-   opcodes.  Note that with TOKEN of 0, this will always choose to
-   iterate through .debug_macro, never .debug_macinfo.
+   unit to iterate through by offset instead of by CU, and always
+   iterates .debug_macro.  This can be used for handling
+   DW_MACRO_GNU_transparent_include's or similar opcodes.
 
    It is not appropriate to obtain macro unit offset by hand from a CU
    DIE and then request iteration through this interface.  The reason
@@ -876,16 +875,19 @@ extern int dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
   __nonnull_attribute__ (2, 3, 4);
 
 /* Return macro opcode.  That's a constant that can be either from
-   DW_MACINFO_* domain if version of MACRO is 0, or from
-   DW_MACRO_GNU_* domain if the version is 4.  */
+   DW_MACINFO_* domain or DW_MACRO_GNU_* domain.  The two domains have
+   compatible values, so it's OK to use either of them for
+   comparisons.  The only differences is 0xff, which currently is
+   never served from .debug_macro, and can thus be safely assumed to
+   mean DW_MACINFO_vendor_ext.  */
 extern int dwarf_macro_opcode (Dwarf_Macro *macro, unsigned int *opcodep)
      __nonnull_attribute__ (2);
 
 /* Get number of parameters of MACRO and store it to *PARAMCNTP.  */
 extern int dwarf_macro_getparamcnt (Dwarf_Macro *macro, size_t *paramcntp);
 
-/* Get IDX-th parameter of MACRO, and stores it to *ATTRIBUTE.
-   Returns 0 on success or -1 for errors.
+/* Get IDX-th parameter of MACRO (numbered from zero), and stores it
+   to *ATTRIBUTE.  Returns 0 on success or -1 for errors.
 
    After a successful call, you can query ATTRIBUTE by dwarf_whatform
    to determine which of the dwarf_formX calls to make to get actual