2010-06-09 00:52:24 +08:00
|
|
|
//===-- ThreadPlanStepOut.cpp -----------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
2015-12-15 09:33:19 +08:00
|
|
|
#include "lldb/Target/ThreadPlanStepOut.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Breakpoint/Breakpoint.h"
|
|
|
|
#include "lldb/Core/Log.h"
|
2011-12-17 09:35:57 +08:00
|
|
|
#include "lldb/Core/Value.h"
|
|
|
|
#include "lldb/Core/ValueObjectConstResult.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Symbol/Block.h"
|
|
|
|
#include "lldb/Symbol/Function.h"
|
2016-01-09 05:40:11 +08:00
|
|
|
#include "lldb/Symbol/Symbol.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Symbol/Type.h"
|
2015-03-04 03:23:09 +08:00
|
|
|
#include "lldb/Target/ABI.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2010-08-04 09:40:35 +08:00
|
|
|
#include "lldb/Target/StopInfo.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2011-10-15 08:57:28 +08:00
|
|
|
#include "lldb/Target/ThreadPlanStepOverRange.h"
|
2014-03-13 10:47:14 +08:00
|
|
|
#include "lldb/Target/ThreadPlanStepThrough.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2014-03-13 10:47:14 +08:00
|
|
|
uint32_t ThreadPlanStepOut::s_default_flag_values = 0;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// ThreadPlanStepOut: Step out of the current frame
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
ThreadPlanStepOut::ThreadPlanStepOut
|
|
|
|
(
|
|
|
|
Thread &thread,
|
|
|
|
SymbolContext *context,
|
|
|
|
bool first_insn,
|
|
|
|
bool stop_others,
|
|
|
|
Vote stop_vote,
|
2011-01-21 14:11:58 +08:00
|
|
|
Vote run_vote,
|
2014-03-13 10:47:14 +08:00
|
|
|
uint32_t frame_idx,
|
2016-01-09 05:40:11 +08:00
|
|
|
LazyBool step_out_avoids_code_without_debug_info,
|
|
|
|
bool continue_to_next_branch
|
2010-06-09 00:52:24 +08:00
|
|
|
) :
|
2010-06-19 12:45:32 +08:00
|
|
|
ThreadPlan (ThreadPlan::eKindStepOut, "Step out", thread, stop_vote, run_vote),
|
2014-03-13 10:47:14 +08:00
|
|
|
ThreadPlanShouldStopHere (this),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_step_from_insn (LLDB_INVALID_ADDRESS),
|
2010-07-16 20:32:33 +08:00
|
|
|
m_return_bp_id (LLDB_INVALID_BREAK_ID),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_return_addr (LLDB_INVALID_ADDRESS),
|
2011-10-15 08:57:28 +08:00
|
|
|
m_stop_others (stop_others),
|
2015-12-15 09:33:19 +08:00
|
|
|
m_immediate_step_from_function(nullptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2014-03-13 10:47:14 +08:00
|
|
|
SetFlagsToDefault();
|
|
|
|
SetupAvoidNoDebug(step_out_avoids_code_without_debug_info);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
m_step_from_insn = m_thread.GetRegisterContext()->GetPC(0);
|
|
|
|
|
2013-11-04 17:33:30 +08:00
|
|
|
StackFrameSP return_frame_sp (m_thread.GetStackFrameAtIndex(frame_idx + 1));
|
|
|
|
StackFrameSP immediate_return_from_sp (m_thread.GetStackFrameAtIndex (frame_idx));
|
2011-10-15 08:57:28 +08:00
|
|
|
|
2012-03-14 00:34:56 +08:00
|
|
|
if (!return_frame_sp || !immediate_return_from_sp)
|
|
|
|
return; // we can't do anything here. ValidatePlan() will return false.
|
|
|
|
|
2012-03-01 08:50:50 +08:00
|
|
|
m_step_out_to_id = return_frame_sp->GetStackID();
|
|
|
|
m_immediate_step_from_id = immediate_return_from_sp->GetStackID();
|
|
|
|
|
|
|
|
StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
|
2011-10-15 08:57:28 +08:00
|
|
|
|
|
|
|
// If the frame directly below the one we are returning to is inlined, we have to be
|
|
|
|
// a little more careful. It is non-trivial to determine the real "return code address" for
|
|
|
|
// an inlined frame, so we have to work our way to that frame and then step out.
|
|
|
|
if (immediate_return_from_sp && immediate_return_from_sp->IsInlined())
|
|
|
|
{
|
|
|
|
if (frame_idx > 0)
|
|
|
|
{
|
|
|
|
// First queue a plan that gets us to this inlined frame, and when we get there we'll queue a second
|
|
|
|
// plan that walks us out of this frame.
|
2015-12-15 09:33:19 +08:00
|
|
|
m_step_out_to_inline_plan_sp.reset(new ThreadPlanStepOut(m_thread,
|
|
|
|
nullptr,
|
|
|
|
false,
|
|
|
|
stop_others,
|
|
|
|
eVoteNoOpinion,
|
|
|
|
eVoteNoOpinion,
|
|
|
|
frame_idx - 1,
|
2016-01-09 05:40:11 +08:00
|
|
|
eLazyBoolNo,
|
|
|
|
continue_to_next_branch));
|
2014-03-13 10:47:14 +08:00
|
|
|
static_cast<ThreadPlanStepOut *>(m_step_out_to_inline_plan_sp.get())->SetShouldStopHereCallbacks(nullptr, nullptr);
|
2014-09-30 07:17:18 +08:00
|
|
|
m_step_out_to_inline_plan_sp->SetPrivate(true);
|
2011-10-15 08:57:28 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If we're already at the inlined frame we're stepping through, then just do that now.
|
|
|
|
QueueInlinedStepPlan(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (return_frame_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-10-15 08:57:28 +08:00
|
|
|
// Find the return address and set a breakpoint there:
|
|
|
|
// FIXME - can we do this more securely if we know first_insn?
|
|
|
|
|
2016-01-09 05:40:11 +08:00
|
|
|
Address return_address (return_frame_sp->GetFrameCodeAddress());
|
|
|
|
if (continue_to_next_branch)
|
|
|
|
{
|
|
|
|
SymbolContext return_address_sc;
|
|
|
|
AddressRange range;
|
|
|
|
Address return_address_decr_pc = return_address;
|
|
|
|
if (return_address_decr_pc.GetOffset() > 0)
|
|
|
|
return_address_decr_pc.Slide (-1);
|
|
|
|
|
|
|
|
return_address_decr_pc.CalculateSymbolContext (&return_address_sc, lldb::eSymbolContextLineEntry);
|
|
|
|
if (return_address_sc.line_entry.IsValid())
|
|
|
|
{
|
|
|
|
range = return_address_sc.line_entry.GetSameLineContiguousAddressRange();
|
|
|
|
if (range.GetByteSize() > 0)
|
|
|
|
{
|
|
|
|
return_address = m_thread.GetProcess()->AdvanceAddressToNextBranchInstruction (return_address,
|
|
|
|
range);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_return_addr = return_address.GetLoadAddress(&m_thread.GetProcess()->GetTarget());
|
2012-08-01 06:19:25 +08:00
|
|
|
|
|
|
|
if (m_return_addr == LLDB_INVALID_ADDRESS)
|
|
|
|
return;
|
|
|
|
|
2013-10-12 03:48:25 +08:00
|
|
|
Breakpoint *return_bp = m_thread.CalculateTarget()->CreateBreakpoint (m_return_addr, true, false).get();
|
2015-12-15 09:33:19 +08:00
|
|
|
if (return_bp != nullptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
return_bp->SetThreadID(m_thread.GetID());
|
|
|
|
m_return_bp_id = return_bp->GetID();
|
2013-01-26 10:19:28 +08:00
|
|
|
return_bp->SetBreakpointKind ("step-out");
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-12-17 09:35:57 +08:00
|
|
|
|
|
|
|
if (immediate_return_from_sp)
|
|
|
|
{
|
|
|
|
const SymbolContext &sc = immediate_return_from_sp->GetSymbolContext(eSymbolContextFunction);
|
|
|
|
if (sc.function)
|
|
|
|
{
|
|
|
|
m_immediate_step_from_function = sc.function;
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-10-15 08:57:28 +08:00
|
|
|
}
|
|
|
|
|
2014-03-13 10:47:14 +08:00
|
|
|
void
|
|
|
|
ThreadPlanStepOut::SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info)
|
|
|
|
{
|
|
|
|
bool avoid_nodebug = true;
|
|
|
|
switch (step_out_avoids_code_without_debug_info)
|
|
|
|
{
|
|
|
|
case eLazyBoolYes:
|
|
|
|
avoid_nodebug = true;
|
|
|
|
break;
|
|
|
|
case eLazyBoolNo:
|
|
|
|
avoid_nodebug = false;
|
|
|
|
break;
|
|
|
|
case eLazyBoolCalculate:
|
|
|
|
avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (avoid_nodebug)
|
|
|
|
GetFlags().Set (ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
|
|
|
|
else
|
|
|
|
GetFlags().Clear (ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
|
|
|
|
}
|
|
|
|
|
2011-10-15 08:57:28 +08:00
|
|
|
void
|
|
|
|
ThreadPlanStepOut::DidPush()
|
|
|
|
{
|
2014-03-13 10:47:14 +08:00
|
|
|
if (m_step_out_to_inline_plan_sp)
|
|
|
|
m_thread.QueueThreadPlan(m_step_out_to_inline_plan_sp, false);
|
2011-10-15 08:57:28 +08:00
|
|
|
else if (m_step_through_inline_plan_sp)
|
|
|
|
m_thread.QueueThreadPlan(m_step_through_inline_plan_sp, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ThreadPlanStepOut::~ThreadPlanStepOut ()
|
|
|
|
{
|
|
|
|
if (m_return_bp_id != LLDB_INVALID_BREAK_ID)
|
2012-02-21 08:09:25 +08:00
|
|
|
m_thread.CalculateTarget()->RemoveBreakpointByID(m_return_bp_id);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ThreadPlanStepOut::GetDescription (Stream *s, lldb::DescriptionLevel level)
|
|
|
|
{
|
|
|
|
if (level == lldb::eDescriptionLevelBrief)
|
|
|
|
s->Printf ("step out");
|
|
|
|
else
|
|
|
|
{
|
2014-03-13 10:47:14 +08:00
|
|
|
if (m_step_out_to_inline_plan_sp)
|
2012-03-01 08:50:50 +08:00
|
|
|
s->Printf ("Stepping out to inlined frame so we can walk through it.");
|
2011-10-15 08:57:28 +08:00
|
|
|
else if (m_step_through_inline_plan_sp)
|
|
|
|
s->Printf ("Stepping out by stepping through inlined function.");
|
|
|
|
else
|
2014-09-30 07:17:18 +08:00
|
|
|
{
|
|
|
|
s->Printf ("Stepping out from ");
|
|
|
|
Address tmp_address;
|
|
|
|
if (tmp_address.SetLoadAddress (m_step_from_insn, &GetTarget()))
|
|
|
|
{
|
|
|
|
tmp_address.Dump(s, &GetThread(), Address::DumpStyleResolvedDescription, Address::DumpStyleLoadAddress);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s->Printf ("address 0x%" PRIx64 "", (uint64_t)m_step_from_insn);
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: find some useful way to present the m_return_id, since there may be multiple copies of the
|
|
|
|
// same function on the stack.
|
|
|
|
|
2015-12-04 10:52:49 +08:00
|
|
|
s->Printf (" returning to frame at ");
|
2014-09-30 07:17:18 +08:00
|
|
|
if (tmp_address.SetLoadAddress (m_return_addr, &GetTarget()))
|
|
|
|
{
|
|
|
|
tmp_address.Dump(s, &GetThread(), Address::DumpStyleResolvedDescription, Address::DumpStyleLoadAddress);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s->Printf ("address 0x%" PRIx64 "", (uint64_t)m_return_addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (level == eDescriptionLevelVerbose)
|
|
|
|
s->Printf(" using breakpoint site %d", m_return_bp_id);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlanStepOut::ValidatePlan (Stream *error)
|
|
|
|
{
|
2014-03-13 10:47:14 +08:00
|
|
|
if (m_step_out_to_inline_plan_sp)
|
|
|
|
return m_step_out_to_inline_plan_sp->ValidatePlan (error);
|
2011-10-15 08:57:28 +08:00
|
|
|
else if (m_step_through_inline_plan_sp)
|
|
|
|
return m_step_through_inline_plan_sp->ValidatePlan (error);
|
|
|
|
else if (m_return_bp_id == LLDB_INVALID_BREAK_ID)
|
|
|
|
{
|
2012-08-01 06:19:25 +08:00
|
|
|
if (error)
|
|
|
|
error->PutCString("Could not create return address breakpoint.");
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
2011-10-15 08:57:28 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
Figure out the reply to "PlanExplainsStop" once when we stop and then use the cached
value. This fixes problems, for instance, with the StepRange plans, where they know that
they explained the stop because they were at their "run to here" breakpoint, then deleted
that breakpoint, so when they got asked again, doh! I had done this for a couple of plans
in an ad hoc fashion, this just formalizes it.
Also add a "ResumeRequested" in Process so that the code in the completion handlers can
tell the ShouldStop logic they want to resume rather than just directly resuming. That allows
us to handle resuming in a more controlled fashion.
Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when
the target was immediately restarted.
--This line, and those below , will be ignored--
M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
M include/lldb/Target/ThreadList.h
M include/lldb/Target/ThreadPlanStepOut.h
M include/lldb/Target/Thread.h
M include/lldb/Target/ThreadPlanBase.h
M include/lldb/Target/ThreadPlanStepThrough.h
M include/lldb/Target/ThreadPlanStepInstruction.h
M include/lldb/Target/ThreadPlanStepInRange.h
M include/lldb/Target/ThreadPlanStepOverBreakpoint.h
M include/lldb/Target/ThreadPlanStepUntil.h
M include/lldb/Target/StopInfo.h
M include/lldb/Target/Process.h
M include/lldb/Target/ThreadPlanRunToAddress.h
M include/lldb/Target/ThreadPlan.h
M include/lldb/Target/ThreadPlanCallFunction.h
M include/lldb/Target/ThreadPlanStepOverRange.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M source/Target/StopInfo.cpp
M source/Target/Process.cpp
M source/Target/ThreadPlanRunToAddress.cpp
M source/Target/ThreadPlan.cpp
M source/Target/ThreadPlanCallFunction.cpp
M source/Target/ThreadPlanStepOverRange.cpp
M source/Target/ThreadList.cpp
M source/Target/ThreadPlanStepOut.cpp
M source/Target/Thread.cpp
M source/Target/ThreadPlanBase.cpp
M source/Target/ThreadPlanStepThrough.cpp
M source/Target/ThreadPlanStepInstruction.cpp
M source/Target/ThreadPlanStepInRange.cpp
M source/Target/ThreadPlanStepOverBreakpoint.cpp
M source/Target/ThreadPlanStepUntil.cpp
M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme
llvm-svn: 181381
2013-05-08 08:35:16 +08:00
|
|
|
ThreadPlanStepOut::DoPlanExplainsStop (Event *event_ptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2014-03-13 10:47:14 +08:00
|
|
|
// If the step out plan is done, then we just need to step through the inlined frame.
|
|
|
|
if (m_step_out_to_inline_plan_sp)
|
2011-10-15 08:57:28 +08:00
|
|
|
{
|
2015-12-15 09:33:19 +08:00
|
|
|
return m_step_out_to_inline_plan_sp->MischiefManaged();
|
2014-03-13 10:47:14 +08:00
|
|
|
}
|
|
|
|
else if (m_step_through_inline_plan_sp)
|
|
|
|
{
|
|
|
|
if (m_step_through_inline_plan_sp->MischiefManaged())
|
2011-10-15 08:57:28 +08:00
|
|
|
{
|
2011-12-17 09:35:57 +08:00
|
|
|
CalculateReturnValue();
|
2011-10-15 08:57:28 +08:00
|
|
|
SetPlanComplete();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2014-03-13 10:47:14 +08:00
|
|
|
else if (m_step_out_further_plan_sp)
|
2011-10-15 08:57:28 +08:00
|
|
|
{
|
2015-12-15 09:33:19 +08:00
|
|
|
return m_step_out_further_plan_sp->MischiefManaged();
|
2011-10-15 08:57:28 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// We don't explain signals or breakpoints (breakpoints that handle stepping in or
|
|
|
|
// out will be handled by a child plan.
|
2011-10-15 08:57:28 +08:00
|
|
|
|
2013-06-04 09:40:51 +08:00
|
|
|
StopInfoSP stop_info_sp = GetPrivateStopInfo ();
|
2010-10-20 08:39:53 +08:00
|
|
|
if (stop_info_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-10-20 08:39:53 +08:00
|
|
|
StopReason reason = stop_info_sp->GetStopReason();
|
2015-07-24 03:55:02 +08:00
|
|
|
if (reason == eStopReasonBreakpoint)
|
2010-08-04 09:40:35 +08:00
|
|
|
{
|
|
|
|
// If this is OUR breakpoint, we're fine, otherwise we don't know why this happened...
|
2012-02-21 08:09:25 +08:00
|
|
|
BreakpointSiteSP site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByID (stop_info_sp->GetValue()));
|
2010-08-04 09:40:35 +08:00
|
|
|
if (site_sp && site_sp->IsBreakpointAtThisSite (m_return_bp_id))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-03-01 08:50:50 +08:00
|
|
|
bool done;
|
|
|
|
|
|
|
|
StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
|
|
|
|
|
|
|
|
if (m_step_out_to_id == frame_zero_id)
|
|
|
|
done = true;
|
|
|
|
else if (m_step_out_to_id < frame_zero_id)
|
|
|
|
{
|
|
|
|
// Either we stepped past the breakpoint, or the stack ID calculation
|
|
|
|
// was incorrect and we should probably stop.
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-15 09:33:19 +08:00
|
|
|
done = (m_immediate_step_from_id < frame_zero_id);
|
2012-03-01 08:50:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (done)
|
2011-12-17 09:35:57 +08:00
|
|
|
{
|
2014-03-13 10:47:14 +08:00
|
|
|
if (InvokeShouldStopHereCallback (eFrameCompareOlder))
|
|
|
|
{
|
|
|
|
CalculateReturnValue();
|
|
|
|
SetPlanComplete();
|
|
|
|
}
|
2011-12-17 09:35:57 +08:00
|
|
|
}
|
2011-01-21 14:11:58 +08:00
|
|
|
|
2010-08-04 09:40:35 +08:00
|
|
|
// If there was only one owner, then we're done. But if we also hit some
|
|
|
|
// user breakpoint on our way out, we should mark ourselves as done, but
|
|
|
|
// also not claim to explain the stop, since it is more important to report
|
|
|
|
// the user breakpoint than the step out completion.
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-08-04 09:40:35 +08:00
|
|
|
if (site_sp->GetNumberOfOwners() == 1)
|
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-08-04 09:40:35 +08:00
|
|
|
return false;
|
|
|
|
}
|
2015-07-24 03:55:02 +08:00
|
|
|
else if (IsUsuallyUnexplainedStopReason(reason))
|
2010-08-04 09:40:35 +08:00
|
|
|
return false;
|
2015-07-24 03:55:02 +08:00
|
|
|
else
|
2010-08-04 09:40:35 +08:00
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlanStepOut::ShouldStop (Event *event_ptr)
|
|
|
|
{
|
2014-03-13 10:47:14 +08:00
|
|
|
if (IsPlanComplete())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
bool done = false;
|
|
|
|
if (m_step_out_to_inline_plan_sp)
|
|
|
|
{
|
|
|
|
if (m_step_out_to_inline_plan_sp->MischiefManaged())
|
|
|
|
{
|
|
|
|
// Now step through the inlined stack we are in:
|
|
|
|
if (QueueInlinedStepPlan(true))
|
|
|
|
{
|
|
|
|
// If we can't queue a plan to do this, then just call ourselves done.
|
|
|
|
m_step_out_to_inline_plan_sp.reset();
|
|
|
|
SetPlanComplete (false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return m_step_out_to_inline_plan_sp->ShouldStop(event_ptr);
|
|
|
|
}
|
|
|
|
else if (m_step_through_inline_plan_sp)
|
|
|
|
{
|
|
|
|
if (m_step_through_inline_plan_sp->MischiefManaged())
|
|
|
|
done = true;
|
|
|
|
else
|
|
|
|
return m_step_through_inline_plan_sp->ShouldStop(event_ptr);
|
|
|
|
}
|
|
|
|
else if (m_step_out_further_plan_sp)
|
|
|
|
{
|
|
|
|
if (m_step_out_further_plan_sp->MischiefManaged())
|
|
|
|
m_step_out_further_plan_sp.reset();
|
|
|
|
else
|
|
|
|
return m_step_out_further_plan_sp->ShouldStop(event_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!done)
|
|
|
|
{
|
2012-03-01 08:50:50 +08:00
|
|
|
StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
|
2015-12-15 09:33:19 +08:00
|
|
|
done = !(frame_zero_id < m_step_out_to_id);
|
2014-03-13 10:47:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// The normal step out computations think we are done, so all we need to do is consult the ShouldStopHere,
|
|
|
|
// and we are done.
|
|
|
|
|
|
|
|
if (done)
|
|
|
|
{
|
|
|
|
if (InvokeShouldStopHereCallback(eFrameCompareOlder))
|
2011-10-15 08:57:28 +08:00
|
|
|
{
|
2011-12-17 09:35:57 +08:00
|
|
|
CalculateReturnValue();
|
2011-10-15 08:57:28 +08:00
|
|
|
SetPlanComplete();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-13 10:47:14 +08:00
|
|
|
m_step_out_further_plan_sp = QueueStepOutFromHerePlan(m_flags, eFrameCompareOlder);
|
|
|
|
done = false;
|
2011-10-15 08:57:28 +08:00
|
|
|
}
|
2014-03-13 10:47:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return done;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlanStepOut::StopOthers ()
|
|
|
|
{
|
|
|
|
return m_stop_others;
|
|
|
|
}
|
|
|
|
|
|
|
|
StateType
|
2010-11-12 03:26:09 +08:00
|
|
|
ThreadPlanStepOut::GetPlanRunState ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
return eStateRunning;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
Figure out the reply to "PlanExplainsStop" once when we stop and then use the cached
value. This fixes problems, for instance, with the StepRange plans, where they know that
they explained the stop because they were at their "run to here" breakpoint, then deleted
that breakpoint, so when they got asked again, doh! I had done this for a couple of plans
in an ad hoc fashion, this just formalizes it.
Also add a "ResumeRequested" in Process so that the code in the completion handlers can
tell the ShouldStop logic they want to resume rather than just directly resuming. That allows
us to handle resuming in a more controlled fashion.
Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when
the target was immediately restarted.
--This line, and those below , will be ignored--
M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py
M include/lldb/Target/ThreadList.h
M include/lldb/Target/ThreadPlanStepOut.h
M include/lldb/Target/Thread.h
M include/lldb/Target/ThreadPlanBase.h
M include/lldb/Target/ThreadPlanStepThrough.h
M include/lldb/Target/ThreadPlanStepInstruction.h
M include/lldb/Target/ThreadPlanStepInRange.h
M include/lldb/Target/ThreadPlanStepOverBreakpoint.h
M include/lldb/Target/ThreadPlanStepUntil.h
M include/lldb/Target/StopInfo.h
M include/lldb/Target/Process.h
M include/lldb/Target/ThreadPlanRunToAddress.h
M include/lldb/Target/ThreadPlan.h
M include/lldb/Target/ThreadPlanCallFunction.h
M include/lldb/Target/ThreadPlanStepOverRange.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
M source/Target/StopInfo.cpp
M source/Target/Process.cpp
M source/Target/ThreadPlanRunToAddress.cpp
M source/Target/ThreadPlan.cpp
M source/Target/ThreadPlanCallFunction.cpp
M source/Target/ThreadPlanStepOverRange.cpp
M source/Target/ThreadList.cpp
M source/Target/ThreadPlanStepOut.cpp
M source/Target/Thread.cpp
M source/Target/ThreadPlanBase.cpp
M source/Target/ThreadPlanStepThrough.cpp
M source/Target/ThreadPlanStepInstruction.cpp
M source/Target/ThreadPlanStepInRange.cpp
M source/Target/ThreadPlanStepOverBreakpoint.cpp
M source/Target/ThreadPlanStepUntil.cpp
M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme
llvm-svn: 181381
2013-05-08 08:35:16 +08:00
|
|
|
ThreadPlanStepOut::DoWillResume (StateType resume_state, bool current_plan)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2014-03-13 10:47:14 +08:00
|
|
|
if (m_step_out_to_inline_plan_sp || m_step_through_inline_plan_sp)
|
2011-10-15 08:57:28 +08:00
|
|
|
return true;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (m_return_bp_id == LLDB_INVALID_BREAK_ID)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (current_plan)
|
|
|
|
{
|
2012-02-21 08:09:25 +08:00
|
|
|
Breakpoint *return_bp = m_thread.CalculateTarget()->GetBreakpointByID(m_return_bp_id).get();
|
2015-12-15 09:33:19 +08:00
|
|
|
if (return_bp != nullptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
return_bp->SetEnabled (true);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlanStepOut::WillStop ()
|
|
|
|
{
|
2011-10-15 08:57:28 +08:00
|
|
|
if (m_return_bp_id != LLDB_INVALID_BREAK_ID)
|
|
|
|
{
|
2012-02-21 08:09:25 +08:00
|
|
|
Breakpoint *return_bp = m_thread.CalculateTarget()->GetBreakpointByID(m_return_bp_id).get();
|
2015-12-15 09:33:19 +08:00
|
|
|
if (return_bp != nullptr)
|
2011-10-15 08:57:28 +08:00
|
|
|
return_bp->SetEnabled (false);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlanStepOut::MischiefManaged ()
|
|
|
|
{
|
2011-10-15 08:57:28 +08:00
|
|
|
if (IsPlanComplete())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// Did I reach my breakpoint? If so I'm done.
|
|
|
|
//
|
|
|
|
// I also check the stack depth, since if we've blown past the breakpoint for some
|
|
|
|
// reason and we're now stopping for some other reason altogether, then we're done
|
|
|
|
// with this step out operation.
|
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
2010-06-09 00:52:24 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("Completed step out plan.");
|
2011-10-15 08:57:28 +08:00
|
|
|
if (m_return_bp_id != LLDB_INVALID_BREAK_ID)
|
|
|
|
{
|
2012-02-21 08:09:25 +08:00
|
|
|
m_thread.CalculateTarget()->RemoveBreakpointByID (m_return_bp_id);
|
2011-10-15 08:57:28 +08:00
|
|
|
m_return_bp_id = LLDB_INVALID_BREAK_ID;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
ThreadPlan::MischiefManaged ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-15 08:57:28 +08:00
|
|
|
bool
|
|
|
|
ThreadPlanStepOut::QueueInlinedStepPlan (bool queue_now)
|
|
|
|
{
|
|
|
|
// Now figure out the range of this inlined block, and set up a "step through range"
|
|
|
|
// plan for that. If we've been provided with a context, then use the block in that
|
|
|
|
// context.
|
2013-11-04 17:33:30 +08:00
|
|
|
StackFrameSP immediate_return_from_sp (m_thread.GetStackFrameAtIndex (0));
|
2011-10-15 08:57:28 +08:00
|
|
|
if (!immediate_return_from_sp)
|
|
|
|
return false;
|
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
|
2011-10-15 08:57:28 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
StreamString s;
|
|
|
|
immediate_return_from_sp->Dump(&s, true, false);
|
|
|
|
log->Printf("Queuing inlined frame to step past: %s.", s.GetData());
|
|
|
|
}
|
|
|
|
|
|
|
|
Block *from_block = immediate_return_from_sp->GetFrameBlock();
|
|
|
|
if (from_block)
|
|
|
|
{
|
|
|
|
Block *inlined_block = from_block->GetContainingInlinedBlock();
|
|
|
|
if (inlined_block)
|
|
|
|
{
|
|
|
|
size_t num_ranges = inlined_block->GetNumRanges();
|
|
|
|
AddressRange inline_range;
|
|
|
|
if (inlined_block->GetRangeAtIndex(0, inline_range))
|
|
|
|
{
|
|
|
|
SymbolContext inlined_sc;
|
|
|
|
inlined_block->CalculateSymbolContext(&inlined_sc);
|
2012-07-27 02:23:21 +08:00
|
|
|
inlined_sc.target_sp = GetTarget().shared_from_this();
|
2011-10-15 08:57:28 +08:00
|
|
|
RunMode run_mode = m_stop_others ? lldb::eOnlyThisThread : lldb::eAllThreads;
|
2014-03-13 10:47:14 +08:00
|
|
|
const LazyBool avoid_no_debug = eLazyBoolNo;
|
2014-09-30 07:17:18 +08:00
|
|
|
|
|
|
|
m_step_through_inline_plan_sp.reset (new ThreadPlanStepOverRange(m_thread,
|
|
|
|
inline_range,
|
|
|
|
inlined_sc,
|
|
|
|
run_mode,
|
|
|
|
avoid_no_debug));
|
|
|
|
ThreadPlanStepOverRange *step_through_inline_plan_ptr
|
|
|
|
= static_cast<ThreadPlanStepOverRange *>(m_step_through_inline_plan_sp.get());
|
|
|
|
m_step_through_inline_plan_sp->SetPrivate(true);
|
|
|
|
|
2011-10-15 08:57:28 +08:00
|
|
|
step_through_inline_plan_ptr->SetOkayToDiscard(true);
|
|
|
|
StreamString errors;
|
|
|
|
if (!step_through_inline_plan_ptr->ValidatePlan(&errors))
|
|
|
|
{
|
|
|
|
//FIXME: Log this failure.
|
|
|
|
delete step_through_inline_plan_ptr;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 1; i < num_ranges; i++)
|
|
|
|
{
|
|
|
|
if (inlined_block->GetRangeAtIndex (i, inline_range))
|
|
|
|
step_through_inline_plan_ptr->AddRange (inline_range);
|
|
|
|
}
|
2014-09-30 07:17:18 +08:00
|
|
|
|
2011-10-15 08:57:28 +08:00
|
|
|
if (queue_now)
|
|
|
|
m_thread.QueueThreadPlan (m_step_through_inline_plan_sp, false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2011-12-17 09:35:57 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
ThreadPlanStepOut::CalculateReturnValue ()
|
|
|
|
{
|
|
|
|
if (m_return_valobj_sp)
|
|
|
|
return;
|
|
|
|
|
2015-12-15 09:33:19 +08:00
|
|
|
if (m_immediate_step_from_function != nullptr)
|
2011-12-17 09:35:57 +08:00
|
|
|
{
|
2015-09-24 11:54:50 +08:00
|
|
|
CompilerType return_compiler_type = m_immediate_step_from_function->GetCompilerType().GetFunctionReturnType();
|
|
|
|
if (return_compiler_type)
|
2011-12-17 09:35:57 +08:00
|
|
|
{
|
2012-02-21 08:09:25 +08:00
|
|
|
lldb::ABISP abi_sp = m_thread.GetProcess()->GetABI();
|
2011-12-17 09:35:57 +08:00
|
|
|
if (abi_sp)
|
2015-09-24 11:54:50 +08:00
|
|
|
m_return_valobj_sp = abi_sp->GetReturnValueObject(m_thread, return_compiler_type);
|
2011-12-17 09:35:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-04 05:19:36 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
ThreadPlanStepOut::IsPlanStale()
|
|
|
|
{
|
|
|
|
// If we are still lower on the stack than the frame we are returning to, then
|
|
|
|
// there's something for us to do. Otherwise, we're stale.
|
|
|
|
|
|
|
|
StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
|
2015-12-15 09:33:19 +08:00
|
|
|
return !(frame_zero_id < m_step_out_to_id);
|
2012-05-04 05:19:36 +08:00
|
|
|
}
|