summaryrefslogtreecommitdiffstats
path: root/tapsets.cxx
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-07-31 17:24:13 -0700
committerJosh Stone <jistone@redhat.com>2009-07-31 17:34:42 -0700
commitdc5a09fc9a61c8b33078164b6855dea54a33627c (patch)
treea1877ba1c9b69a0cb189ce97092888c84ca6e0ab /tapsets.cxx
parentc67847a0d05f8c7207513e79378fc8d84563e109 (diff)
downloadsystemtap-steved-dc5a09fc9a61c8b33078164b6855dea54a33627c.tar.gz
systemtap-steved-dc5a09fc9a61c8b33078164b6855dea54a33627c.tar.xz
systemtap-steved-dc5a09fc9a61c8b33078164b6855dea54a33627c.zip
Unify no-component assertions on target variables
There are several tapsets that can't deal with component dereferences on their target variables, and they all check-and-throw in the same way. This refactors the checks into a target_symbol member. * staptree.cxx (target_symbol::assert_no_components): New. * tapsets.cxx (tracepoint_var_expanding_visitor::visit_target_symbol_arg, tracepoint_var_expanding_visitor::visit_target_symbol_context): Use the new assertion function to check for no components. * tapset-mark.cxx (mark_var_expanding_visitor::visit_target_symbol_arg, mark_var_expanding_visitor::visit_target_symbol_context): Ditto. * tapset-perfmon.cxx (perfmon_var_expanding_visitor::visit_target_symbol): Ditto. * tapset-procfs.cxx (procfs_var_expanding_visitor::visit_target_symbol): Ditto. * tapset-utrace.cxx (utrace_var_expanding_visitor::visit_target_symbol_arg, utrace_var_expanding_visitor::visit_target_symbol_context): Ditto.
Diffstat (limited to 'tapsets.cxx')
-rw-r--r--tapsets.cxx28
1 files changed, 3 insertions, 25 deletions
diff --git a/tapsets.cxx b/tapsets.cxx
index 70edc7d8..537c33e7 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -5261,19 +5261,8 @@ tracepoint_var_expanding_visitor::visit_target_symbol_arg (target_symbol* e)
}
// make sure we're not dereferencing base types
- if (!e->components.empty() && !arg->isptr)
- switch (e->components[0].type)
- {
- case target_symbol::comp_literal_array_index:
- throw semantic_error("tracepoint variable '" + e->base_name
- + "' may not be used as array", e->tok);
- case target_symbol::comp_struct_member:
- throw semantic_error("tracepoint variable '" + e->base_name
- + "' may not be used as a structure", e->tok);
- default:
- throw semantic_error("invalid use of tracepoint variable '"
- + e->base_name + "'", e->tok);
- }
+ if (!arg->isptr)
+ e->assert_no_components("tracepoint");
// we can only write to dereferenced fields, and only if guru mode is on
bool lvalue = is_active_lvalue(e);
@@ -5393,18 +5382,7 @@ tracepoint_var_expanding_visitor::visit_target_symbol_context (target_symbol* e)
if (is_active_lvalue (e))
throw semantic_error("write to tracepoint '" + e->base_name + "' not permitted", e->tok);
- if (!e->components.empty())
- switch (e->components[0].type)
- {
- case target_symbol::comp_literal_array_index:
- throw semantic_error("tracepoint '" + e->base_name + "' may not be used as array",
- e->tok);
- case target_symbol::comp_struct_member:
- throw semantic_error("tracepoint '" + e->base_name + "' may not be used as a structure",
- e->tok);
- default:
- throw semantic_error("invalid tracepoint '" + e->base_name + "' use", e->tok);
- }
+ e->assert_no_components("tracepoint");
if (e->base_name == "$$name")
{