[Lldb-commits] [PATCH] D81810: LLDB step-instruction gets stuck on jump to self
Sebastian Ă–sterlund via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sun Jun 14 11:12:52 PDT 2020
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;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81810.270631.patch
Type: text/x-patch
Size: 996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200614/1c122500/attachment.bin>
More information about the lldb-commits
mailing list