X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fdisasm-selftests.c;h=e0d84d981eebc603ace6a954a5173b84220d8ab3;hb=e6ed716cd5514c08b9d7c469d185b1aa177dbc22;hp=7d0b006d3972eba5041fd4de205599c924fee8ca;hpb=d7e747318f4d04af033f16325f9b6d74f67079ec;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c index 7d0b006d39..e0d84d981e 100644 --- a/gdb/disasm-selftests.c +++ b/gdb/disasm-selftests.c @@ -1,6 +1,6 @@ /* Self tests for disassembler for GDB, the GNU debugger. - Copyright (C) 2017 Free Software Foundation, Inc. + Copyright (C) 2017-2019 Free Software Foundation, Inc. This file is part of GDB. @@ -21,7 +21,7 @@ #include "disasm.h" #if GDB_SELF_TEST -#include "selftest.h" +#include "common/selftest.h" #include "selftest-arch.h" namespace selftests { @@ -77,12 +77,15 @@ print_one_insn_test (struct gdbarch *gdbarch) /* fall through */ case bfd_arch_nios2: case bfd_arch_score: - /* nios2 and score need to know the current instruction to select - breakpoint instruction. Give the breakpoint instruction kind - explicitly. */ - int bplen; - insn = gdbarch_sw_breakpoint_from_kind (gdbarch, 4, &bplen); - len = bplen; + case bfd_arch_riscv: + /* nios2, riscv, and score need to know the current instruction + to select breakpoint instruction. Give the breakpoint + instruction kind explicitly. */ + { + int bplen; + insn = gdbarch_sw_breakpoint_from_kind (gdbarch, 4, &bplen); + len = bplen; + } break; default: { @@ -102,13 +105,12 @@ print_one_insn_test (struct gdbarch *gdbarch) /* Test gdb_disassembler for a given gdbarch by reading data from a pre-allocated buffer. If you want to see the disassembled instruction printed to gdb_stdout, set verbose to true. */ + static const bool verbose = false; class gdb_disassembler_test : public gdb_disassembler { public: - const bool verbose = false; - explicit gdb_disassembler_test (struct gdbarch *gdbarch, const gdb_byte *insn, size_t len) @@ -190,16 +192,15 @@ memory_error_test (struct gdbarch *gdbarch) gdb_disassembler_test di (gdbarch); bool saw_memory_error = false; - TRY + try { di.print_insn (0); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_error &ex) { if (ex.error == MEMORY_ERROR) saw_memory_error = true; } - END_CATCH /* Expect MEMORY_ERROR. */ SELF_CHECK (saw_memory_error); @@ -208,14 +209,13 @@ memory_error_test (struct gdbarch *gdbarch) } // namespace selftests #endif /* GDB_SELF_TEST */ -/* Suppress warning from -Wmissing-prototypes. */ -extern initialize_file_ftype _initialize_disasm_selftests; - void _initialize_disasm_selftests (void) { #if GDB_SELF_TEST - register_self_test_foreach_arch (selftests::print_one_insn_test); - register_self_test_foreach_arch (selftests::memory_error_test); + selftests::register_test_foreach_arch ("print_one_insn", + selftests::print_one_insn_test); + selftests::register_test_foreach_arch ("memory_error", + selftests::memory_error_test); #endif }