aboutsummaryrefslogtreecommitdiff
path: root/gdb/disasm-selftests.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-11-16 15:31:16 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-11-17 10:11:51 +0000
commit6f2643dbd2192e6fff77a5e6fec5141d209fd7d0 (patch)
tree3ad5db07128c45af50b909d3b7e7f868ef26f1c7 /gdb/disasm-selftests.c
parentc72e313608b86c45a822d385ea5bc7acd3b6582c (diff)
downloadgdb-6f2643dbd2192e6fff77a5e6fec5141d209fd7d0.zip
gdb-6f2643dbd2192e6fff77a5e6fec5141d209fd7d0.tar.gz
gdb-6f2643dbd2192e6fff77a5e6fec5141d209fd7d0.tar.bz2
gdb/arc: fix print_one_insn selftest
I noticed that the ARC print_one_insn selftest was failing. The problem is that in print_one_insn_test the arc case falls through into the special case that handles nios2, score, and riscv. The special case for these targets hard codes the breakpoint kind to '4'. This is find for bare metal arc (see arc-tdep.c, arc_sw_breakpoint_from_kind), however, for arc/linux only breakpoint kind '2' is supported (see arc-linux-tdep.c, arc_linux_sw_breakpoint_from_kind). So the code in print_one_insn_test as it is currently written passed in an invalid breakpoint kind, this leads to GDB trying to disassemble unexpected memory. The fix is to reorder the code in print_one_insn_test so that the arc case falls through into the default case. In the default we no longer hard code the breakpoint kind, and everything should be good. Additionally, given the arc code only expects specific breakpoint kind values, I thought it would be nice to add some gdb_assert to validate things. This assert would have triggered in this case and made it easier to find the error. After this commit, configure GDB with --enable-targets=all, then run gdb.gdb/unittest.exp, there should no longer be any failures. gdb/ChangeLog: * arc-linux-tdep.c (arc_linux_sw_breakpoint_from_kind): Add an assert. * arc-tdep.c (arc_breakpoint_kind_from_pc): Likewise. * disasm-selftests.c (print_one_insn_test): Fall throough from ARC case to the default.
Diffstat (limited to 'gdb/disasm-selftests.c')
-rw-r--r--gdb/disasm-selftests.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c
index a24db7f..f8f9993 100644
--- a/gdb/disasm-selftests.c
+++ b/gdb/disasm-selftests.c
@@ -69,11 +69,6 @@ print_one_insn_test (struct gdbarch *gdbarch)
insn = xstormy16_insn;
len = sizeof (xstormy16_insn);
break;
- case bfd_arch_arc:
- /* PR 21003 */
- if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_arc_arc601)
- return;
- /* fall through */
case bfd_arch_nios2:
case bfd_arch_score:
case bfd_arch_riscv:
@@ -86,6 +81,11 @@ print_one_insn_test (struct gdbarch *gdbarch)
len = bplen;
}
break;
+ case bfd_arch_arc:
+ /* PR 21003 */
+ if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_arc_arc601)
+ return;
+ /* fall through */
default:
{
/* Test disassemble breakpoint instruction. */