sirmc created this revision.
sirmc added a reviewer: LLDB.
sirmc added a project: LLDB.
Herald added a subscriber: lldb-commits.
sirmc edited the summary of this revision.
When executing `thread step-inst `/ `si` on an instruction that returns to the
same PC, LLDB currently keeps stepping indefinitely.
I couldn't find the exact semantics for the step-instruction, but
https://lldb.llvm.org/use/map.html suggests the behavior to be equivalent to
GDB's `si`. GDB steps exactly one instruction, without the assumption that the
program counter has to change.
Reproduce with the following code:
int main()
{
while(1){};
return 0;
}
When compiled with `clang -g a.c`, the above example generates an instruction
(X86-64 jmpq) that jumps to the address of itself. When reaching the line with
the loop, a `si` will never stop/break in this case, since the assumption is
that the PC needs to change for the stepping to be finished.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81810
Files:
lldb/source/Target/ThreadPlanStepInstruction.cpp
Index: lldb/source/Target/ThreadPlanStepInstruction.cpp
===================================================================
--- lldb/source/Target/ThreadPlanStepInstruction.cpp
+++ lldb/source/Target/ThreadPlanStepInstruction.cpp
@@ -217,19 +217,16 @@
}
}
} else {
- lldb::addr_t pc_addr = thread.GetRegisterContext()->GetPC(0);
- if (pc_addr != m_instruction_addr) {
- if (--m_iteration_count <= 0) {
- SetPlanComplete();
- return true;
- } else {
- // We are still stepping, reset the start pc, and in case we've stepped
- // in or out, reset the current stack id.
- SetUpState();
- return false;
- }
- } else
+ if (--m_iteration_count <= 0) {
+ SetPlanComplete();
+ return true;
+ } else {
+ // We are still stepping, reset the start pc, and in case we've stepped
+ // in or out, reset the current stack id.
+ SetUpState();
return false;
+ }
+ return false;
}
}
Index: lldb/source/Target/ThreadPlanStepInstruction.cpp
===================================================================
--- lldb/source/Target/ThreadPlanStepInstruction.cpp
+++ lldb/source/Target/ThreadPlanStepInstruction.cpp
@@ -217,19 +217,16 @@
}
}
} else {
- lldb::addr_t pc_addr = thread.GetRegisterContext()->GetPC(0);
- if (pc_addr != m_instruction_addr) {
- if (--m_iteration_count <= 0) {
- SetPlanComplete();
- return true;
- } else {
- // We are still stepping, reset the start pc, and in case we've stepped
- // in or out, reset the current stack id.
- SetUpState();
- return false;
- }
- } else
+ if (--m_iteration_count <= 0) {
+ SetPlanComplete();
+ return true;
+ } else {
+ // We are still stepping, reset the start pc, and in case we've stepped
+ // in or out, reset the current stack id.
+ SetUpState();
return false;
+ }
+ return false;
}
}
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits