[Lldb-commits] [lldb] [lldb][riscv] Fix setting breakpoint for undecoded instruction (PR #90075)

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Mon May 20 18:02:11 PDT 2024


================
@@ -115,8 +148,23 @@ Status NativeProcessSoftwareSingleStep::SetupSoftwareSingleStepping(
   emulator_up->SetWriteMemCallback(&WriteMemoryCallback);
   emulator_up->SetWriteRegCallback(&WriteRegisterCallback);
 
-  if (!emulator_up->ReadInstruction())
-    return Status("Read instruction failed!");
+  if (!emulator_up->ReadInstruction()) {
----------------
jasonmolenda wrote:

Ah wait, I see.  This method is trying to decode where the next instruction will go, with branches and jumps decoded, so we can put a breakpoint there.  And you're handling the case where we can't decode the current instruction (I now understand why you used that in your test case).  It seems harmless to call GetLastInstrSize() if the instruction that couldn't be decoded, and add the length of the instruction to pc.  We can assume the emulation engine will emulate all branching instructions.  I could imagine the RISCV emulation plugin didn't have decoding for an instruction that doesn't branch, it could fail, but we can still decode the size of that unknown instruction successfully, and assume that it does not branch.

https://github.com/llvm/llvm-project/pull/90075


More information about the lldb-commits mailing list