1 //===-- ThreadPlanStepRange.h -----------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_ThreadPlanStepRange_h_
11 #define liblldb_ThreadPlanStepRange_h_
12 
13 #include "lldb/Core/AddressRange.h"
14 #include "lldb/Target/StackID.h"
15 #include "lldb/Target/Thread.h"
16 #include "lldb/Target/ThreadPlan.h"
17 #include "lldb/Target/ThreadPlanShouldStopHere.h"
18 
19 namespace lldb_private {
20 
21 class ThreadPlanStepRange : public ThreadPlan {
22 public:
23   ThreadPlanStepRange(ThreadPlanKind kind, const char *name, Thread &thread,
24                       const AddressRange &range,
25                       const SymbolContext &addr_context,
26                       lldb::RunMode stop_others,
27                       bool given_ranges_only = false);
28 
29   ~ThreadPlanStepRange() override;
30 
31   void GetDescription(Stream *s, lldb::DescriptionLevel level) override = 0;
32   bool ValidatePlan(Stream *error) override;
33   bool ShouldStop(Event *event_ptr) override = 0;
34   Vote ShouldReportStop(Event *event_ptr) override;
35   bool StopOthers() override;
36   lldb::StateType GetPlanRunState() override;
37   bool WillStop() override;
38   bool MischiefManaged() override;
39   void DidPush() override;
40   bool IsPlanStale() override;
41 
42   void AddRange(const AddressRange &new_range);
43 
44 protected:
45   bool InRange();
46   lldb::FrameComparison CompareCurrentFrameToStartFrame();
47   bool InSymbol();
48   void DumpRanges(Stream *s);
49 
50   Disassembler *GetDisassembler();
51 
52   InstructionList *GetInstructionsForAddress(lldb::addr_t addr,
53                                              size_t &range_index,
54                                              size_t &insn_offset);
55 
56   // Pushes a plan to proceed through the next section of instructions in the
57   // range - usually just a RunToAddress plan to run to the next branch.
58   // Returns true if it pushed such a plan.  If there was no available 'quick
59   // run' plan, then just single step.
60   bool SetNextBranchBreakpoint();
61 
62   void ClearNextBranchBreakpoint();
63 
64   bool NextRangeBreakpointExplainsStop(lldb::StopInfoSP stop_info_sp);
65 
66   SymbolContext m_addr_context;
67   std::vector<AddressRange> m_address_ranges;
68   lldb::RunMode m_stop_others;
69   StackID m_stack_id; // Use the stack ID so we can tell step out from step in.
70   StackID m_parent_stack_id; // Use the parent stack ID so we can identify tail
71                              // calls and the like.
72   bool m_no_more_plans;   // Need this one so we can tell if we stepped into a
73                           // call,
74                           // but can't continue, in which case we are done.
75   bool m_first_run_event; // We want to broadcast only one running event, our
76                           // first.
77   lldb::BreakpointSP m_next_branch_bp_sp;
78   bool m_use_fast_step;
79   bool m_given_ranges_only;
80 
81 private:
82   std::vector<lldb::DisassemblerSP> m_instruction_ranges;
83 
84   DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepRange);
85 };
86 
87 } // namespace lldb_private
88 
89 #endif // liblldb_ThreadPlanStepRange_h_
90