From 03c75a4a21ef3dba8abbc7e596d2a102427a3d96 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 15 Jul 2009 18:21:56 -0700 Subject: PR5930: Address-op for $target and @cast members This allows the '&' operator to get the address of @cast and $target variable expressions. * staptree.h (target_symbol): add addressof field * staptree.cxx (target_symbol::print): print '&' for addressof (cast_op::print): ditto * parse.cxx (parser::parse_value): allow '&' prefix on $target/@cast * dwflpp.cxx (dwflpp::translate_final_fetch_or_store): allow taking the computed address without actually doing a final fetch. * tapset* (*::visit_target_symbol): throw errors for $vars w/o addresses * testsuite/systemtap.base/cast.stp: add &@cast test * testsuite/semok/target_addr.stp: test '&' on different member types * testsuite/semko/target_addr?.stp: test failure on bitfields/registers --- tapsets.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index 9ca25b0b..f629d08c 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -2331,6 +2331,9 @@ dwarf_var_expanding_visitor::visit_target_symbol (target_symbol *e) if (dwarf_getscopes_die (scope_die, &scopes) == 0) return; + if (e->addressof) + throw semantic_error("cannot take address of context variable", e->tok); + target_symbol *tsym = new target_symbol; print_format* pf = new print_format; @@ -3356,6 +3359,9 @@ sdt_var_expanding_visitor::visit_target_symbol (target_symbol *e) { if (e->base_name == "$$name") { + if (e->addressof) + throw semantic_error("cannot take address of sdt variable", e->tok); + literal_string *myname = new literal_string (probe_name); myname->tok = e->tok; provide(myname); @@ -3409,6 +3415,9 @@ sdt_var_expanding_visitor::visit_target_symbol (target_symbol *e) if (e->components.empty()) { + if (e->addressof) + throw semantic_error("cannot take address of sdt variable", e->tok); + provide(fc); return; } @@ -5041,6 +5050,9 @@ tracepoint_var_expanding_visitor::visit_target_symbol_arg (target_symbol* e) if (e->components.empty()) { + if (e->addressof) + throw semantic_error("cannot take address of tracepoint variable", e->tok); + // Just grab the value from the probe locals e->probe_context_var = "__tracepoint_arg_" + arg->name; e->type = pe_long; @@ -5140,6 +5152,9 @@ tracepoint_var_expanding_visitor::visit_target_symbol_arg (target_symbol* e) void tracepoint_var_expanding_visitor::visit_target_symbol_context (target_symbol* e) { + if (e->addressof) + throw semantic_error("cannot take address of context variable", e->tok); + if (is_active_lvalue (e)) throw semantic_error("write to tracepoint '" + e->base_name + "' not permitted", e->tok); -- cgit