[Lldb-commits] [PATCH] D15708: Advance the return-address breakpoint location to the end of the next source line, or the next branching instruction, when stepping over a func call

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 21 19:59:26 PST 2015


jasonmolenda created this revision.
jasonmolenda added a reviewer: jingham.
jasonmolenda added a subscriber: lldb-commits.
jasonmolenda set the repository for this revision to rL LLVM.
Herald added a subscriber: aemerson.

When lldb is instruction stepping (or fast-stepping / instruction stepping) over a source line, and it instruction steps into a function call, and the function is not "interesting" to the user, lldb sets a breakpoint on the return address and continues the process until that breakpoint is hit on the current thread.

lldb has a fast-stepping approach to avoid stopping at every instruction in a source line range - it only stops on instructions that can branch / return / call functions.

So we have one extra stop when nexting over a function call.  We step into the uninteresting-function, put a breakpoint on the return address, continue, hit the breakpoint on the return address and then we fast-step to the next branch instruction.  That was four extra gdb-remote protocol packets for every function call in a source line.  

This patch advances the stop breakpoint to the first branching instruction after we return, or to the end of the source line.

It passes the testsuite.  I'll be doing more by-hand testing in the following week or two when I have time, but it's a straightforward change, it shouldn't cause problems unless I've missed something.  I added the new Process::AdvanceAddressToNextBranchInstruction() method but I'm only calling it from ThreadPlanStepOut::ThreadPlanStepOut.  I thought I'd be able to unify this new function with the code in ThreadPlanStepRange::SetNextBranchBreakpoint but I don't think the few lines I could remove from ThreadPlanStepRange::SetNextBranchBreakpoint would be worth the change.  Jim might disagree with that.

The one point where this would be incorrect is a command like "finish" which displays the return value after the function exits.  On an architecture where the return values are passed in volatile registers (x86, arm), that register may be overwritten after the function return so we must stop on the return address.

Repository:
  rL LLVM

http://reviews.llvm.org/D15708

Files:
  include/lldb/Target/Process.h
  include/lldb/Target/Thread.h
  include/lldb/Target/ThreadPlanStepOut.h
  source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
  source/Target/Process.cpp
  source/Target/Thread.cpp
  source/Target/ThreadPlanShouldStopHere.cpp
  source/Target/ThreadPlanStepInstruction.cpp
  source/Target/ThreadPlanStepOut.cpp
  source/Target/ThreadPlanStepOverRange.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15708.43428.patch
Type: text/x-patch
Size: 15471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151222/d2a720d7/attachment-0001.bin>


More information about the lldb-commits mailing list