From 675e4d2a0635f822e8258c3f219c6dda685c67cf Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 13 Apr 2009 14:46:54 -0700 Subject: PR10049: Restore better errors for $return In commit c4ce66a1 I shifted some of the variable accesses around, and that caused the error messages for $return variables to lose context. The root problem in this case was that dwarf_attr didn't find the type attribute, and that failure wasn't immediately caught. Now that result is checked so we can provide a proper error message. While I'm at it, changing that lookup to dwarf_attr_integrate is enough to make the $return value usable again, at least for the reported test case. --- tapsets.cxx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index 774821c7..094ae358 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -2434,13 +2434,12 @@ struct dwflpp /* Translate the ->bar->baz[NN] parts. */ - Dwarf_Die die_mem, *die = NULL; - die = dwarf_formref_die (&attr_mem, &die_mem); + 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, &vardie); + die = dwarf_formref_die (&attr_mem, &die_mem); stringstream alternatives; if (die != NULL) print_members(die,alternatives); @@ -2516,17 +2515,19 @@ struct dwflpp /* Translate the ->bar->baz[NN] parts. */ Dwarf_Attribute attr_mem; - Dwarf_Attribute *attr = dwarf_attr (scope_die, DW_AT_type, &attr_mem); - - Dwarf_Die vardie_mem; - Dwarf_Die *vardie = dwarf_formref_die (attr, &vardie_mem); + if (dwarf_attr_integrate (scope_die, DW_AT_type, &attr_mem) == NULL) + throw semantic_error("failed to retrieve return value type attribute for " + + string(dwarf_diename(scope_die) ?: "") + + "(" + string(dwarf_diename(cu) ?: "") + + ")", + e->tok); - Dwarf_Die die_mem, *die = NULL; + Dwarf_Die die_mem, *die = dwarf_formref_die (&attr_mem, &die_mem); die = translate_components (&pool, &tail, pc, e, - vardie, &die_mem, &attr_mem); + die, &die_mem, &attr_mem); if(!die) { - die = dwarf_formref_die (&attr_mem, vardie); + die = dwarf_formref_die (&attr_mem, &die_mem); stringstream alternatives; if (die != NULL) print_members(die,alternatives); -- cgit