[Lldb-commits] [lldb] r252963 - Another little stepping optimization: if any of the source step commands are running through a range

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 12 14:32:09 PST 2015


Author: jingham
Date: Thu Nov 12 16:32:09 2015
New Revision: 252963

URL: http://llvm.org/viewvc/llvm-project?rev=252963&view=rev
Log:
Another little stepping optimization: if any of the source step commands are running through a range 
of addresses, and the range has no branches, instead of running to the last instruction and
single-stepping over that, run to the first instruction after the end of the range.  If there
are no branches in the current range, then the bytes right after it have to be in the current
function, and have to be instructions not data in code, so this is safe.  And it cuts down one
extra stepi per source range step.

Incidentally, this also works around a bug in the llvm Intel assembler where it treats the "rep" 
prefix as a separate instruction from the repeated instruction.  If that were at the end of a
line range, then we would put a trap in place of the repeated instruction, which is undefined
behavior.  Current processors just ignore the repetition in this case, which changes program behavior.
Since there would never be a line range break after the rep prefix, always doing the range stepping 
to the beginning of the new range avoids this problem.

<rdar://problem/23461686>

Modified:
    lldb/trunk/source/Target/ThreadPlanStepRange.cpp

Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepRange.cpp?rev=252963&r1=252962&r2=252963&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepRange.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepRange.cpp Thu Nov 12 16:32:09 2015
@@ -390,12 +390,19 @@ ThreadPlanStepRange::SetNextBranchBreakp
         if (branch_index == UINT32_MAX)
         {
             branch_index = instructions->GetSize() - 1;
+            InstructionSP last_inst = instructions->GetInstructionAtIndex(branch_index);
+            size_t last_inst_size = last_inst->GetOpcode().GetByteSize();
+            run_to_address = last_inst->GetAddress();
+            run_to_address.Slide(last_inst_size);
+        }
+        else if (branch_index - pc_index > 1)
+        {
+            run_to_address = instructions->GetInstructionAtIndex(branch_index)->GetAddress();
         }
         
-        if (branch_index - pc_index > 1)
+        if (run_to_address.IsValid())
         {
             const bool is_internal = true;
-            run_to_address = instructions->GetInstructionAtIndex(branch_index)->GetAddress();
             m_next_branch_bp_sp = GetTarget().CreateBreakpoint(run_to_address, is_internal, false);
             if (m_next_branch_bp_sp)
             {




More information about the lldb-commits mailing list