aboutsummaryrefslogtreecommitdiff
path: root/gdb/disasm-selftests.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2018-09-28 14:15:54 -0700
committerJohn Baldwin <jhb@FreeBSD.org>2018-09-28 14:15:54 -0700
commitf37bc8b13c898fa39731c20d8565b24e006c13a8 (patch)
treeb7a4dce3462728cd012753b919c2f5d10b3788fe /gdb/disasm-selftests.c
parent2283a21049cdefb87cdd0f11df367266e3e029d1 (diff)
downloadfsf-binutils-gdb-f37bc8b13c898fa39731c20d8565b24e006c13a8.zip
fsf-binutils-gdb-f37bc8b13c898fa39731c20d8565b24e006c13a8.tar.gz
fsf-binutils-gdb-f37bc8b13c898fa39731c20d8565b24e006c13a8.tar.bz2
Use the existing instruction to determine the RISC-V breakpoint kind.
RISC-V supports instructions of varying lengths. Standard existing instructions in the base ISA are 4 bytes in length, but the 'C' extension adds support for compressed, 2 byte instructions. RISC-V supports two different breakpoint instructions: EBREAK is a 4 byte instruction in the base ISA, and C.EBREAK is a 2 byte instruction only available on processors implementing the 'C' extension. Using EBREAK to set breakpoints on compressed instructions causes problems as the second half of EBREAK will overwrite the first 2 bytes of the following instruction breaking other threads in the process if their PC is the following instruction. Thus, breakpoints on compressed instructions need to use C.EBREAK instead of EBREAK. Previously, the riscv architecture checked the MISA register to determine if the 'C' extension was available. If so, it used C.EBREAK for all breakpoints. However, the MISA register is not necessarily available to supervisor mode operating systems. While native targets could provide a fake MISA register value, this patch instead examines the existing instruction at a breakpoint target to determine which breakpoint instruction to use. If the existing instruction is a compressed instruction, C.EBREAK is used, otherwise EBREAK is used. gdb/ChangeLog: * disasm-selftests.c (print_one_insn_test): Add bfd_arch_riscv to case with explicit breakpoint kind. * riscv-tdep.c (show_use_compressed_breakpoints): Remove 'additional_info' and related logic. (riscv_debug_breakpoints): New variable. (riscv_breakpoint_kind_from_pc): Use the length of the existing instruction to determine the breakpoint kind. (_initialize_riscv_tdep): Add 'set/show debug riscv breakpoints' flag. Update description of 'set/show riscv use-compressed-breakpoints' flag.
Diffstat (limited to 'gdb/disasm-selftests.c')
-rw-r--r--gdb/disasm-selftests.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c
index f7d0ecc..8cc2676 100644
--- a/gdb/disasm-selftests.c
+++ b/gdb/disasm-selftests.c
@@ -77,9 +77,10 @@ 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. */
+ 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;