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 --- dwflpp.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'dwflpp.cxx') diff --git a/dwflpp.cxx b/dwflpp.cxx index dc7af5d8..79561c73 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -1830,6 +1830,21 @@ dwflpp::translate_final_fetch_or_store (struct obstack *pool, typedie = resolve_unqualified_inner_typedie (&typedie_mem, attr_mem, e); typetag = dwarf_tag (typedie); + /* If we're looking for an address, then we can just provide what + we computed to this point, without using a fetch/store. */ + if (e->addressof) + { + if (lvalue) + throw semantic_error ("cannot write to member address", e->tok); + + if (dwarf_hasattr_integrate (die, DW_AT_bit_offset)) + throw semantic_error ("cannot take address of bit-field", e->tok); + + c_translate_addressof (pool, 1, 0, 0, die, tail, "THIS->__retvalue"); + ty = pe_long; + return; + } + /* Then switch behavior depending on the type of fetch/store we want, and the type and pointer-ness of the final location. */ -- cgit