]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/ThreadPlanCallFunction.h
MFV r316933: 5142 libzfs support raidz root pool (loader project)
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Target / ThreadPlanCallFunction.h
1 //===-- ThreadPlanCallFunction.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_ThreadPlanCallFunction_h_
11 #define liblldb_ThreadPlanCallFunction_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Target/Thread.h"
18 #include "lldb/Target/ThreadPlan.h"
19 #include "lldb/lldb-private.h"
20
21 #include "llvm/ADT/ArrayRef.h"
22
23 namespace lldb_private {
24
25 class ThreadPlanCallFunction : public ThreadPlan {
26   // Create a thread plan to call a function at the address passed in the
27   // "function"
28   // argument.  If you plan to call GetReturnValueObject, then pass in the
29   // return type, otherwise just pass in an invalid CompilerType.
30 public:
31   ThreadPlanCallFunction(Thread &thread, const Address &function,
32                          const CompilerType &return_type,
33                          llvm::ArrayRef<lldb::addr_t> args,
34                          const EvaluateExpressionOptions &options);
35
36   ThreadPlanCallFunction(Thread &thread, const Address &function,
37                          const EvaluateExpressionOptions &options);
38
39   ~ThreadPlanCallFunction() override;
40
41   void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
42
43   bool ValidatePlan(Stream *error) override;
44
45   bool ShouldStop(Event *event_ptr) override;
46
47   Vote ShouldReportStop(Event *event_ptr) override;
48
49   bool StopOthers() override;
50
51   lldb::StateType GetPlanRunState() override;
52
53   void DidPush() override;
54
55   bool WillStop() override;
56
57   bool MischiefManaged() override;
58
59   // To get the return value from a function call you must create a
60   // lldb::ValueSP that contains a valid clang type in its context and call
61   // RequestReturnValue. The ValueSP will be stored and when the function is
62   // done executing, the object will check if there is a requested return
63   // value. If there is, the return value will be retrieved using the
64   // ABI::GetReturnValue() for the ABI in the process. Then after the thread
65   // plan is complete, you can call "GetReturnValue()" to retrieve the value
66   // that was extracted.
67
68   lldb::ValueObjectSP GetReturnValueObject() override {
69     return m_return_valobj_sp;
70   }
71
72   // Return the stack pointer that the function received
73   // on entry.  Any stack address below this should be
74   // considered invalid after the function has been
75   // cleaned up.
76   lldb::addr_t GetFunctionStackPointer() { return m_function_sp; }
77
78   // Classes that derive from FunctionCaller, and implement
79   // their own WillPop methods should call this so that the
80   // thread state gets restored if the plan gets discarded.
81   void WillPop() override;
82
83   // If the thread plan stops mid-course, this will be the stop reason that
84   // interrupted us.
85   // Once DoTakedown is called, this will be the real stop reason at the end of
86   // the function call.
87   // If it hasn't been set for one or the other of these reasons, we'll return
88   // the PrivateStopReason.
89   // This is needed because we want the CallFunction thread plans not to show up
90   // as the stop reason.
91   // But if something bad goes wrong, it is nice to be able to tell the user
92   // what really happened.
93
94   lldb::StopInfoSP GetRealStopInfo() override {
95     if (m_real_stop_info_sp)
96       return m_real_stop_info_sp;
97     else
98       return GetPrivateStopInfo();
99   }
100
101   lldb::addr_t GetStopAddress() { return m_stop_address; }
102
103   bool RestoreThreadState() override;
104
105   void ThreadDestroyed() override { m_takedown_done = true; }
106
107   void SetStopOthers(bool new_value) override;
108
109 protected:
110   void ReportRegisterState(const char *message);
111
112   bool DoPlanExplainsStop(Event *event_ptr) override;
113
114   virtual void SetReturnValue();
115
116   bool ConstructorSetup(Thread &thread, ABI *&abi,
117                         lldb::addr_t &start_load_addr,
118                         lldb::addr_t &function_load_addr);
119
120   virtual void DoTakedown(bool success);
121
122   void SetBreakpoints();
123
124   void ClearBreakpoints();
125
126   bool BreakpointsExplainStop();
127
128   bool m_valid;
129   bool m_stop_other_threads;
130   bool m_unwind_on_error;
131   bool m_ignore_breakpoints;
132   bool m_debug_execution;
133   bool m_trap_exceptions;
134   Address m_function_addr;
135   Address m_start_addr;
136   lldb::addr_t m_function_sp;
137   lldb::ThreadPlanSP m_subplan_sp;
138   LanguageRuntime *m_cxx_language_runtime;
139   LanguageRuntime *m_objc_language_runtime;
140   Thread::ThreadStateCheckpoint m_stored_thread_state;
141   lldb::StopInfoSP
142       m_real_stop_info_sp; // In general we want to hide call function
143                            // thread plans, but for reporting purposes,
144                            // it's nice to know the real stop reason.
145                            // This gets set in DoTakedown.
146   StreamString m_constructor_errors;
147   lldb::ValueObjectSP m_return_valobj_sp; // If this contains a valid pointer,
148                                           // use the ABI to extract values when
149                                           // complete
150   bool m_takedown_done; // We want to ensure we only do the takedown once.  This
151                         // ensures that.
152   bool m_should_clear_objc_exception_bp;
153   bool m_should_clear_cxx_exception_bp;
154   lldb::addr_t m_stop_address; // This is the address we stopped at.  Also set
155                                // in DoTakedown;
156
157 private:
158   CompilerType m_return_type;
159   DISALLOW_COPY_AND_ASSIGN(ThreadPlanCallFunction);
160 };
161
162 } // namespace lldb_private
163
164 #endif // liblldb_ThreadPlanCallFunction_h_