130fdc8d8SChris Lattner //===-- ThreadPlanStepOverRange.cpp -----------------------------*- C++ -*-===// 230fdc8d8SChris Lattner // 330fdc8d8SChris Lattner // The LLVM Compiler Infrastructure 430fdc8d8SChris Lattner // 530fdc8d8SChris Lattner // This file is distributed under the University of Illinois Open Source 630fdc8d8SChris Lattner // License. See LICENSE.TXT for details. 730fdc8d8SChris Lattner // 830fdc8d8SChris Lattner //===----------------------------------------------------------------------===// 930fdc8d8SChris Lattner 1030fdc8d8SChris Lattner // C Includes 1130fdc8d8SChris Lattner // C++ Includes 1230fdc8d8SChris Lattner // Other libraries and framework includes 1330fdc8d8SChris Lattner // Project includes 14e65b2cf2SEugene Zelenko #include "lldb/Target/ThreadPlanStepOverRange.h" 1530fdc8d8SChris Lattner #include "lldb/Core/Log.h" 1630fdc8d8SChris Lattner #include "lldb/Core/Stream.h" 17513c6bb8SJim Ingham #include "lldb/Symbol/Block.h" 183bfa753fSJim Ingham #include "lldb/Symbol/CompileUnit.h" 19513c6bb8SJim Ingham #include "lldb/Symbol/Function.h" 203bfa753fSJim Ingham #include "lldb/Symbol/LineTable.h" 2130fdc8d8SChris Lattner #include "lldb/Target/Process.h" 2230fdc8d8SChris Lattner #include "lldb/Target/RegisterContext.h" 23514487e8SGreg Clayton #include "lldb/Target/Target.h" 2430fdc8d8SChris Lattner #include "lldb/Target/Thread.h" 2530fdc8d8SChris Lattner #include "lldb/Target/ThreadPlanStepOut.h" 2630fdc8d8SChris Lattner #include "lldb/Target/ThreadPlanStepThrough.h" 2730fdc8d8SChris Lattner 2830fdc8d8SChris Lattner using namespace lldb_private; 292d4edfbcSGreg Clayton using namespace lldb; 3030fdc8d8SChris Lattner 314b4b2478SJim Ingham uint32_t ThreadPlanStepOverRange::s_default_flag_values = 0; 3230fdc8d8SChris Lattner 3330fdc8d8SChris Lattner //---------------------------------------------------------------------- 3430fdc8d8SChris Lattner // ThreadPlanStepOverRange: Step through a stack range, either stepping over or into 3530fdc8d8SChris Lattner // based on the value of \a type. 3630fdc8d8SChris Lattner //---------------------------------------------------------------------- 3730fdc8d8SChris Lattner 3830fdc8d8SChris Lattner ThreadPlanStepOverRange::ThreadPlanStepOverRange 3930fdc8d8SChris Lattner ( 4030fdc8d8SChris Lattner Thread &thread, 4130fdc8d8SChris Lattner const AddressRange &range, 4230fdc8d8SChris Lattner const SymbolContext &addr_context, 434b4b2478SJim Ingham lldb::RunMode stop_others, 444b4b2478SJim Ingham LazyBool step_out_avoids_code_without_debug_info 4530fdc8d8SChris Lattner ) : 46513c6bb8SJim Ingham ThreadPlanStepRange (ThreadPlan::eKindStepOverRange, "Step range stepping over", thread, range, addr_context, stop_others), 474b4b2478SJim Ingham ThreadPlanShouldStopHere (this), 48513c6bb8SJim Ingham m_first_resume(true) 4930fdc8d8SChris Lattner { 504b4b2478SJim Ingham SetFlagsToDefault(); 514b4b2478SJim Ingham SetupAvoidNoDebug(step_out_avoids_code_without_debug_info); 5230fdc8d8SChris Lattner } 5330fdc8d8SChris Lattner 54e65b2cf2SEugene Zelenko ThreadPlanStepOverRange::~ThreadPlanStepOverRange() = default; 5530fdc8d8SChris Lattner 5630fdc8d8SChris Lattner void 5730fdc8d8SChris Lattner ThreadPlanStepOverRange::GetDescription (Stream *s, lldb::DescriptionLevel level) 5830fdc8d8SChris Lattner { 5930fdc8d8SChris Lattner if (level == lldb::eDescriptionLevelBrief) 6030fdc8d8SChris Lattner { 612bdbfd50SJim Ingham s->Printf("step over"); 622bdbfd50SJim Ingham return; 632bdbfd50SJim Ingham } 642bdbfd50SJim Ingham s->Printf ("Stepping over"); 652bdbfd50SJim Ingham bool printed_line_info = false; 662bdbfd50SJim Ingham if (m_addr_context.line_entry.IsValid()) 672bdbfd50SJim Ingham { 682bdbfd50SJim Ingham s->Printf (" line "); 692bdbfd50SJim Ingham m_addr_context.line_entry.DumpStopContext (s, false); 702bdbfd50SJim Ingham printed_line_info = true; 712bdbfd50SJim Ingham } 722bdbfd50SJim Ingham 732bdbfd50SJim Ingham if (!printed_line_info || level == eDescriptionLevelVerbose) 742bdbfd50SJim Ingham { 752bdbfd50SJim Ingham s->Printf (" using ranges: "); 76c4c9fedcSJim Ingham DumpRanges(s); 7730fdc8d8SChris Lattner } 782bdbfd50SJim Ingham 792bdbfd50SJim Ingham s->PutChar('.'); 8030fdc8d8SChris Lattner } 8130fdc8d8SChris Lattner 824b4b2478SJim Ingham void 834b4b2478SJim Ingham ThreadPlanStepOverRange::SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info) 844b4b2478SJim Ingham { 854b4b2478SJim Ingham bool avoid_nodebug = true; 864b4b2478SJim Ingham switch (step_out_avoids_code_without_debug_info) 874b4b2478SJim Ingham { 884b4b2478SJim Ingham case eLazyBoolYes: 894b4b2478SJim Ingham avoid_nodebug = true; 904b4b2478SJim Ingham break; 914b4b2478SJim Ingham case eLazyBoolNo: 924b4b2478SJim Ingham avoid_nodebug = false; 934b4b2478SJim Ingham break; 944b4b2478SJim Ingham case eLazyBoolCalculate: 954b4b2478SJim Ingham avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug(); 964b4b2478SJim Ingham break; 974b4b2478SJim Ingham } 984b4b2478SJim Ingham if (avoid_nodebug) 994b4b2478SJim Ingham GetFlags().Set (ThreadPlanShouldStopHere::eStepOutAvoidNoDebug); 1004b4b2478SJim Ingham else 1014b4b2478SJim Ingham GetFlags().Clear (ThreadPlanShouldStopHere::eStepOutAvoidNoDebug); 102862d1bbdSJim Ingham // Step Over plans should always avoid no-debug on step in. Seems like you shouldn't 103862d1bbdSJim Ingham // have to say this, but a tail call looks more like a step in that a step out, so 104862d1bbdSJim Ingham // we want to catch this case. 105862d1bbdSJim Ingham GetFlags().Set (ThreadPlanShouldStopHere::eStepInAvoidNoDebug); 1064b4b2478SJim Ingham } 1074b4b2478SJim Ingham 10830fdc8d8SChris Lattner bool 1094b86728bSDaniel Malea ThreadPlanStepOverRange::IsEquivalentContext(const SymbolContext &context) 1104b86728bSDaniel Malea { 1114b86728bSDaniel Malea // Match as much as is specified in the m_addr_context: 1124b86728bSDaniel Malea // This is a fairly loose sanity check. Note, sometimes the target doesn't get filled 1134b86728bSDaniel Malea // in so I left out the target check. And sometimes the module comes in as the .o file from the 1144b86728bSDaniel Malea // inlined range, so I left that out too... 1154b86728bSDaniel Malea if (m_addr_context.comp_unit) 1164b86728bSDaniel Malea { 1174b86728bSDaniel Malea if (m_addr_context.comp_unit == context.comp_unit) 1184b86728bSDaniel Malea { 1194b86728bSDaniel Malea if (m_addr_context.function && m_addr_context.function == context.function) 1204b86728bSDaniel Malea { 121*7766c4a8SJim Ingham // It is okay to return to a different block of a straight function, we only have to 122*7766c4a8SJim Ingham // be more careful if returning from one inlined block to another. 123*7766c4a8SJim Ingham if (m_addr_context.block->GetInlinedFunctionInfo() == nullptr 124*7766c4a8SJim Ingham && context.block->GetInlinedFunctionInfo() == nullptr) 125*7766c4a8SJim Ingham return true; 126*7766c4a8SJim Ingham 1274b86728bSDaniel Malea if (m_addr_context.block && m_addr_context.block == context.block) 1284b86728bSDaniel Malea return true; 1294b86728bSDaniel Malea } 1304b86728bSDaniel Malea } 1314b86728bSDaniel Malea } 1324b86728bSDaniel Malea else if (m_addr_context.symbol && m_addr_context.symbol == context.symbol) 1334b86728bSDaniel Malea { 1344b86728bSDaniel Malea return true; 1354b86728bSDaniel Malea } 1364b86728bSDaniel Malea return false; 1374b86728bSDaniel Malea } 1384b86728bSDaniel Malea 1394b86728bSDaniel Malea bool 14030fdc8d8SChris Lattner ThreadPlanStepOverRange::ShouldStop (Event *event_ptr) 14130fdc8d8SChris Lattner { 1425160ce5cSGreg Clayton Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); 14330fdc8d8SChris Lattner 14430fdc8d8SChris Lattner if (log) 14530fdc8d8SChris Lattner { 14630fdc8d8SChris Lattner StreamString s; 147514487e8SGreg Clayton s.Address (m_thread.GetRegisterContext()->GetPC(), 1481ac04c30SGreg Clayton m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize()); 14930fdc8d8SChris Lattner log->Printf("ThreadPlanStepOverRange reached %s.", s.GetData()); 15030fdc8d8SChris Lattner } 15130fdc8d8SChris Lattner 15230fdc8d8SChris Lattner // If we're out of the range but in the same frame or in our caller's frame 15330fdc8d8SChris Lattner // then we should stop. 1544a58e968SJim Ingham // When stepping out we only stop others if we are forcing running one thread. 155e65b2cf2SEugene Zelenko bool stop_others = (m_stop_others == lldb::eOnlyThisThread); 1564d56e9c1SJim Ingham ThreadPlanSP new_plan_sp; 157b5c0d1ccSJim Ingham FrameComparison frame_order = CompareCurrentFrameToStartFrame(); 158b5c0d1ccSJim Ingham 159b5c0d1ccSJim Ingham if (frame_order == eFrameCompareOlder) 1605822173bSJim Ingham { 1615822173bSJim Ingham // If we're in an older frame then we should stop. 1625822173bSJim Ingham // 1635822173bSJim Ingham // A caveat to this is if we think the frame is older but we're actually in a trampoline. 1645822173bSJim Ingham // I'm going to make the assumption that you wouldn't RETURN to a trampoline. So if we are 1655822173bSJim Ingham // in a trampoline we think the frame is older because the trampoline confused the backtracer. 1665822173bSJim Ingham // As below, we step through first, and then try to figure out how to get back out again. 1675822173bSJim Ingham 1684d56e9c1SJim Ingham new_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others); 1695822173bSJim Ingham 1704d56e9c1SJim Ingham if (new_plan_sp && log) 1715822173bSJim Ingham log->Printf("Thought I stepped out, but in fact arrived at a trampoline."); 1725822173bSJim Ingham } 173b5c0d1ccSJim Ingham else if (frame_order == eFrameCompareYounger) 174b5c0d1ccSJim Ingham { 175b5c0d1ccSJim Ingham // Make sure we really are in a new frame. Do that by unwinding and seeing if the 176b5c0d1ccSJim Ingham // start function really is our start function... 1774b86728bSDaniel Malea for(uint32_t i = 1;; ++i) 178b5c0d1ccSJim Ingham { 179b57e4a1bSJason Molenda StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(i); 1804b86728bSDaniel Malea if (!older_frame_sp) { 1814b86728bSDaniel Malea // We can't unwind the next frame we should just get out of here & stop... 1824b86728bSDaniel Malea break; 1834b86728bSDaniel Malea } 1844b86728bSDaniel Malea 185b5c0d1ccSJim Ingham const SymbolContext &older_context = older_frame_sp->GetSymbolContext(eSymbolContextEverything); 1864b86728bSDaniel Malea if (IsEquivalentContext(older_context)) 18730fdc8d8SChris Lattner { 1884b4b2478SJim Ingham new_plan_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop(false, 189e65b2cf2SEugene Zelenko nullptr, 190481cef25SGreg Clayton true, 191481cef25SGreg Clayton stop_others, 192e0d378b3SGreg Clayton eVoteNo, 193e0d378b3SGreg Clayton eVoteNoOpinion, 194fd4cea53SJason Molenda 0, 195fd4cea53SJason Molenda true); 1964b86728bSDaniel Malea break; 19730fdc8d8SChris Lattner } 198b5c0d1ccSJim Ingham else 199b5c0d1ccSJim Ingham { 2004d56e9c1SJim Ingham new_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others); 2015beccb22SJim Ingham // If we found a way through, then we should stop recursing. 2025beccb22SJim Ingham if (new_plan_sp) 2035beccb22SJim Ingham break; 204b5c0d1ccSJim Ingham } 205b5c0d1ccSJim Ingham } 206b5c0d1ccSJim Ingham } 207564d8bc2SJim Ingham else 208564d8bc2SJim Ingham { 209564d8bc2SJim Ingham // If we're still in the range, keep going. 210564d8bc2SJim Ingham if (InRange()) 211564d8bc2SJim Ingham { 212564d8bc2SJim Ingham SetNextBranchBreakpoint(); 213564d8bc2SJim Ingham return false; 214564d8bc2SJim Ingham } 215564d8bc2SJim Ingham 216564d8bc2SJim Ingham if (!InSymbol()) 21730fdc8d8SChris Lattner { 21830fdc8d8SChris Lattner // This one is a little tricky. Sometimes we may be in a stub or something similar, 21930fdc8d8SChris Lattner // in which case we need to get out of there. But if we are in a stub then it's 22030fdc8d8SChris Lattner // likely going to be hard to get out from here. It is probably easiest to step into the 22130fdc8d8SChris Lattner // stub, and then it will be straight-forward to step out. 2224d56e9c1SJim Ingham new_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others); 22330fdc8d8SChris Lattner } 2243bfa753fSJim Ingham else 2253bfa753fSJim Ingham { 2263bfa753fSJim Ingham // The current clang (at least through 424) doesn't always get the address range for the 2273bfa753fSJim Ingham // DW_TAG_inlined_subroutines right, so that when you leave the inlined range the line table says 2283bfa753fSJim Ingham // you are still in the source file of the inlining function. This is bad, because now you are missing 2293bfa753fSJim Ingham // the stack frame for the function containing the inlining, and if you sensibly do "finish" to get 2303bfa753fSJim Ingham // out of this function you will instead exit the containing function. 2313bfa753fSJim Ingham // To work around this, we check whether we are still in the source file we started in, and if not assume 2323bfa753fSJim Ingham // it is an error, and push a plan to get us out of this line and back to the containing file. 2333bfa753fSJim Ingham 2343bfa753fSJim Ingham if (m_addr_context.line_entry.IsValid()) 2353bfa753fSJim Ingham { 2363bfa753fSJim Ingham SymbolContext sc; 237b57e4a1bSJason Molenda StackFrameSP frame_sp = m_thread.GetStackFrameAtIndex(0); 2383bfa753fSJim Ingham sc = frame_sp->GetSymbolContext (eSymbolContextEverything); 2393bfa753fSJim Ingham if (sc.line_entry.IsValid()) 2403bfa753fSJim Ingham { 241911d5784STed Woodward if (sc.line_entry.original_file != m_addr_context.line_entry.original_file 2423bfa753fSJim Ingham && sc.comp_unit == m_addr_context.comp_unit 2433bfa753fSJim Ingham && sc.function == m_addr_context.function) 2443bfa753fSJim Ingham { 24558ef391fSBruce Mitchener // Okay, find the next occurrence of this file in the line table: 2463bfa753fSJim Ingham LineTable *line_table = m_addr_context.comp_unit->GetLineTable(); 2473bfa753fSJim Ingham if (line_table) 2483bfa753fSJim Ingham { 2493bfa753fSJim Ingham Address cur_address = frame_sp->GetFrameCodeAddress(); 2503bfa753fSJim Ingham uint32_t entry_idx; 2513bfa753fSJim Ingham LineEntry line_entry; 2523bfa753fSJim Ingham if (line_table->FindLineEntryByAddress (cur_address, line_entry, &entry_idx)) 2533bfa753fSJim Ingham { 2543bfa753fSJim Ingham LineEntry next_line_entry; 2553bfa753fSJim Ingham bool step_past_remaining_inline = false; 2563bfa753fSJim Ingham if (entry_idx > 0) 2573bfa753fSJim Ingham { 25858ef391fSBruce Mitchener // We require the previous line entry and the current line entry come 2593bfa753fSJim Ingham // from the same file. 2603bfa753fSJim Ingham // The other requirement is that the previous line table entry be part of an 2613bfa753fSJim Ingham // inlined block, we don't want to step past cases where people have inlined 2623bfa753fSJim Ingham // some code fragment by using #include <source-fragment.c> directly. 2633bfa753fSJim Ingham LineEntry prev_line_entry; 2643bfa753fSJim Ingham if (line_table->GetLineEntryAtIndex(entry_idx - 1, prev_line_entry) 265911d5784STed Woodward && prev_line_entry.original_file == line_entry.original_file) 2663bfa753fSJim Ingham { 2673bfa753fSJim Ingham SymbolContext prev_sc; 2683bfa753fSJim Ingham Address prev_address = prev_line_entry.range.GetBaseAddress(); 2693bfa753fSJim Ingham prev_address.CalculateSymbolContext(&prev_sc); 2703bfa753fSJim Ingham if (prev_sc.block) 2713bfa753fSJim Ingham { 2723bfa753fSJim Ingham Block *inlined_block = prev_sc.block->GetContainingInlinedBlock(); 2733bfa753fSJim Ingham if (inlined_block) 2743bfa753fSJim Ingham { 2753bfa753fSJim Ingham AddressRange inline_range; 2763bfa753fSJim Ingham inlined_block->GetRangeContainingAddress(prev_address, inline_range); 2773bfa753fSJim Ingham if (!inline_range.ContainsFileAddress(cur_address)) 2783bfa753fSJim Ingham { 2793bfa753fSJim Ingham 2803bfa753fSJim Ingham step_past_remaining_inline = true; 2813bfa753fSJim Ingham } 2823bfa753fSJim Ingham } 2833bfa753fSJim Ingham } 2843bfa753fSJim Ingham } 2853bfa753fSJim Ingham } 2863bfa753fSJim Ingham 2873bfa753fSJim Ingham if (step_past_remaining_inline) 2883bfa753fSJim Ingham { 2893bfa753fSJim Ingham uint32_t look_ahead_step = 1; 2903bfa753fSJim Ingham while (line_table->GetLineEntryAtIndex(entry_idx + look_ahead_step, next_line_entry)) 2913bfa753fSJim Ingham { 2923bfa753fSJim Ingham // Make sure we haven't wandered out of the function we started from... 2933bfa753fSJim Ingham Address next_line_address = next_line_entry.range.GetBaseAddress(); 2943bfa753fSJim Ingham Function *next_line_function = next_line_address.CalculateSymbolContextFunction(); 2953bfa753fSJim Ingham if (next_line_function != m_addr_context.function) 2963bfa753fSJim Ingham break; 2973bfa753fSJim Ingham 298911d5784STed Woodward if (next_line_entry.original_file == m_addr_context.line_entry.original_file) 2993bfa753fSJim Ingham { 3003bfa753fSJim Ingham const bool abort_other_plans = false; 30155828080SJim Ingham const RunMode stop_other_threads = RunMode::eAllThreads; 30255828080SJim Ingham lldb::addr_t cur_pc = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC(); 30355828080SJim Ingham AddressRange step_range(cur_pc, next_line_address.GetLoadAddress(&GetTarget()) - cur_pc); 30455828080SJim Ingham 30555828080SJim Ingham new_plan_sp = m_thread.QueueThreadPlanForStepOverRange (abort_other_plans, 30655828080SJim Ingham step_range, 30755828080SJim Ingham sc, 3083bfa753fSJim Ingham stop_other_threads); 3093bfa753fSJim Ingham break; 3103bfa753fSJim Ingham } 3113bfa753fSJim Ingham look_ahead_step++; 3123bfa753fSJim Ingham } 3133bfa753fSJim Ingham } 3143bfa753fSJim Ingham } 3153bfa753fSJim Ingham } 3163bfa753fSJim Ingham } 3173bfa753fSJim Ingham } 3183bfa753fSJim Ingham } 3193bfa753fSJim Ingham } 320564d8bc2SJim Ingham } 321564d8bc2SJim Ingham 322564d8bc2SJim Ingham // If we get to this point, we're not going to use a previously set "next branch" breakpoint, so delete it: 323564d8bc2SJim Ingham ClearNextBranchBreakpoint(); 32430fdc8d8SChris Lattner 3254b4b2478SJim Ingham 3264b4b2478SJim Ingham // If we haven't figured out something to do yet, then ask the ShouldStopHere callback: 3274b4b2478SJim Ingham if (!new_plan_sp) 3284b4b2478SJim Ingham { 3294b4b2478SJim Ingham new_plan_sp = CheckShouldStopHereAndQueueStepOut (frame_order); 3304b4b2478SJim Ingham } 3314b4b2478SJim Ingham 3324d56e9c1SJim Ingham if (!new_plan_sp) 33330fdc8d8SChris Lattner m_no_more_plans = true; 33430fdc8d8SChris Lattner else 3352bdbfd50SJim Ingham { 3362bdbfd50SJim Ingham // Any new plan will be an implementation plan, so mark it private: 3372bdbfd50SJim Ingham new_plan_sp->SetPrivate(true); 33830fdc8d8SChris Lattner m_no_more_plans = false; 3392bdbfd50SJim Ingham } 34030fdc8d8SChris Lattner 3414d56e9c1SJim Ingham if (!new_plan_sp) 34230fdc8d8SChris Lattner { 34330fdc8d8SChris Lattner // For efficiencies sake, we know we're done here so we don't have to do this 34430fdc8d8SChris Lattner // calculation again in MischiefManaged. 34530fdc8d8SChris Lattner SetPlanComplete(); 34630fdc8d8SChris Lattner return true; 34730fdc8d8SChris Lattner } 34830fdc8d8SChris Lattner else 34930fdc8d8SChris Lattner return false; 35030fdc8d8SChris Lattner } 351fbbfe6ecSJim Ingham 352fbbfe6ecSJim Ingham bool 353221d51cfSJim Ingham ThreadPlanStepOverRange::DoPlanExplainsStop (Event *event_ptr) 354fbbfe6ecSJim Ingham { 355fbbfe6ecSJim Ingham // For crashes, breakpoint hits, signals, etc, let the base plan (or some plan above us) 356fbbfe6ecSJim Ingham // handle the stop. That way the user can see the stop, step around, and then when they 357fbbfe6ecSJim Ingham // are done, continue and have their step complete. The exception is if we've hit our 358fbbfe6ecSJim Ingham // "run to next branch" breakpoint. 359fbbfe6ecSJim Ingham // Note, unlike the step in range plan, we don't mark ourselves complete if we hit an 360fbbfe6ecSJim Ingham // unexplained breakpoint/crash. 361fbbfe6ecSJim Ingham 3625160ce5cSGreg Clayton Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); 36360c4118cSJim Ingham StopInfoSP stop_info_sp = GetPrivateStopInfo (); 364221d51cfSJim Ingham bool return_value; 365221d51cfSJim Ingham 366fbbfe6ecSJim Ingham if (stop_info_sp) 367fbbfe6ecSJim Ingham { 368fbbfe6ecSJim Ingham StopReason reason = stop_info_sp->GetStopReason(); 369fbbfe6ecSJim Ingham 3709b03fa0cSJim Ingham if (reason == eStopReasonTrace) 371fbbfe6ecSJim Ingham { 372221d51cfSJim Ingham return_value = true; 3739b03fa0cSJim Ingham } 3749b03fa0cSJim Ingham else if (reason == eStopReasonBreakpoint) 3759b03fa0cSJim Ingham { 376e65b2cf2SEugene Zelenko return_value = NextRangeBreakpointExplainsStop(stop_info_sp); 3779b03fa0cSJim Ingham } 3789b03fa0cSJim Ingham else 3799b03fa0cSJim Ingham { 380fbbfe6ecSJim Ingham if (log) 381fbbfe6ecSJim Ingham log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step."); 382221d51cfSJim Ingham return_value = false; 383fbbfe6ecSJim Ingham } 384fbbfe6ecSJim Ingham } 385221d51cfSJim Ingham else 386221d51cfSJim Ingham return_value = true; 387221d51cfSJim Ingham 388221d51cfSJim Ingham return return_value; 389fbbfe6ecSJim Ingham } 390513c6bb8SJim Ingham 391513c6bb8SJim Ingham bool 392221d51cfSJim Ingham ThreadPlanStepOverRange::DoWillResume (lldb::StateType resume_state, bool current_plan) 393513c6bb8SJim Ingham { 394513c6bb8SJim Ingham if (resume_state != eStateSuspended && m_first_resume) 395513c6bb8SJim Ingham { 396513c6bb8SJim Ingham m_first_resume = false; 397513c6bb8SJim Ingham if (resume_state == eStateStepping && current_plan) 398513c6bb8SJim Ingham { 399513c6bb8SJim Ingham // See if we are about to step over an inlined call in the middle of the inlined stack, if so figure 400513c6bb8SJim Ingham // out its extents and reset our range to step over that. 401513c6bb8SJim Ingham bool in_inlined_stack = m_thread.DecrementCurrentInlinedDepth(); 402513c6bb8SJim Ingham if (in_inlined_stack) 403513c6bb8SJim Ingham { 4045160ce5cSGreg Clayton Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); 405513c6bb8SJim Ingham if (log) 406221d51cfSJim Ingham log->Printf ("ThreadPlanStepInRange::DoWillResume: adjusting range to the frame at inlined depth %d.", 407513c6bb8SJim Ingham m_thread.GetCurrentInlinedDepth()); 408b57e4a1bSJason Molenda StackFrameSP stack_sp = m_thread.GetStackFrameAtIndex(0); 409513c6bb8SJim Ingham if (stack_sp) 410513c6bb8SJim Ingham { 411513c6bb8SJim Ingham Block *frame_block = stack_sp->GetFrameBlock(); 412513c6bb8SJim Ingham lldb::addr_t curr_pc = m_thread.GetRegisterContext()->GetPC(); 413513c6bb8SJim Ingham AddressRange my_range; 414513c6bb8SJim Ingham if (frame_block->GetRangeContainingLoadAddress(curr_pc, m_thread.GetProcess()->GetTarget(), my_range)) 415513c6bb8SJim Ingham { 416513c6bb8SJim Ingham m_address_ranges.clear(); 417513c6bb8SJim Ingham m_address_ranges.push_back(my_range); 418513c6bb8SJim Ingham if (log) 419513c6bb8SJim Ingham { 420513c6bb8SJim Ingham StreamString s; 421513c6bb8SJim Ingham const InlineFunctionInfo *inline_info = frame_block->GetInlinedFunctionInfo(); 422513c6bb8SJim Ingham const char *name; 423513c6bb8SJim Ingham if (inline_info) 424ddaf6a72SGreg Clayton name = inline_info->GetName(frame_block->CalculateSymbolContextFunction()->GetLanguage()).AsCString(); 425513c6bb8SJim Ingham else 426513c6bb8SJim Ingham name = "<unknown-notinlined>"; 427513c6bb8SJim Ingham 428513c6bb8SJim Ingham s.Printf ("Stepping over inlined function \"%s\" in inlined stack: ", name); 429513c6bb8SJim Ingham DumpRanges(&s); 430513c6bb8SJim Ingham log->PutCString(s.GetData()); 431513c6bb8SJim Ingham } 432513c6bb8SJim Ingham } 433513c6bb8SJim Ingham 434513c6bb8SJim Ingham } 435513c6bb8SJim Ingham } 436513c6bb8SJim Ingham } 437513c6bb8SJim Ingham } 438513c6bb8SJim Ingham 439221d51cfSJim Ingham return true; 440513c6bb8SJim Ingham } 441