1ac7ddfbfSEd Maste //===-- ThreadPlanStepOverRange.cpp -----------------------------*- C++ -*-===//
2ac7ddfbfSEd Maste //
3ac7ddfbfSEd Maste // The LLVM Compiler Infrastructure
4ac7ddfbfSEd Maste //
5ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source
6ac7ddfbfSEd Maste // License. See LICENSE.TXT for details.
7ac7ddfbfSEd Maste //
8ac7ddfbfSEd Maste //===----------------------------------------------------------------------===//
9ac7ddfbfSEd Maste
109f2f44ceSEd Maste #include "lldb/Target/ThreadPlanStepOverRange.h"
11ac7ddfbfSEd Maste #include "lldb/Symbol/Block.h"
12ac7ddfbfSEd Maste #include "lldb/Symbol/CompileUnit.h"
13ac7ddfbfSEd Maste #include "lldb/Symbol/Function.h"
14ac7ddfbfSEd Maste #include "lldb/Symbol/LineTable.h"
15ac7ddfbfSEd Maste #include "lldb/Target/Process.h"
16ac7ddfbfSEd Maste #include "lldb/Target/RegisterContext.h"
17ac7ddfbfSEd Maste #include "lldb/Target/Target.h"
18ac7ddfbfSEd Maste #include "lldb/Target/Thread.h"
19ac7ddfbfSEd Maste #include "lldb/Target/ThreadPlanStepOut.h"
20ac7ddfbfSEd Maste #include "lldb/Target/ThreadPlanStepThrough.h"
21f678e45dSDimitry Andric #include "lldb/Utility/Log.h"
22f678e45dSDimitry Andric #include "lldb/Utility/Stream.h"
23ac7ddfbfSEd Maste
24ac7ddfbfSEd Maste using namespace lldb_private;
25ac7ddfbfSEd Maste using namespace lldb;
26ac7ddfbfSEd Maste
270127ef0fSEd Maste uint32_t ThreadPlanStepOverRange::s_default_flag_values = 0;
28ac7ddfbfSEd Maste
29ac7ddfbfSEd Maste //----------------------------------------------------------------------
30435933ddSDimitry Andric // ThreadPlanStepOverRange: Step through a stack range, either stepping over or
314ba319b5SDimitry Andric // into based on the value of \a type.
32ac7ddfbfSEd Maste //----------------------------------------------------------------------
33ac7ddfbfSEd Maste
ThreadPlanStepOverRange(Thread & thread,const AddressRange & range,const SymbolContext & addr_context,lldb::RunMode stop_others,LazyBool step_out_avoids_code_without_debug_info)34435933ddSDimitry Andric ThreadPlanStepOverRange::ThreadPlanStepOverRange(
35435933ddSDimitry Andric Thread &thread, const AddressRange &range,
36435933ddSDimitry Andric const SymbolContext &addr_context, lldb::RunMode stop_others,
37435933ddSDimitry Andric LazyBool step_out_avoids_code_without_debug_info)
38435933ddSDimitry Andric : ThreadPlanStepRange(ThreadPlan::eKindStepOverRange,
39435933ddSDimitry Andric "Step range stepping over", thread, range,
40435933ddSDimitry Andric addr_context, stop_others),
41435933ddSDimitry Andric ThreadPlanShouldStopHere(this), m_first_resume(true) {
420127ef0fSEd Maste SetFlagsToDefault();
430127ef0fSEd Maste SetupAvoidNoDebug(step_out_avoids_code_without_debug_info);
44ac7ddfbfSEd Maste }
45ac7ddfbfSEd Maste
469f2f44ceSEd Maste ThreadPlanStepOverRange::~ThreadPlanStepOverRange() = default;
47ac7ddfbfSEd Maste
GetDescription(Stream * s,lldb::DescriptionLevel level)48435933ddSDimitry Andric void ThreadPlanStepOverRange::GetDescription(Stream *s,
49435933ddSDimitry Andric lldb::DescriptionLevel level) {
50*b5893f02SDimitry Andric auto PrintFailureIfAny = [&]() {
51*b5893f02SDimitry Andric if (m_status.Success())
52*b5893f02SDimitry Andric return;
53*b5893f02SDimitry Andric s->Printf(" failed (%s)", m_status.AsCString());
54*b5893f02SDimitry Andric };
55*b5893f02SDimitry Andric
56435933ddSDimitry Andric if (level == lldb::eDescriptionLevelBrief) {
577aa51b79SEd Maste s->Printf("step over");
58*b5893f02SDimitry Andric PrintFailureIfAny();
597aa51b79SEd Maste return;
607aa51b79SEd Maste }
61*b5893f02SDimitry Andric
627aa51b79SEd Maste s->Printf("Stepping over");
637aa51b79SEd Maste bool printed_line_info = false;
64435933ddSDimitry Andric if (m_addr_context.line_entry.IsValid()) {
657aa51b79SEd Maste s->Printf(" line ");
667aa51b79SEd Maste m_addr_context.line_entry.DumpStopContext(s, false);
677aa51b79SEd Maste printed_line_info = true;
687aa51b79SEd Maste }
697aa51b79SEd Maste
70435933ddSDimitry Andric if (!printed_line_info || level == eDescriptionLevelVerbose) {
717aa51b79SEd Maste s->Printf(" using ranges: ");
72ac7ddfbfSEd Maste DumpRanges(s);
73ac7ddfbfSEd Maste }
747aa51b79SEd Maste
75*b5893f02SDimitry Andric PrintFailureIfAny();
76*b5893f02SDimitry Andric
777aa51b79SEd Maste s->PutChar('.');
78ac7ddfbfSEd Maste }
79ac7ddfbfSEd Maste
SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info)80435933ddSDimitry Andric void ThreadPlanStepOverRange::SetupAvoidNoDebug(
81435933ddSDimitry Andric LazyBool step_out_avoids_code_without_debug_info) {
820127ef0fSEd Maste bool avoid_nodebug = true;
83435933ddSDimitry Andric switch (step_out_avoids_code_without_debug_info) {
840127ef0fSEd Maste case eLazyBoolYes:
850127ef0fSEd Maste avoid_nodebug = true;
860127ef0fSEd Maste break;
870127ef0fSEd Maste case eLazyBoolNo:
880127ef0fSEd Maste avoid_nodebug = false;
890127ef0fSEd Maste break;
900127ef0fSEd Maste case eLazyBoolCalculate:
910127ef0fSEd Maste avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug();
920127ef0fSEd Maste break;
930127ef0fSEd Maste }
940127ef0fSEd Maste if (avoid_nodebug)
950127ef0fSEd Maste GetFlags().Set(ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
960127ef0fSEd Maste else
970127ef0fSEd Maste GetFlags().Clear(ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
98435933ddSDimitry Andric // Step Over plans should always avoid no-debug on step in. Seems like you
994ba319b5SDimitry Andric // shouldn't have to say this, but a tail call looks more like a step in that
1004ba319b5SDimitry Andric // a step out, so we want to catch this case.
1010127ef0fSEd Maste GetFlags().Set(ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
1020127ef0fSEd Maste }
1030127ef0fSEd Maste
IsEquivalentContext(const SymbolContext & context)104435933ddSDimitry Andric bool ThreadPlanStepOverRange::IsEquivalentContext(
105435933ddSDimitry Andric const SymbolContext &context) {
1064ba319b5SDimitry Andric // Match as much as is specified in the m_addr_context: This is a fairly
1074ba319b5SDimitry Andric // loose sanity check. Note, sometimes the target doesn't get filled in so I
1084ba319b5SDimitry Andric // left out the target check. And sometimes the module comes in as the .o
1094ba319b5SDimitry Andric // file from the inlined range, so I left that out too...
110435933ddSDimitry Andric if (m_addr_context.comp_unit) {
111435933ddSDimitry Andric if (m_addr_context.comp_unit != context.comp_unit)
112435933ddSDimitry Andric return false;
113435933ddSDimitry Andric if (m_addr_context.function) {
114435933ddSDimitry Andric if (m_addr_context.function != context.function)
115435933ddSDimitry Andric return false;
116435933ddSDimitry Andric // It is okay to return to a different block of a straight function, we
1174ba319b5SDimitry Andric // only have to be more careful if returning from one inlined block to
1184ba319b5SDimitry Andric // another.
119435933ddSDimitry Andric if (m_addr_context.block->GetInlinedFunctionInfo() == nullptr &&
120435933ddSDimitry Andric context.block->GetInlinedFunctionInfo() == nullptr)
12135617911SEd Maste return true;
122435933ddSDimitry Andric return m_addr_context.block == context.block;
12335617911SEd Maste }
12435617911SEd Maste }
125435933ddSDimitry Andric // Fall back to symbol if we have no decision from comp_unit/function/block.
126*b5893f02SDimitry Andric return m_addr_context.symbol && m_addr_context.symbol == context.symbol;
12735617911SEd Maste }
12835617911SEd Maste
ShouldStop(Event * event_ptr)129435933ddSDimitry Andric bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
130ac7ddfbfSEd Maste Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
131ac7ddfbfSEd Maste
132435933ddSDimitry Andric if (log) {
133ac7ddfbfSEd Maste StreamString s;
134435933ddSDimitry Andric s.Address(
135435933ddSDimitry Andric m_thread.GetRegisterContext()->GetPC(),
136ac7ddfbfSEd Maste m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
137ac7ddfbfSEd Maste log->Printf("ThreadPlanStepOverRange reached %s.", s.GetData());
138ac7ddfbfSEd Maste }
139ac7ddfbfSEd Maste
140ac7ddfbfSEd Maste // If we're out of the range but in the same frame or in our caller's frame
1414ba319b5SDimitry Andric // then we should stop. When stepping out we only stop others if we are
1424ba319b5SDimitry Andric // forcing running one thread.
1439f2f44ceSEd Maste bool stop_others = (m_stop_others == lldb::eOnlyThisThread);
144ac7ddfbfSEd Maste ThreadPlanSP new_plan_sp;
145ac7ddfbfSEd Maste FrameComparison frame_order = CompareCurrentFrameToStartFrame();
146ac7ddfbfSEd Maste
147435933ddSDimitry Andric if (frame_order == eFrameCompareOlder) {
148ac7ddfbfSEd Maste // If we're in an older frame then we should stop.
149ac7ddfbfSEd Maste //
150435933ddSDimitry Andric // A caveat to this is if we think the frame is older but we're actually in
151435933ddSDimitry Andric // a trampoline.
152435933ddSDimitry Andric // I'm going to make the assumption that you wouldn't RETURN to a
1534ba319b5SDimitry Andric // trampoline. So if we are in a trampoline we think the frame is older
1544ba319b5SDimitry Andric // because the trampoline confused the backtracer. As below, we step
1554ba319b5SDimitry Andric // through first, and then try to figure out how to get back out again.
156ac7ddfbfSEd Maste
157*b5893f02SDimitry Andric new_plan_sp = m_thread.QueueThreadPlanForStepThrough(m_stack_id, false,
158*b5893f02SDimitry Andric stop_others, m_status);
159ac7ddfbfSEd Maste
160ac7ddfbfSEd Maste if (new_plan_sp && log)
161435933ddSDimitry Andric log->Printf(
162435933ddSDimitry Andric "Thought I stepped out, but in fact arrived at a trampoline.");
163435933ddSDimitry Andric } else if (frame_order == eFrameCompareYounger) {
164435933ddSDimitry Andric // Make sure we really are in a new frame. Do that by unwinding and seeing
1654ba319b5SDimitry Andric // if the start function really is our start function...
166435933ddSDimitry Andric for (uint32_t i = 1;; ++i) {
16735617911SEd Maste StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(i);
16835617911SEd Maste if (!older_frame_sp) {
169435933ddSDimitry Andric // We can't unwind the next frame we should just get out of here &
170435933ddSDimitry Andric // stop...
17135617911SEd Maste break;
17235617911SEd Maste }
17335617911SEd Maste
174435933ddSDimitry Andric const SymbolContext &older_context =
175435933ddSDimitry Andric older_frame_sp->GetSymbolContext(eSymbolContextEverything);
176435933ddSDimitry Andric if (IsEquivalentContext(older_context)) {
177435933ddSDimitry Andric new_plan_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop(
178435933ddSDimitry Andric false, nullptr, true, stop_others, eVoteNo, eVoteNoOpinion, 0,
179*b5893f02SDimitry Andric m_status, true);
18035617911SEd Maste break;
181435933ddSDimitry Andric } else {
182*b5893f02SDimitry Andric new_plan_sp = m_thread.QueueThreadPlanForStepThrough(
183*b5893f02SDimitry Andric m_stack_id, false, stop_others, m_status);
1840127ef0fSEd Maste // If we found a way through, then we should stop recursing.
1850127ef0fSEd Maste if (new_plan_sp)
1860127ef0fSEd Maste break;
187ac7ddfbfSEd Maste }
188ac7ddfbfSEd Maste }
189435933ddSDimitry Andric } else {
190ac7ddfbfSEd Maste // If we're still in the range, keep going.
191435933ddSDimitry Andric if (InRange()) {
192ac7ddfbfSEd Maste SetNextBranchBreakpoint();
193ac7ddfbfSEd Maste return false;
194ac7ddfbfSEd Maste }
195ac7ddfbfSEd Maste
196435933ddSDimitry Andric if (!InSymbol()) {
197435933ddSDimitry Andric // This one is a little tricky. Sometimes we may be in a stub or
1984ba319b5SDimitry Andric // something similar, in which case we need to get out of there. But if
1994ba319b5SDimitry Andric // we are in a stub then it's likely going to be hard to get out from
2004ba319b5SDimitry Andric // here. It is probably easiest to step into the stub, and then it will
2014ba319b5SDimitry Andric // be straight-forward to step out.
202*b5893f02SDimitry Andric new_plan_sp = m_thread.QueueThreadPlanForStepThrough(
203*b5893f02SDimitry Andric m_stack_id, false, stop_others, m_status);
204435933ddSDimitry Andric } else {
2054ba319b5SDimitry Andric // The current clang (at least through 424) doesn't always get the
2064ba319b5SDimitry Andric // address range for the DW_TAG_inlined_subroutines right, so that when
2074ba319b5SDimitry Andric // you leave the inlined range the line table says you are still in the
2084ba319b5SDimitry Andric // source file of the inlining function. This is bad, because now you
2094ba319b5SDimitry Andric // are missing the stack frame for the function containing the inlining,
2104ba319b5SDimitry Andric // and if you sensibly do "finish" to get out of this function you will
2114ba319b5SDimitry Andric // instead exit the containing function. To work around this, we check
2124ba319b5SDimitry Andric // whether we are still in the source file we started in, and if not
2134ba319b5SDimitry Andric // assume it is an error, and push a plan to get us out of this line and
2144ba319b5SDimitry Andric // back to the containing file.
215ac7ddfbfSEd Maste
216435933ddSDimitry Andric if (m_addr_context.line_entry.IsValid()) {
217ac7ddfbfSEd Maste SymbolContext sc;
218ac7ddfbfSEd Maste StackFrameSP frame_sp = m_thread.GetStackFrameAtIndex(0);
219ac7ddfbfSEd Maste sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
220435933ddSDimitry Andric if (sc.line_entry.IsValid()) {
221435933ddSDimitry Andric if (sc.line_entry.original_file !=
222435933ddSDimitry Andric m_addr_context.line_entry.original_file &&
223435933ddSDimitry Andric sc.comp_unit == m_addr_context.comp_unit &&
224435933ddSDimitry Andric sc.function == m_addr_context.function) {
2251c3bbb01SEd Maste // Okay, find the next occurrence of this file in the line table:
226ac7ddfbfSEd Maste LineTable *line_table = m_addr_context.comp_unit->GetLineTable();
227435933ddSDimitry Andric if (line_table) {
228ac7ddfbfSEd Maste Address cur_address = frame_sp->GetFrameCodeAddress();
229ac7ddfbfSEd Maste uint32_t entry_idx;
230ac7ddfbfSEd Maste LineEntry line_entry;
231435933ddSDimitry Andric if (line_table->FindLineEntryByAddress(cur_address, line_entry,
232435933ddSDimitry Andric &entry_idx)) {
233ac7ddfbfSEd Maste LineEntry next_line_entry;
234ac7ddfbfSEd Maste bool step_past_remaining_inline = false;
235435933ddSDimitry Andric if (entry_idx > 0) {
236435933ddSDimitry Andric // We require the previous line entry and the current line
2374ba319b5SDimitry Andric // entry come from the same file. The other requirement is
2384ba319b5SDimitry Andric // that the previous line table entry be part of an inlined
2394ba319b5SDimitry Andric // block, we don't want to step past cases where people have
2404ba319b5SDimitry Andric // inlined some code fragment by using #include <source-
2414ba319b5SDimitry Andric // fragment.c> directly.
242ac7ddfbfSEd Maste LineEntry prev_line_entry;
243435933ddSDimitry Andric if (line_table->GetLineEntryAtIndex(entry_idx - 1,
244435933ddSDimitry Andric prev_line_entry) &&
245435933ddSDimitry Andric prev_line_entry.original_file ==
246435933ddSDimitry Andric line_entry.original_file) {
247ac7ddfbfSEd Maste SymbolContext prev_sc;
248435933ddSDimitry Andric Address prev_address =
249435933ddSDimitry Andric prev_line_entry.range.GetBaseAddress();
250ac7ddfbfSEd Maste prev_address.CalculateSymbolContext(&prev_sc);
251435933ddSDimitry Andric if (prev_sc.block) {
252435933ddSDimitry Andric Block *inlined_block =
253435933ddSDimitry Andric prev_sc.block->GetContainingInlinedBlock();
254435933ddSDimitry Andric if (inlined_block) {
255ac7ddfbfSEd Maste AddressRange inline_range;
256435933ddSDimitry Andric inlined_block->GetRangeContainingAddress(prev_address,
257435933ddSDimitry Andric inline_range);
258435933ddSDimitry Andric if (!inline_range.ContainsFileAddress(cur_address)) {
259ac7ddfbfSEd Maste
260ac7ddfbfSEd Maste step_past_remaining_inline = true;
261ac7ddfbfSEd Maste }
262ac7ddfbfSEd Maste }
263ac7ddfbfSEd Maste }
264ac7ddfbfSEd Maste }
265ac7ddfbfSEd Maste }
266ac7ddfbfSEd Maste
267435933ddSDimitry Andric if (step_past_remaining_inline) {
268ac7ddfbfSEd Maste uint32_t look_ahead_step = 1;
269435933ddSDimitry Andric while (line_table->GetLineEntryAtIndex(
270435933ddSDimitry Andric entry_idx + look_ahead_step, next_line_entry)) {
271435933ddSDimitry Andric // Make sure we haven't wandered out of the function we
272435933ddSDimitry Andric // started from...
273435933ddSDimitry Andric Address next_line_address =
274435933ddSDimitry Andric next_line_entry.range.GetBaseAddress();
275435933ddSDimitry Andric Function *next_line_function =
276435933ddSDimitry Andric next_line_address.CalculateSymbolContextFunction();
277ac7ddfbfSEd Maste if (next_line_function != m_addr_context.function)
278ac7ddfbfSEd Maste break;
279ac7ddfbfSEd Maste
280435933ddSDimitry Andric if (next_line_entry.original_file ==
281435933ddSDimitry Andric m_addr_context.line_entry.original_file) {
282ac7ddfbfSEd Maste const bool abort_other_plans = false;
2839f2f44ceSEd Maste const RunMode stop_other_threads = RunMode::eAllThreads;
284435933ddSDimitry Andric lldb::addr_t cur_pc = m_thread.GetStackFrameAtIndex(0)
285435933ddSDimitry Andric ->GetRegisterContext()
286435933ddSDimitry Andric ->GetPC();
287435933ddSDimitry Andric AddressRange step_range(
288435933ddSDimitry Andric cur_pc,
289435933ddSDimitry Andric next_line_address.GetLoadAddress(&GetTarget()) -
290435933ddSDimitry Andric cur_pc);
2919f2f44ceSEd Maste
292435933ddSDimitry Andric new_plan_sp = m_thread.QueueThreadPlanForStepOverRange(
293*b5893f02SDimitry Andric abort_other_plans, step_range, sc, stop_other_threads,
294*b5893f02SDimitry Andric m_status);
295ac7ddfbfSEd Maste break;
296ac7ddfbfSEd Maste }
297ac7ddfbfSEd Maste look_ahead_step++;
298ac7ddfbfSEd Maste }
299ac7ddfbfSEd Maste }
300ac7ddfbfSEd Maste }
301ac7ddfbfSEd Maste }
302ac7ddfbfSEd Maste }
303ac7ddfbfSEd Maste }
304ac7ddfbfSEd Maste }
305ac7ddfbfSEd Maste }
306ac7ddfbfSEd Maste }
307ac7ddfbfSEd Maste
308435933ddSDimitry Andric // If we get to this point, we're not going to use a previously set "next
309435933ddSDimitry Andric // branch" breakpoint, so delete it:
310ac7ddfbfSEd Maste ClearNextBranchBreakpoint();
311ac7ddfbfSEd Maste
312435933ddSDimitry Andric // If we haven't figured out something to do yet, then ask the ShouldStopHere
313435933ddSDimitry Andric // callback:
314435933ddSDimitry Andric if (!new_plan_sp) {
315*b5893f02SDimitry Andric new_plan_sp = CheckShouldStopHereAndQueueStepOut(frame_order, m_status);
3160127ef0fSEd Maste }
3170127ef0fSEd Maste
318ac7ddfbfSEd Maste if (!new_plan_sp)
319ac7ddfbfSEd Maste m_no_more_plans = true;
320435933ddSDimitry Andric else {
3217aa51b79SEd Maste // Any new plan will be an implementation plan, so mark it private:
3227aa51b79SEd Maste new_plan_sp->SetPrivate(true);
323ac7ddfbfSEd Maste m_no_more_plans = false;
3247aa51b79SEd Maste }
325ac7ddfbfSEd Maste
326435933ddSDimitry Andric if (!new_plan_sp) {
327435933ddSDimitry Andric // For efficiencies sake, we know we're done here so we don't have to do
3284ba319b5SDimitry Andric // this calculation again in MischiefManaged.
329*b5893f02SDimitry Andric SetPlanComplete(m_status.Success());
330ac7ddfbfSEd Maste return true;
331435933ddSDimitry Andric } else
332ac7ddfbfSEd Maste return false;
333ac7ddfbfSEd Maste }
334ac7ddfbfSEd Maste
DoPlanExplainsStop(Event * event_ptr)335435933ddSDimitry Andric bool ThreadPlanStepOverRange::DoPlanExplainsStop(Event *event_ptr) {
3364ba319b5SDimitry Andric // For crashes, breakpoint hits, signals, etc, let the base plan (or some
3374ba319b5SDimitry Andric // plan above us) handle the stop. That way the user can see the stop, step
3384ba319b5SDimitry Andric // around, and then when they are done, continue and have their step
3394ba319b5SDimitry Andric // complete. The exception is if we've hit our "run to next branch"
3404ba319b5SDimitry Andric // breakpoint. Note, unlike the step in range plan, we don't mark ourselves
3414ba319b5SDimitry Andric // complete if we hit an unexplained breakpoint/crash.
342ac7ddfbfSEd Maste
343ac7ddfbfSEd Maste Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
344ac7ddfbfSEd Maste StopInfoSP stop_info_sp = GetPrivateStopInfo();
345ac7ddfbfSEd Maste bool return_value;
346ac7ddfbfSEd Maste
347435933ddSDimitry Andric if (stop_info_sp) {
348ac7ddfbfSEd Maste StopReason reason = stop_info_sp->GetStopReason();
349ac7ddfbfSEd Maste
350435933ddSDimitry Andric if (reason == eStopReasonTrace) {
351ac7ddfbfSEd Maste return_value = true;
352435933ddSDimitry Andric } else if (reason == eStopReasonBreakpoint) {
3539f2f44ceSEd Maste return_value = NextRangeBreakpointExplainsStop(stop_info_sp);
354435933ddSDimitry Andric } else {
355ac7ddfbfSEd Maste if (log)
356435933ddSDimitry Andric log->PutCString("ThreadPlanStepInRange got asked if it explains the "
357435933ddSDimitry Andric "stop for some reason other than step.");
358ac7ddfbfSEd Maste return_value = false;
359ac7ddfbfSEd Maste }
360435933ddSDimitry Andric } else
361ac7ddfbfSEd Maste return_value = true;
362ac7ddfbfSEd Maste
363ac7ddfbfSEd Maste return return_value;
364ac7ddfbfSEd Maste }
365ac7ddfbfSEd Maste
DoWillResume(lldb::StateType resume_state,bool current_plan)366435933ddSDimitry Andric bool ThreadPlanStepOverRange::DoWillResume(lldb::StateType resume_state,
367435933ddSDimitry Andric bool current_plan) {
368435933ddSDimitry Andric if (resume_state != eStateSuspended && m_first_resume) {
369ac7ddfbfSEd Maste m_first_resume = false;
370435933ddSDimitry Andric if (resume_state == eStateStepping && current_plan) {
371435933ddSDimitry Andric // See if we are about to step over an inlined call in the middle of the
3724ba319b5SDimitry Andric // inlined stack, if so figure out its extents and reset our range to
3734ba319b5SDimitry Andric // step over that.
374ac7ddfbfSEd Maste bool in_inlined_stack = m_thread.DecrementCurrentInlinedDepth();
375435933ddSDimitry Andric if (in_inlined_stack) {
376ac7ddfbfSEd Maste Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
377ac7ddfbfSEd Maste if (log)
378435933ddSDimitry Andric log->Printf("ThreadPlanStepInRange::DoWillResume: adjusting range to "
379435933ddSDimitry Andric "the frame at inlined depth %d.",
380ac7ddfbfSEd Maste m_thread.GetCurrentInlinedDepth());
381ac7ddfbfSEd Maste StackFrameSP stack_sp = m_thread.GetStackFrameAtIndex(0);
382435933ddSDimitry Andric if (stack_sp) {
383ac7ddfbfSEd Maste Block *frame_block = stack_sp->GetFrameBlock();
384ac7ddfbfSEd Maste lldb::addr_t curr_pc = m_thread.GetRegisterContext()->GetPC();
385ac7ddfbfSEd Maste AddressRange my_range;
386435933ddSDimitry Andric if (frame_block->GetRangeContainingLoadAddress(
387435933ddSDimitry Andric curr_pc, m_thread.GetProcess()->GetTarget(), my_range)) {
388ac7ddfbfSEd Maste m_address_ranges.clear();
389ac7ddfbfSEd Maste m_address_ranges.push_back(my_range);
390435933ddSDimitry Andric if (log) {
391ac7ddfbfSEd Maste StreamString s;
392435933ddSDimitry Andric const InlineFunctionInfo *inline_info =
393435933ddSDimitry Andric frame_block->GetInlinedFunctionInfo();
394ac7ddfbfSEd Maste const char *name;
395ac7ddfbfSEd Maste if (inline_info)
396435933ddSDimitry Andric name =
397435933ddSDimitry Andric inline_info
398435933ddSDimitry Andric ->GetName(frame_block->CalculateSymbolContextFunction()
399435933ddSDimitry Andric ->GetLanguage())
400435933ddSDimitry Andric .AsCString();
401ac7ddfbfSEd Maste else
402ac7ddfbfSEd Maste name = "<unknown-notinlined>";
403ac7ddfbfSEd Maste
404435933ddSDimitry Andric s.Printf(
405435933ddSDimitry Andric "Stepping over inlined function \"%s\" in inlined stack: ",
406435933ddSDimitry Andric name);
407ac7ddfbfSEd Maste DumpRanges(&s);
408435933ddSDimitry Andric log->PutString(s.GetString());
409ac7ddfbfSEd Maste }
410ac7ddfbfSEd Maste }
411ac7ddfbfSEd Maste }
412ac7ddfbfSEd Maste }
413ac7ddfbfSEd Maste }
414ac7ddfbfSEd Maste }
415ac7ddfbfSEd Maste
416ac7ddfbfSEd Maste return true;
417ac7ddfbfSEd Maste }
418