1 //===-- AppleThreadPlanStepThroughObjCTrampoline.h --------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLETHREADPLANSTEPTHROUGHOBJCTRAMPOLINE_H
10 #define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLETHREADPLANSTEPTHROUGHOBJCTRAMPOLINE_H
12 #include "AppleObjCTrampolineHandler.h"
13 #include "lldb/Core/Value.h"
14 #include "lldb/Target/ThreadPlan.h"
15 #include "lldb/Target/ThreadPlanStepInRange.h"
16 #include "lldb/Target/ThreadPlanStepOut.h"
17 #include "lldb/Target/ThreadPlanShouldStopHere.h"
18 #include "lldb/lldb-enumerations.h"
19 #include "lldb/lldb-types.h"
21 namespace lldb_private {
23 class AppleThreadPlanStepThroughObjCTrampoline : public ThreadPlan {
25 AppleThreadPlanStepThroughObjCTrampoline(
26 Thread &thread, AppleObjCTrampolineHandler &trampoline_handler,
27 ValueList &values, lldb::addr_t isa_addr, lldb::addr_t sel_addr,
30 ~AppleThreadPlanStepThroughObjCTrampoline() override;
32 static bool PreResumeInitializeFunctionCaller(void *myself);
34 void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
36 bool ValidatePlan(Stream *error) override;
38 lldb::StateType GetPlanRunState() override;
40 bool ShouldStop(Event *event_ptr) override;
42 bool StopOthers() override { return m_stop_others; }
44 // The base class MischiefManaged does some cleanup - so you have to call it
45 // in your MischiefManaged derived class.
46 bool MischiefManaged() override;
48 void DidPush() override;
50 bool WillStop() override;
53 bool DoPlanExplainsStop(Event *event_ptr) override;
56 bool InitializeFunctionCaller();
58 AppleObjCTrampolineHandler &m_trampoline_handler; /// The handler itself.
59 lldb::addr_t m_args_addr; /// Stores the address for our step through function
61 ValueList m_input_values;
62 lldb::addr_t m_isa_addr; /// isa_addr and sel_addr are the keys we will use to
63 /// cache the implementation.
64 lldb::addr_t m_sel_addr;
65 lldb::ThreadPlanSP m_func_sp; /// This is the function call plan. We fill it
66 /// at start, then set it to NULL when this plan
67 /// is done. That way we know to go on to:
68 lldb::ThreadPlanSP m_run_to_sp; /// The plan that runs to the target.
69 FunctionCaller *m_impl_function; /// This is a pointer to a impl function that
70 /// is owned by the client that pushes this
72 bool m_stop_others; /// Whether we should stop other threads.
75 class AppleThreadPlanStepThroughDirectDispatch: public ThreadPlanStepOut {
77 AppleThreadPlanStepThroughDirectDispatch(
78 Thread &thread, AppleObjCTrampolineHandler &handler,
79 llvm::StringRef dispatch_func_name, bool stop_others,
80 LazyBool step_in_avoids_code_without_debug_info);
82 ~AppleThreadPlanStepThroughDirectDispatch() override;
84 void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
86 bool ShouldStop(Event *event_ptr) override;
88 bool StopOthers() override { return m_stop_others; }
90 bool MischiefManaged() override;
92 bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
94 void SetFlagsToDefault() override {
95 GetFlags().Set(ThreadPlanStepInRange::GetDefaultFlagsValue());
99 bool DoPlanExplainsStop(Event *event_ptr) override;
101 AppleObjCTrampolineHandler &m_trampoline_handler;
102 std::string m_dispatch_func_name; /// Which dispatch function we're stepping
104 lldb::ThreadPlanSP m_objc_step_through_sp; /// When we hit an objc_msgSend,
105 /// we'll use this plan to get to
107 std::vector<lldb::BreakpointSP> m_msgSend_bkpts; /// Breakpoints on the objc
108 /// dispatch functions.
109 bool m_at_msg_send; /// Are we currently handling an msg_send
110 bool m_stop_others; /// Whether we should stop other threads.
114 } // namespace lldb_private
116 #endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLETHREADPLANSTEPTHROUGHOBJCTRAMPOLINE_H