Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:56

0001 //===-- ThreadPlanStepRange.h -----------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_TARGET_THREADPLANSTEPRANGE_H
0010 #define LLDB_TARGET_THREADPLANSTEPRANGE_H
0011 
0012 #include "lldb/Core/AddressRange.h"
0013 #include "lldb/Target/StackID.h"
0014 #include "lldb/Target/Thread.h"
0015 #include "lldb/Target/ThreadPlan.h"
0016 #include "lldb/Target/ThreadPlanShouldStopHere.h"
0017 
0018 namespace lldb_private {
0019 
0020 class ThreadPlanStepRange : public ThreadPlan {
0021 public:
0022   ThreadPlanStepRange(ThreadPlanKind kind, const char *name, Thread &thread,
0023                       const AddressRange &range,
0024                       const SymbolContext &addr_context,
0025                       lldb::RunMode stop_others,
0026                       bool given_ranges_only = false);
0027 
0028   ~ThreadPlanStepRange() override;
0029 
0030   void GetDescription(Stream *s, lldb::DescriptionLevel level) override = 0;
0031   bool ValidatePlan(Stream *error) override;
0032   bool ShouldStop(Event *event_ptr) override = 0;
0033   Vote ShouldReportStop(Event *event_ptr) override;
0034   bool StopOthers() override;
0035   lldb::StateType GetPlanRunState() override;
0036   bool WillStop() override;
0037   bool MischiefManaged() override;
0038   void DidPush() override;
0039   bool IsPlanStale() override;
0040 
0041   void AddRange(const AddressRange &new_range);
0042 
0043 protected:
0044   bool InRange();
0045   lldb::FrameComparison CompareCurrentFrameToStartFrame();
0046   bool InSymbol();
0047   void DumpRanges(Stream *s);
0048 
0049   Disassembler *GetDisassembler();
0050 
0051   InstructionList *GetInstructionsForAddress(lldb::addr_t addr,
0052                                              size_t &range_index,
0053                                              size_t &insn_offset);
0054 
0055   // Pushes a plan to proceed through the next section of instructions in the
0056   // range - usually just a RunToAddress plan to run to the next branch.
0057   // Returns true if it pushed such a plan.  If there was no available 'quick
0058   // run' plan, then just single step.
0059   bool SetNextBranchBreakpoint();
0060 
0061   // Whether the input stop info is caused by the next branch breakpoint.
0062   // Note: this does not check if branch breakpoint site is shared by other
0063   // breakpoints or not.
0064   bool IsNextBranchBreakpointStop(lldb::StopInfoSP stop_info_sp);
0065 
0066   void ClearNextBranchBreakpoint();
0067 
0068   void ClearNextBranchBreakpointExplainedStop();
0069 
0070   bool NextRangeBreakpointExplainsStop(lldb::StopInfoSP stop_info_sp);
0071 
0072   SymbolContext m_addr_context;
0073   std::vector<AddressRange> m_address_ranges;
0074   lldb::RunMode m_stop_others;
0075   StackID m_stack_id; // Use the stack ID so we can tell step out from step in.
0076   StackID m_parent_stack_id; // Use the parent stack ID so we can identify tail
0077                              // calls and the like.
0078   bool m_no_more_plans;   // Need this one so we can tell if we stepped into a
0079                           // call,
0080                           // but can't continue, in which case we are done.
0081   bool m_first_run_event; // We want to broadcast only one running event, our
0082                           // first.
0083   lldb::BreakpointSP m_next_branch_bp_sp;
0084   bool m_use_fast_step;
0085   bool m_given_ranges_only;
0086   bool m_found_calls = false; // When we set the next branch breakpoint for
0087                               // step over, we now extend them past call insns
0088                               // that directly return.  But if we do that we
0089                               // need to run all threads, or we might cause
0090                               // deadlocks.  This tells us whether we found
0091                               // any calls in setting the next branch breakpoint.
0092 
0093 private:
0094   std::vector<lldb::DisassemblerSP> m_instruction_ranges;
0095 
0096   ThreadPlanStepRange(const ThreadPlanStepRange &) = delete;
0097   const ThreadPlanStepRange &operator=(const ThreadPlanStepRange &) = delete;
0098 };
0099 
0100 } // namespace lldb_private
0101 
0102 #endif // LLDB_TARGET_THREADPLANSTEPRANGE_H