[gdb/exp] Fix exception when printing optimized out vla

When compiling vla-optimized-out.c with -O3 and a recent gcc, and trying to
print the vla a in f1, we run into this gdb exception:
...
Cannot find matching parameter at DW_TAG_call_site 0x4003be at main
...

This is a regression introduced by 42dc7699a2 "[gdb/exp] Fix printing of type
of optimized out vla".

This patch fixes the regression by wrapping the ctx.eval call in
dwarf2_locexpr_baton_eval in try/catch, similar to what is done in
dwarf2_evaluate_loc_desc_full.

Build and reg-tested on x86_64-linux.

2018-07-25  Tom de Vries  <tdevries@suse.de>

	* dwarf2loc.c (dwarf2_locexpr_baton_eval): Wrap ctx.eval call in
	try/catch.

	* gdb.base/vla-optimized-out-o3.exp: New file.  Reuse
	vla-optimized-out.c.
This commit is contained in:
Tom de Vries
2018-07-20 16:41:00 +02:00
parent d7154a8d08
commit 16f808ec99
4 changed files with 66 additions and 1 deletions

View File

@@ -2573,7 +2573,26 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
ctx.ref_addr_size = dwarf2_per_cu_ref_addr_size (dlbaton->per_cu);
ctx.offset = dwarf2_per_cu_text_offset (dlbaton->per_cu);
ctx.eval (dlbaton->data, dlbaton->size);
TRY
{
ctx.eval (dlbaton->data, dlbaton->size);
}
CATCH (ex, RETURN_MASK_ERROR)
{
if (ex.error == NOT_AVAILABLE_ERROR)
{
return 0;
}
else if (ex.error == NO_ENTRY_VALUE_ERROR)
{
if (entry_values_debug)
exception_print (gdb_stdout, ex);
return 0;
}
else
throw_exception (ex);
}
END_CATCH
switch (ctx.location)
{