From ea1e477a78969d44aeea51cfc3cbd2e8ed96cfe4 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Apr 2010 14:33:24 -0700 Subject: PR11474: Don't manually iterate over CUs for @cast Since commit 063906a9, we can just let dwflpp look everywhere for the type on our behalf. Thanks dwflpp! * tapsets.cxx (dwarf_cast_query::handle_query_module): Call dwflpp's declaration_resolve_other_cus, focus on the CU, and expand. (dwarf_cast_query::handle_query_cu): Remove. (dwarf_cast_query::cast_query_cu): Remove. --- tapsets.cxx | 55 +++++++++++++++---------------------------------------- 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/tapsets.cxx b/tapsets.cxx index 7b04f794..4b4fd513 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -2748,9 +2748,6 @@ struct dwarf_cast_query : public base_query pe_type(pe_type), code(code) {} void handle_query_module(); - int handle_query_cu(Dwarf_Die * cudie); - - static int cast_query_cu (Dwarf_Die * cudie, void * arg); }; @@ -2760,46 +2757,24 @@ dwarf_cast_query::handle_query_module() if (!code.empty()) return; - // look for the type in each CU - dw.iterate_over_cus(cast_query_cu, this); -} - - -int -dwarf_cast_query::handle_query_cu(Dwarf_Die * cudie) -{ - if (!code.empty()) - return DWARF_CB_ABORT; + // look for the type in any CU + Dwarf_Die* type_die = dw.declaration_resolve_other_cus(e.type.c_str()); + if (!type_die) + return; - dw.focus_on_cu (cudie); - Dwarf_Die* type_die = dw.declaration_resolve(e.type.c_str()); - if (type_die) + try { - try - { - code = dw.literal_stmt_for_pointer (type_die, &e, - lvalue, pe_type); - } - catch (const semantic_error& er) - { - // XXX might be better to try again in another CU - // NB: we can have multiple errors, since a @cast - // may be expanded in several different contexts: - // function ("*") { @cast(...) } - e.chain (new semantic_error(er)); - } - return DWARF_CB_ABORT; + Dwarf_Die cu_mem; + dw.focus_on_cu(dwarf_diecu(type_die, &cu_mem, NULL, NULL)); + code = dw.literal_stmt_for_pointer (type_die, &e, lvalue, pe_type); + } + catch (const semantic_error& er) + { + // NB: we can have multiple errors, since a @cast + // may be expanded in several different contexts: + // function ("*") { @cast(...) } + e.chain (new semantic_error(er)); } - return DWARF_CB_OK; -} - - -int -dwarf_cast_query::cast_query_cu (Dwarf_Die * cudie, void * arg) -{ - dwarf_cast_query * q = static_cast(arg); - if (pending_interrupts) return DWARF_CB_ABORT; - return q->handle_query_cu(cudie); } -- cgit