summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Machata <[email protected]>2014-11-04 17:30:03 +0100
committerPetr Machata <[email protected]>2014-11-04 17:30:03 +0100
commit049c40c6a221d8189ecd538ac007402211cd3050 (patch)
treea5ae7977cb40b412a1921c0f10b490dd71283c04
parent8a44e6c215edffae1ef66b9c43aeb730901d43a6 (diff)
Update per the review
-rw-r--r--NEWS8
-rw-r--r--libdw/dwarf_getmacros.c14
-rw-r--r--libdw/dwarf_getsrclines.c3
-rw-r--r--libdw/libdw.h22
4 files changed, 23 insertions, 24 deletions
diff --git a/NEWS b/NEWS
index aceb3e33..2334646e 100644
--- 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.
diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c
index 7f889a91..8d9d78be 100644
--- a/libdw/dwarf_getmacros.c
+++ b/libdw/dwarf_getmacros.c
@@ -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);
}
diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c
index 1f460ec2..4bb19c2e 100644
--- a/libdw/dwarf_getsrclines.c
+++ b/libdw/dwarf_getsrclines.c
@@ -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,
diff --git a/libdw/libdw.h b/libdw/libdw.h
index cd7f5d15..9ac8ea49 100644
--- a/libdw/libdw.h
+++ b/libdw/libdw.h
@@ -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