ThreadPlanStepRange.h revision 353358
1228753Smm//===-- ThreadPlanStepRange.h -----------------------------------*- C++ -*-===//
2228753Smm//
3248616Smm// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4228753Smm// See https://llvm.org/LICENSE.txt for license information.
5228753Smm// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6228753Smm//
7228753Smm//===----------------------------------------------------------------------===//
8228753Smm
9228753Smm#ifndef liblldb_ThreadPlanStepRange_h_
10228753Smm#define liblldb_ThreadPlanStepRange_h_
11228753Smm
12228753Smm#include "lldb/Core/AddressRange.h"
13228753Smm#include "lldb/Target/StackID.h"
14228753Smm#include "lldb/Target/Thread.h"
15228753Smm#include "lldb/Target/ThreadPlan.h"
16228753Smm#include "lldb/Target/ThreadPlanShouldStopHere.h"
17228753Smm
18228753Smmnamespace lldb_private {
19228753Smm
20228753Smmclass ThreadPlanStepRange : public ThreadPlan {
21228753Smmpublic:
22228753Smm  ThreadPlanStepRange(ThreadPlanKind kind, const char *name, Thread &thread,
23228753Smm                      const AddressRange &range,
24228753Smm                      const SymbolContext &addr_context,
25228753Smm                      lldb::RunMode stop_others,
26228753Smm                      bool given_ranges_only = false);
27228753Smm
28231200Smm  ~ThreadPlanStepRange() override;
29228753Smm
30228753Smm  void GetDescription(Stream *s, lldb::DescriptionLevel level) override = 0;
31228753Smm  bool ValidatePlan(Stream *error) override;
32228753Smm  bool ShouldStop(Event *event_ptr) override = 0;
33228753Smm  Vote ShouldReportStop(Event *event_ptr) override;
34228753Smm  bool StopOthers() override;
35228753Smm  lldb::StateType GetPlanRunState() override;
36228753Smm  bool WillStop() override;
37228753Smm  bool MischiefManaged() override;
38228753Smm  void DidPush() override;
39228753Smm  bool IsPlanStale() override;
40228753Smm
41228753Smm  void AddRange(const AddressRange &new_range);
42228753Smm
43228753Smmprotected:
44228753Smm  bool InRange();
45228753Smm  lldb::FrameComparison CompareCurrentFrameToStartFrame();
46228753Smm  bool InSymbol();
47228753Smm  void DumpRanges(Stream *s);
48228753Smm
49228753Smm  Disassembler *GetDisassembler();
50228753Smm
51228753Smm  InstructionList *GetInstructionsForAddress(lldb::addr_t addr,
52228753Smm                                             size_t &range_index,
53228753Smm                                             size_t &insn_offset);
54228753Smm
55228753Smm  // Pushes a plan to proceed through the next section of instructions in the
56228753Smm  // range - usually just a RunToAddress plan to run to the next branch.
57248616Smm  // Returns true if it pushed such a plan.  If there was no available 'quick
58228753Smm  // run' plan, then just single step.
59248616Smm  bool SetNextBranchBreakpoint();
60228753Smm
61231200Smm  void ClearNextBranchBreakpoint();
62231200Smm
63231200Smm  bool NextRangeBreakpointExplainsStop(lldb::StopInfoSP stop_info_sp);
64228753Smm
65228753Smm  SymbolContext m_addr_context;
66228753Smm  std::vector<AddressRange> m_address_ranges;
67231200Smm  lldb::RunMode m_stop_others;
68228753Smm  StackID m_stack_id; // Use the stack ID so we can tell step out from step in.
69228753Smm  StackID m_parent_stack_id; // Use the parent stack ID so we can identify tail
70231200Smm                             // calls and the like.
71231200Smm  bool m_no_more_plans;   // Need this one so we can tell if we stepped into a
72231200Smm                          // call,
73231200Smm                          // but can't continue, in which case we are done.
74231200Smm  bool m_first_run_event; // We want to broadcast only one running event, our
75231200Smm                          // first.
76231200Smm  lldb::BreakpointSP m_next_branch_bp_sp;
77231200Smm  bool m_use_fast_step;
78228753Smm  bool m_given_ranges_only;
79231200Smm
80231200Smmprivate:
81231200Smm  std::vector<lldb::DisassemblerSP> m_instruction_ranges;
82231200Smm
83231200Smm  DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepRange);
84231200Smm};
85228753Smm
86228753Smm} // namespace lldb_private
87228753Smm
88228753Smm#endif // liblldb_ThreadPlanStepRange_h_
89228753Smm