1254721Semaste//===-- ThreadPlanStepRange.h -----------------------------------*- C++ -*-===// 2254721Semaste// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6254721Semaste// 7254721Semaste//===----------------------------------------------------------------------===// 8254721Semaste 9254721Semaste#ifndef liblldb_ThreadPlanStepRange_h_ 10254721Semaste#define liblldb_ThreadPlanStepRange_h_ 11254721Semaste 12254721Semaste#include "lldb/Core/AddressRange.h" 13254721Semaste#include "lldb/Target/StackID.h" 14254721Semaste#include "lldb/Target/Thread.h" 15254721Semaste#include "lldb/Target/ThreadPlan.h" 16254721Semaste#include "lldb/Target/ThreadPlanShouldStopHere.h" 17254721Semaste 18254721Semastenamespace lldb_private { 19254721Semaste 20314564Sdimclass ThreadPlanStepRange : public ThreadPlan { 21254721Semastepublic: 22314564Sdim ThreadPlanStepRange(ThreadPlanKind kind, const char *name, Thread &thread, 23314564Sdim const AddressRange &range, 24314564Sdim const SymbolContext &addr_context, 25314564Sdim lldb::RunMode stop_others, 26314564Sdim bool given_ranges_only = false); 27254721Semaste 28314564Sdim ~ThreadPlanStepRange() override; 29254721Semaste 30314564Sdim void GetDescription(Stream *s, lldb::DescriptionLevel level) override = 0; 31314564Sdim bool ValidatePlan(Stream *error) override; 32314564Sdim bool ShouldStop(Event *event_ptr) override = 0; 33314564Sdim Vote ShouldReportStop(Event *event_ptr) override; 34314564Sdim bool StopOthers() override; 35314564Sdim lldb::StateType GetPlanRunState() override; 36314564Sdim bool WillStop() override; 37314564Sdim bool MischiefManaged() override; 38314564Sdim void DidPush() override; 39314564Sdim bool IsPlanStale() override; 40254721Semaste 41314564Sdim void AddRange(const AddressRange &new_range); 42254721Semaste 43254721Semasteprotected: 44314564Sdim bool InRange(); 45314564Sdim lldb::FrameComparison CompareCurrentFrameToStartFrame(); 46314564Sdim bool InSymbol(); 47314564Sdim void DumpRanges(Stream *s); 48254721Semaste 49314564Sdim Disassembler *GetDisassembler(); 50254721Semaste 51314564Sdim InstructionList *GetInstructionsForAddress(lldb::addr_t addr, 52314564Sdim size_t &range_index, 53314564Sdim size_t &insn_offset); 54314564Sdim 55314564Sdim // Pushes a plan to proceed through the next section of instructions in the 56341825Sdim // range - usually just a RunToAddress plan to run to the next branch. 57341825Sdim // Returns true if it pushed such a plan. If there was no available 'quick 58341825Sdim // run' plan, then just single step. 59314564Sdim bool SetNextBranchBreakpoint(); 60314564Sdim 61314564Sdim void ClearNextBranchBreakpoint(); 62314564Sdim 63314564Sdim bool NextRangeBreakpointExplainsStop(lldb::StopInfoSP stop_info_sp); 64314564Sdim 65314564Sdim SymbolContext m_addr_context; 66314564Sdim std::vector<AddressRange> m_address_ranges; 67314564Sdim lldb::RunMode m_stop_others; 68314564Sdim StackID m_stack_id; // Use the stack ID so we can tell step out from step in. 69314564Sdim StackID m_parent_stack_id; // Use the parent stack ID so we can identify tail 70314564Sdim // calls and the like. 71314564Sdim bool m_no_more_plans; // Need this one so we can tell if we stepped into a 72314564Sdim // call, 73314564Sdim // but can't continue, in which case we are done. 74314564Sdim bool m_first_run_event; // We want to broadcast only one running event, our 75314564Sdim // first. 76314564Sdim lldb::BreakpointSP m_next_branch_bp_sp; 77314564Sdim bool m_use_fast_step; 78314564Sdim bool m_given_ranges_only; 79360784Sdim bool m_found_calls = false; // When we set the next branch breakpoint for 80360784Sdim // step over, we now extend them past call insns 81360784Sdim // that directly return. But if we do that we 82360784Sdim // need to run all threads, or we might cause 83360784Sdim // deadlocks. This tells us whether we found 84360784Sdim // any calls in setting the next branch breakpoint. 85314564Sdim 86254721Semasteprivate: 87314564Sdim std::vector<lldb::DisassemblerSP> m_instruction_ranges; 88296417Sdim 89314564Sdim DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepRange); 90254721Semaste}; 91254721Semaste 92254721Semaste} // namespace lldb_private 93254721Semaste 94296417Sdim#endif // liblldb_ThreadPlanStepRange_h_ 95