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