From 56212da92dae36e5870ac6149c89d967fcab10f9 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 8 May 2009 18:32:17 -0700 Subject: PR10054: Unify the translate_components errors Since translate_components is the one that knows the details of its failures, it makes more sense to let it throw its own errors, instead of relying on each caller to do it. The function now always either returns successfully or throws an error. --- tapsets.cxx | 51 ++++++++++++--------------------------------------- 1 file changed, 12 insertions(+), 39 deletions(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index a3ad8436..1e0d9e6b 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -1843,7 +1843,18 @@ success: { vector locs; if (!find_struct_member(e->components[i].second, die, e, die, locs)) - return NULL; + { + string alternatives; + stringstream members; + print_members(die, members); + if (members.str().size() != 0) + alternatives = " (alternatives:" + members.str(); + throw semantic_error("unable to find member '" + + e->components[i].second + "' for struct " + + string(dwarf_diename_integrate(die) ?: "") + + alternatives, + e->tok); + } for (unsigned j = 0; j < locs.size(); ++j) translate_location (pool, &locs[j], pc, NULL, tail, e); @@ -2130,17 +2141,6 @@ success: Dwarf_Die die_mem, *die = dwarf_formref_die (&attr_mem, &die_mem); die = translate_components (&pool, &tail, pc, e, die, &die_mem, &attr_mem); - if(!die) - { - die = dwarf_formref_die (&attr_mem, &die_mem); - stringstream alternatives; - if (die != NULL) - print_members(die,alternatives); - throw semantic_error("unable to find local '" + local + "'" - + " near pc " + lex_cast_hex(pc) - + (alternatives.str() == "" ? "" : (" (alternatives:" + alternatives.str () + ")")), - e->tok); - } /* Translate the assignment part, either x = $foo->bar->baz[NN] @@ -2218,22 +2218,6 @@ success: Dwarf_Die die_mem, *die = dwarf_formref_die (&attr_mem, &die_mem); die = translate_components (&pool, &tail, pc, e, die, &die_mem, &attr_mem); - if(!die) - { - die = dwarf_formref_die (&attr_mem, &die_mem); - stringstream alternatives; - if (die != NULL) - print_members(die,alternatives); - throw semantic_error("unable to find return value" - " near pc " + lex_cast_hex(pc) - + " for " - + string(dwarf_diename(scope_die) ?: "") - + "(" + string(dwarf_diename(cu) ?: "") - + ")" - + (alternatives.str() == "" ? "" : (" (alternatives:" + alternatives.str () + ")")), - e->tok); - } - /* Translate the assignment part, either x = $return->bar->baz[NN] @@ -2277,17 +2261,6 @@ success: Dwarf_Die die_mem, *die = NULL; die = translate_components (&pool, &tail, 0, e, type_die, &die_mem, &attr_mem); - if(!die) - { - die = dwarf_formref_die (&attr_mem, &die_mem); - stringstream alternatives; - print_members(die ?: type_die, alternatives); - throw semantic_error("unable to find member for struct " - + string(dwarf_diename(die ?: type_die) ?: "") - + (alternatives.str() == "" ? "" : (" (alternatives:" + alternatives.str () + ")")), - e->tok); - } - /* Translate the assignment part, either x = (THIS->pointer)->bar->baz[NN] -- cgit