summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-08-19 17:27:18 -0700
committerJosh Stone <jistone@redhat.com>2009-08-19 17:27:18 -0700
commit3d1ad34033e6f77368287927049e112d9ee3677e (patch)
tree6ddc1b1ae665ed6be9a01b81d142f048c2b063d8
parentde9a66e3bbc3f287229cad892108e46ac44b2bdf (diff)
downloadsystemtap-steved-3d1ad34033e6f77368287927049e112d9ee3677e.tar.gz
systemtap-steved-3d1ad34033e6f77368287927049e112d9ee3677e.tar.xz
systemtap-steved-3d1ad34033e6f77368287927049e112d9ee3677e.zip
Create a dwarf_attr_die idiom
We commonly do a dwarf_attr_integrate followed by dwarf_formref_die, with no care for the Dwarf_Attribute, so I captured that idiom in an inline function. * dwarf_wrappers.h (dwarf_attr_die): New. * dwarf_wrappers.cxx (dwarf_type_name): Call dwarf_attr_die. * dwflpp.cxx (dwflpp::print_members): Ditto. (dwflpp::find_struct_member): Ditto. * tapsets.cxx (dwarf_derived_probe::saveargs): Ditto. (uprobe_derived_probe::saveargs): Ditto. (resolve_tracepoint_arg_type): Ditto. (tracepoint_derived_probe::build_args): Ditto.
-rw-r--r--dwarf_wrappers.cxx4
-rw-r--r--dwarf_wrappers.h10
-rw-r--r--dwflpp.cxx13
-rw-r--r--tapsets.cxx25
4 files changed, 21 insertions, 31 deletions
diff --git a/dwarf_wrappers.cxx b/dwarf_wrappers.cxx
index fe8ead07..7b64aac5 100644
--- a/dwarf_wrappers.cxx
+++ b/dwarf_wrappers.cxx
@@ -125,10 +125,8 @@ dwarf_type_name(Dwarf_Die *type_die, ostringstream& o)
// recurse into the referent type
// if it can't be named, just call it "void"
- Dwarf_Attribute subtype_attr;
Dwarf_Die subtype_die;
- if (!dwarf_attr_integrate(type_die, DW_AT_type, &subtype_attr)
- || !dwarf_formref_die(&subtype_attr, &subtype_die)
+ if (!dwarf_attr_die(type_die, DW_AT_type, &subtype_die)
|| !dwarf_type_name(&subtype_die, o))
o.str("void"), o.seekp(4);
diff --git a/dwarf_wrappers.h b/dwarf_wrappers.h
index bc1cde2b..766abb6d 100644
--- a/dwarf_wrappers.h
+++ b/dwarf_wrappers.h
@@ -103,6 +103,16 @@ public:
};
+// Look up the DIE for a reference-form attribute name
+inline Dwarf_Die *
+dwarf_attr_die (Dwarf_Die *die, unsigned int attr, Dwarf_Die *result)
+{
+ Dwarf_Attribute attr_mem;
+ return dwarf_formref_die (dwarf_attr_integrate (die, attr, &attr_mem),
+ result);
+}
+
+
#if !_ELFUTILS_PREREQ(0, 143)
// Elfutils prior to 0.143 didn't use attr_integrate when looking up the
// decl_file or decl_line, so the attributes would sometimes be missed. For
diff --git a/dwflpp.cxx b/dwflpp.cxx
index dcf04678..dce19f21 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -1588,10 +1588,7 @@ dwflpp::print_members(Dwarf_Die *vardie, ostream &o)
else
{
Dwarf_Die temp_die;
- Dwarf_Attribute temp_attr;
-
- if (!dwarf_attr_integrate (die, DW_AT_type, &temp_attr) ||
- !dwarf_formref_die (&temp_attr, &temp_die))
+ if (!dwarf_attr_die (die, DW_AT_type, &temp_die))
{
string source = dwarf_decl_file(die) ?: "<unknown source>";
int line = -1;
@@ -1642,12 +1639,8 @@ dwflpp::find_struct_member(const target_symbol::component& c,
{
// need to recurse for anonymous structs/unions
Dwarf_Die subdie;
-
- if (!dwarf_attr_integrate (&die, DW_AT_type, &attr) ||
- !dwarf_formref_die (&attr, &subdie))
- continue;
-
- if (find_struct_member(c, &subdie, memberdie, locs))
+ if (dwarf_attr_die (&die, DW_AT_type, &subdie) &&
+ find_struct_member(c, &subdie, memberdie, locs))
goto success;
}
else if (name == c.member)
diff --git a/tapsets.cxx b/tapsets.cxx
index 0e46962d..04d03503 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -2780,12 +2780,10 @@ dwarf_derived_probe::saveargs(Dwarf_Die* scope_die)
stringstream argstream;
string type_name;
- Dwarf_Attribute type_attr;
Dwarf_Die type_die;
if (has_return &&
- dwarf_attr_integrate (scope_die, DW_AT_type, &type_attr) &&
- dwarf_formref_die (&type_attr, &type_die) &&
+ dwarf_attr_die (scope_die, DW_AT_type, &type_die) &&
dwarf_type_name(&type_die, type_name))
argstream << " $return:" << type_name;
@@ -2808,8 +2806,7 @@ dwarf_derived_probe::saveargs(Dwarf_Die* scope_die)
continue;
type_name.clear();
- if (!dwarf_attr_integrate (&arg, DW_AT_type, &type_attr) ||
- !dwarf_formref_die (&type_attr, &type_die) ||
+ if (!dwarf_attr_die (&arg, DW_AT_type, &type_die) ||
!dwarf_type_name(&type_die, type_name))
continue;
@@ -4286,12 +4283,10 @@ uprobe_derived_probe::saveargs(Dwarf_Die* scope_die)
stringstream argstream;
string type_name;
- Dwarf_Attribute type_attr;
Dwarf_Die type_die;
if (return_p &&
- dwarf_attr_integrate (scope_die, DW_AT_type, &type_attr) &&
- dwarf_formref_die (&type_attr, &type_die) &&
+ dwarf_attr_die (scope_die, DW_AT_type, &type_die) &&
dwarf_type_name(&type_die, type_name))
argstream << " $return:" << type_name;
@@ -4314,8 +4309,7 @@ uprobe_derived_probe::saveargs(Dwarf_Die* scope_die)
continue;
type_name.clear();
- if (!dwarf_attr_integrate (&arg, DW_AT_type, &type_attr) ||
- !dwarf_formref_die (&type_attr, &type_die) ||
+ if (!dwarf_attr_die (&arg, DW_AT_type, &type_die) ||
!dwarf_type_name(&type_die, type_name))
continue;
@@ -5583,15 +5577,13 @@ tracepoint_derived_probe::tracepoint_derived_probe (systemtap_session& s,
static bool
resolve_tracepoint_arg_type(tracepoint_arg& arg)
{
- Dwarf_Attribute type_attr;
switch (dwarf_tag(&arg.type_die))
{
case DW_TAG_typedef:
case DW_TAG_const_type:
case DW_TAG_volatile_type:
// iterate on the referent type
- return (dwarf_attr_integrate(&arg.type_die, DW_AT_type, &type_attr)
- && dwarf_formref_die(&type_attr, &arg.type_die)
+ return (dwarf_attr_die(&arg.type_die, DW_AT_type, &arg.type_die)
&& resolve_tracepoint_arg_type(arg));
case DW_TAG_base_type:
// base types will simply be treated as script longs
@@ -5600,8 +5592,7 @@ resolve_tracepoint_arg_type(tracepoint_arg& arg)
case DW_TAG_pointer_type:
// pointers can be treated as script longs,
// and if we know their type, they can also be dereferenced
- if (dwarf_attr_integrate(&arg.type_die, DW_AT_type, &type_attr)
- && dwarf_formref_die(&type_attr, &arg.type_die))
+ if (dwarf_attr_die(&arg.type_die, DW_AT_type, &arg.type_die))
arg.isptr = true;
arg.typecast = "(intptr_t)";
return true;
@@ -5632,9 +5623,7 @@ tracepoint_derived_probe::build_args(dwflpp& dw, Dwarf_Die& func_die)
tparg.name = dwarf_diename(&arg);
// read the type of this parameter
- Dwarf_Attribute type_attr;
- if (!dwarf_attr_integrate (&arg, DW_AT_type, &type_attr)
- || !dwarf_formref_die (&type_attr, &tparg.type_die)
+ if (!dwarf_attr_die (&arg, DW_AT_type, &tparg.type_die)
|| !dwarf_type_name(&tparg.type_die, tparg.c_type))
throw semantic_error ("cannot get type of tracepoint '"
+ tracepoint_name + "' parameter '"