Fix register regression in DWARF evaluator

On an internal test case, using an arm-elf target, commit ba5bc3e5a9
("Make DWARF evaluator return a single struct value") causes a
regression.  (It doesn't happen for any of the other cross targets
that I test when importing upstream gdb.)

I don't know if there's an upstream gdb test case showing the same
problem... I can only really run native tests with dejagnu AFAIK.

The failure manifests like this:

    Breakpoint 1, file_1.export_1 (param_1=<error reading variable: Unable to access DWARF register number 64>, str=...) at [...]/file_1.adb:5

Whereas when it works it looks like:

    Breakpoint 1, file_1.export_1 (param_1=99.0, str=...) at [...]/file_1.adb:5

The difference is that the new code uses the passed-in gdbarch,
whereas the old code used the frame's gdbarch, when handling
DWARF_VALUE_REGISTER.

This patch restores the use of the frame's arch.
This commit is contained in:
Tom Tromey
2021-08-12 06:44:40 -06:00
parent 1dd34eff4b
commit 892a1e5303

View File

@@ -927,9 +927,11 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
{
case DWARF_VALUE_REGISTER:
{
gdbarch *f_arch = get_frame_arch (this->m_frame);
int dwarf_regnum
= longest_to_int (value_as_long (this->fetch (0)));
int gdb_regnum = dwarf_reg_to_regnum_or_error (arch, dwarf_regnum);
int gdb_regnum = dwarf_reg_to_regnum_or_error (f_arch,
dwarf_regnum);
if (subobj_offset != 0)
error (_("cannot use offset on synthetic pointer to register"));