]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Handle JALR.CAP in riscv_next_pc().
authorJohn Baldwin <jhb@FreeBSD.org>
Wed, 18 Mar 2020 23:40:35 +0000 (16:40 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 13 Oct 2022 18:25:32 +0000 (11:25 -0700)
This fixes stepping into some functions in purecap.

gdb/riscv-tdep.c

index 49f6fe8cb8cfe90d4b5ec457010a0b605dcf9058..f7da7165056a864191da4c78998f92caf65500ca 100644 (file)
@@ -1570,6 +1570,7 @@ public:
       BGE,
       BLTU,
       BGEU,
+      JALR_CAP,
       /* These are needed for stepping over atomic sequences.  */
       LR,
       SC,
@@ -1866,6 +1867,8 @@ riscv_insn::decode (struct gdbarch *gdbarch, CORE_ADDR pc)
        decode_b_type_insn (BLTU, ival);
       else if (is_bgeu_insn (ival))
        decode_b_type_insn (BGEU, ival);
+      else if (is_jalr_cap_insn (ival))
+       decode_r_type_insn (JALR_CAP, ival);
       else if (is_lr_w_insn (ival))
        decode_r_type_insn (LR, ival);
       else if (is_lr_d_insn (ival))
@@ -4178,6 +4181,13 @@ riscv_next_pc (struct regcache *regcache, CORE_ADDR pc)
       if (tdep->syscall_next_pc != nullptr)
        next_pc = tdep->syscall_next_pc (get_current_frame ());
     }
+  else if (insn.opcode () == riscv_insn::JALR_CAP && riscv_has_cheri (gdbarch))
+    {
+      gdb_byte source[register_size (gdbarch, RISCV_CNULL_REGNUM)];
+      regcache->cooked_read (RISCV_CNULL_REGNUM + insn.rs1 (), source);
+      next_pc = extract_unsigned_integer (source, riscv_isa_xlen (gdbarch),
+                                         gdbarch_byte_order (gdbarch));
+    }
 
   return next_pc;
 }