summaryrefslogtreecommitdiffstats
path: root/staptree.h
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-08-03 14:45:21 -0700
committerJosh Stone <jistone@redhat.com>2009-08-03 15:14:21 -0700
commit6fda2dff51c667a8c73545dd397b844108715310 (patch)
treeb0a6be2e84f7a9ce8b0f72a3e9b4f2c329ac9ba2 /staptree.h
parentdc5a09fc9a61c8b33078164b6855dea54a33627c (diff)
downloadsystemtap-steved-6fda2dff51c667a8c73545dd397b844108715310.tar.gz
systemtap-steved-6fda2dff51c667a8c73545dd397b844108715310.tar.xz
systemtap-steved-6fda2dff51c667a8c73545dd397b844108715310.zip
PR2049: support arbitrary $target-array indexing
Rather than just numeric literals, we can now support arbitrary expressions for the index value. Note that loc2c won't allow this for noncontiguous arrays, as the access methods need to be statically computed, but for contiguous arrays and pointers-as-arrays it works just fine. * staptree.h (target_symbol::component): Add expression_array_index. * staptree.cxx (target_symbol::visit_components): New helper. (target_symbol::assert_no_components): Recognize new array type. (target_symbol::component::print): Print subexpressions. (traversing_visitor::visit_target_symbol, visit_cast_op): Visit the indexing components too. (varuse_collecting_visitor::visit_target_symbol): Ditto. (update_visitor::visit_target_symbol, visit_cast_op): Ditto. * elaborate.cxx (void_statement_reducer::visit_target_symbol): New. (void_statement_reducer::visit_cast_op): Save indexes too. * parse.cxx (parser::parse_target_symbol_components): Parse expressions. * tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol): Pass expression-indexes as parameters (indexN) to the dwarf function. (dwarf_cast_expanding_visitor::visit_cast_op): Ditto. (tracepoint_var_expanding_visitor::visit_target_symbol_arg): Ditto. (sdt_var_expanding_visitor::visit_target_symbol): Visit the new @cast. * dwflpp.cxx (dwflpp::translate_components): Use THIS->indexN. * translate.cxx (c_unparser::visit_target_symbol): Correct error msg. * testsuite/systemtap.base/pointer_array.stp: Use a simple index.
Diffstat (limited to 'staptree.h')
-rw-r--r--staptree.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/staptree.h b/staptree.h
index 9ade2a42..146d0e34 100644
--- a/staptree.h
+++ b/staptree.h
@@ -58,6 +58,7 @@ std::ostream& operator << (std::ostream& o, const exp_type& e);
struct token;
struct visitor;
+struct update_visitor;
struct expression
{
@@ -227,7 +228,8 @@ struct target_symbol: public symbol
enum component_type
{
comp_struct_member,
- comp_literal_array_index
+ comp_literal_array_index,
+ comp_expression_array_index,
};
struct component
@@ -236,11 +238,14 @@ struct target_symbol: public symbol
component_type type;
std::string member; // comp_struct_member
int64_t num_index; // comp_literal_array_index
+ expression* expr_index; // comp_expression_array_index
component(const token* t, const std::string& m):
- tok(t), type(comp_struct_member), member(m), num_index(0) {}
+ tok(t), type(comp_struct_member), member(m) {}
component(const token* t, int64_t n):
tok(t), type(comp_literal_array_index), num_index(n) {}
+ component(const token* t, expression* e):
+ tok(t), type(comp_expression_array_index), expr_index(e) {}
void print (std::ostream& o) const;
};
@@ -252,6 +257,8 @@ struct target_symbol: public symbol
target_symbol(): addressof(false), saved_conversion_error (0) {}
void print (std::ostream& o) const;
void visit (visitor* u);
+ void visit_components (visitor* u);
+ void visit_components (update_visitor* u);
void assert_no_components(const std::string& tapset);
};