ThreadPlanStepRange.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //===-- ThreadPlanStepRange.h -----------------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLDB_TARGET_THREADPLANSTEPRANGE_H
  9. #define LLDB_TARGET_THREADPLANSTEPRANGE_H
  10. #include "lldb/Core/AddressRange.h"
  11. #include "lldb/Target/StackID.h"
  12. #include "lldb/Target/Thread.h"
  13. #include "lldb/Target/ThreadPlan.h"
  14. #include "lldb/Target/ThreadPlanShouldStopHere.h"
  15. namespace lldb_private {
  16. class ThreadPlanStepRange : public ThreadPlan {
  17. public:
  18. ThreadPlanStepRange(ThreadPlanKind kind, const char *name, Thread &thread,
  19. const AddressRange &range,
  20. const SymbolContext &addr_context,
  21. lldb::RunMode stop_others,
  22. bool given_ranges_only = false);
  23. ~ThreadPlanStepRange() override;
  24. void GetDescription(Stream *s, lldb::DescriptionLevel level) override = 0;
  25. bool ValidatePlan(Stream *error) override;
  26. bool ShouldStop(Event *event_ptr) override = 0;
  27. Vote ShouldReportStop(Event *event_ptr) override;
  28. bool StopOthers() override;
  29. lldb::StateType GetPlanRunState() override;
  30. bool WillStop() override;
  31. bool MischiefManaged() override;
  32. void DidPush() override;
  33. bool IsPlanStale() override;
  34. void AddRange(const AddressRange &new_range);
  35. protected:
  36. bool InRange();
  37. lldb::FrameComparison CompareCurrentFrameToStartFrame();
  38. bool InSymbol();
  39. void DumpRanges(Stream *s);
  40. Disassembler *GetDisassembler();
  41. InstructionList *GetInstructionsForAddress(lldb::addr_t addr,
  42. size_t &range_index,
  43. size_t &insn_offset);
  44. // Pushes a plan to proceed through the next section of instructions in the
  45. // range - usually just a RunToAddress plan to run to the next branch.
  46. // Returns true if it pushed such a plan. If there was no available 'quick
  47. // run' plan, then just single step.
  48. bool SetNextBranchBreakpoint();
  49. void ClearNextBranchBreakpoint();
  50. bool NextRangeBreakpointExplainsStop(lldb::StopInfoSP stop_info_sp);
  51. SymbolContext m_addr_context;
  52. std::vector<AddressRange> m_address_ranges;
  53. lldb::RunMode m_stop_others;
  54. StackID m_stack_id; // Use the stack ID so we can tell step out from step in.
  55. StackID m_parent_stack_id; // Use the parent stack ID so we can identify tail
  56. // calls and the like.
  57. bool m_no_more_plans; // Need this one so we can tell if we stepped into a
  58. // call,
  59. // but can't continue, in which case we are done.
  60. bool m_first_run_event; // We want to broadcast only one running event, our
  61. // first.
  62. lldb::BreakpointSP m_next_branch_bp_sp;
  63. bool m_use_fast_step;
  64. bool m_given_ranges_only;
  65. bool m_found_calls = false; // When we set the next branch breakpoint for
  66. // step over, we now extend them past call insns
  67. // that directly return. But if we do that we
  68. // need to run all threads, or we might cause
  69. // deadlocks. This tells us whether we found
  70. // any calls in setting the next branch breakpoint.
  71. private:
  72. std::vector<lldb::DisassemblerSP> m_instruction_ranges;
  73. ThreadPlanStepRange(const ThreadPlanStepRange &) = delete;
  74. const ThreadPlanStepRange &operator=(const ThreadPlanStepRange &) = delete;
  75. };
  76. } // namespace lldb_private
  77. #endif // LLDB_TARGET_THREADPLANSTEPRANGE_H