1 //===-- ThreadPlanStepOut.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_ThreadPlanStepOut_h_
11 #define liblldb_ThreadPlanStepOut_h_
12 
13 #include "lldb/Target/Thread.h"
14 #include "lldb/Target/ThreadPlan.h"
15 #include "lldb/Target/ThreadPlanShouldStopHere.h"
16 
17 namespace lldb_private {
18 
19 class ThreadPlanStepOut : public ThreadPlan, public ThreadPlanShouldStopHere {
20 public:
21   ThreadPlanStepOut(Thread &thread, SymbolContext *addr_context,
22                     bool first_insn, bool stop_others, Vote stop_vote,
23                     Vote run_vote, uint32_t frame_idx,
24                     LazyBool step_out_avoids_code_without_debug_info,
25                     bool continue_to_next_branch = false,
26                     bool gather_return_value = true);
27 
28   ~ThreadPlanStepOut() override;
29 
30   void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
31   bool ValidatePlan(Stream *error) override;
32   bool ShouldStop(Event *event_ptr) override;
33   bool StopOthers() override;
34   lldb::StateType GetPlanRunState() override;
35   bool WillStop() override;
36   bool MischiefManaged() override;
37   void DidPush() override;
38   bool IsPlanStale() override;
39 
GetReturnValueObject()40   lldb::ValueObjectSP GetReturnValueObject() override {
41     return m_return_valobj_sp;
42   }
43 
44 protected:
SetFlagsToDefault()45   void SetFlagsToDefault() override {
46     GetFlags().Set(ThreadPlanStepOut::s_default_flag_values);
47   }
48 
49   bool DoPlanExplainsStop(Event *event_ptr) override;
50   bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
51   bool QueueInlinedStepPlan(bool queue_now);
52 
53 private:
54   static uint32_t s_default_flag_values; // These are the default flag values
55                                          // for the ThreadPlanStepThrough.
56 
57   lldb::addr_t m_step_from_insn;
58   StackID m_step_out_to_id;
59   StackID m_immediate_step_from_id;
60   lldb::break_id_t m_return_bp_id;
61   lldb::addr_t m_return_addr;
62   bool m_stop_others;
63   lldb::ThreadPlanSP m_step_out_to_inline_plan_sp; // This plan implements step
64                                                    // out to the real function
65                                                    // containing
66   // an inlined frame so we can then step out of that.
67   lldb::ThreadPlanSP m_step_through_inline_plan_sp; // This plan then steps past
68                                                     // the inlined frame(s).
69   lldb::ThreadPlanSP m_step_out_further_plan_sp; // This plan keeps stepping out
70                                                  // if ShouldStopHere told us
71                                                  // to.
72   Function *m_immediate_step_from_function;
73   std::vector<lldb::StackFrameSP> m_stepped_past_frames;
74   lldb::ValueObjectSP m_return_valobj_sp;
75   bool m_calculate_return_value;
76 
77   friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepOut(
78       bool abort_other_plans, SymbolContext *addr_context, bool first_insn,
79       bool stop_others, Vote stop_vote, Vote run_vote, uint32_t frame_idx,
80       Status &status, LazyBool step_out_avoids_code_without_debug_info);
81 
82   void SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info);
83   // Need an appropriate marker for the current stack so we can tell step out
84   // from step in.
85 
86   void CalculateReturnValue();
87 
88   DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepOut);
89 };
90 
91 } // namespace lldb_private
92 
93 #endif // liblldb_ThreadPlanStepOut_h_
94