summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-05-08 18:32:17 -0700
committerJosh Stone <jistone@redhat.com>2009-05-08 18:32:17 -0700
commit56212da92dae36e5870ac6149c89d967fcab10f9 (patch)
tree631f1578dc6379a332133fc2e0456508e6fc6818
parent0730bfbd2665aef93d6fae287f3623a51f243540 (diff)
downloadsystemtap-steved-56212da92dae36e5870ac6149c89d967fcab10f9.tar.gz
systemtap-steved-56212da92dae36e5870ac6149c89d967fcab10f9.tar.xz
systemtap-steved-56212da92dae36e5870ac6149c89d967fcab10f9.zip
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.
-rw-r--r--tapsets.cxx51
1 files changed, 12 insertions, 39 deletions
diff --git a/tapsets.cxx b/tapsets.cxx
index a3ad8436..1e0d9e6b 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -1843,7 +1843,18 @@ success:
{
vector<Dwarf_Attribute> 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) ?: "<unknown>")
+ + 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<string>(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<string>(pc)
- + " for "
- + string(dwarf_diename(scope_die) ?: "<unknown>")
- + "(" + string(dwarf_diename(cu) ?: "<unknown>")
- + ")"
- + (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) ?: "<unknown>")
- + (alternatives.str() == "" ? "" : (" (alternatives:" + alternatives.str () + ")")),
- e->tok);
- }
-
/* Translate the assignment part, either
x = (THIS->pointer)->bar->baz[NN]