summaryrefslogtreecommitdiffstats
path: root/staptree.cxx
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-07-31 17:00:09 -0700
committerJosh Stone <jistone@redhat.com>2009-07-31 17:08:07 -0700
commitc67847a0d05f8c7207513e79378fc8d84563e109 (patch)
tree799f8f524dab1175e1a2a5ffce03774f7adc4259 /staptree.cxx
parent81931eaba5dcd0727f33328bf4b0ff511b791990 (diff)
downloadsystemtap-steved-c67847a0d05f8c7207513e79378fc8d84563e109.tar.gz
systemtap-steved-c67847a0d05f8c7207513e79378fc8d84563e109.tar.xz
systemtap-steved-c67847a0d05f8c7207513e79378fc8d84563e109.zip
Make a real type for target_symbol->components
Now the dereferences on target_symbol and cast_op are tracked with a struct instead of just a generic pair. The first immediate benefit is that we can track the token for more exact error reporting. * staptree.h (target_symbol): Add a new component type. * staptree.cxx (target_symbol::component::print): New. (operator<<(ostream&, target_symbol::component&): New. (target_symbol::print): Adapt component printing. (cast_op::print): Ditto. * parse.cxx (parser::parse_target_symbol_components): Adapt to the new component construction. * dwflpp.cxx (dwflpp::find_struct_member): take the component as a parameter for a better token in error messages (dwflpp::translate_components): Adapt to the new component type. * tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol): Don't overwrite the token in target_symbol saved errors. (tracepoint_var_expanding_visitor::visit_target_symbol_arg): Ditto.
Diffstat (limited to 'staptree.cxx')
-rw-r--r--staptree.cxx45
1 files changed, 23 insertions, 22 deletions
diff --git a/staptree.cxx b/staptree.cxx
index b14a5c44..1231f74d 100644
--- a/staptree.cxx
+++ b/staptree.cxx
@@ -259,23 +259,34 @@ void symbol::print (ostream& o) const
}
+void target_symbol::component::print (ostream& o) const
+{
+ switch (type)
+ {
+ case comp_struct_member:
+ o << "->" << member;
+ break;
+ case comp_literal_array_index:
+ o << '[' << num_index << ']';
+ break;
+ }
+}
+
+
+std::ostream& operator << (std::ostream& o, const target_symbol::component& c)
+{
+ c.print (o);
+ return o;
+}
+
+
void target_symbol::print (ostream& o) const
{
if (addressof)
o << "&";
o << base_name;
for (unsigned i = 0; i < components.size(); ++i)
- {
- switch (components[i].first)
- {
- case comp_literal_array_index:
- o << '[' << components[i].second << ']';
- break;
- case comp_struct_member:
- o << "->" << components[i].second;
- break;
- }
- }
+ o << components[i];
}
@@ -289,17 +300,7 @@ void cast_op::print (ostream& o) const
o << ", " << lex_cast_qstring (module);
o << ')';
for (unsigned i = 0; i < components.size(); ++i)
- {
- switch (components[i].first)
- {
- case comp_literal_array_index:
- o << '[' << components[i].second << ']';
- break;
- case comp_struct_member:
- o << "->" << components[i].second;
- break;
- }
- }
+ o << components[i];
}