From 892a1e530379eeea924e938c8a588fbf3845f4fa Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 12 Aug 2021 06:44:40 -0600 Subject: [PATCH] Fix register regression in DWARF evaluator On an internal test case, using an arm-elf target, commit ba5bc3e5a92 ("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=, 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. --- gdb/dwarf2/expr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 85088e9a07a..0e62de22aff 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -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")); -- 2.30.2