LLDB  mainline
AppleThreadPlanStepThroughObjCTrampoline.h
Go to the documentation of this file.
1 //===-- AppleThreadPlanStepThroughObjCTrampoline.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 
9 #ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLETHREADPLANSTEPTHROUGHOBJCTRAMPOLINE_H
10 #define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLETHREADPLANSTEPTHROUGHOBJCTRAMPOLINE_H
11 
13 #include "lldb/Core/Value.h"
14 #include "lldb/Target/ThreadPlan.h"
18 #include "lldb/lldb-enumerations.h"
19 #include "lldb/lldb-types.h"
20 
21 namespace lldb_private {
22 
24 public:
26  Thread &thread, AppleObjCTrampolineHandler &trampoline_handler,
27  ValueList &values, lldb::addr_t isa_addr, lldb::addr_t sel_addr,
28  lldb::addr_t sel_str_addr, llvm::StringRef sel_str);
29 
31 
32  static bool PreResumeInitializeFunctionCaller(void *myself);
33 
34  void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
35 
36  bool ValidatePlan(Stream *error) override;
37 
39 
40  bool ShouldStop(Event *event_ptr) override;
41 
42  // The step through code might have to fill in the cache, so it is not safe
43  // to run only one thread.
44  bool StopOthers() override { return false; }
45 
46  // The base class MischiefManaged does some cleanup - so you have to call it
47  // in your MischiefManaged derived class.
48  bool MischiefManaged() override;
49 
50  void DidPush() override;
51 
52  bool WillStop() override;
53 
54 protected:
55  bool DoPlanExplainsStop(Event *event_ptr) override;
56 
57 private:
59 
61  lldb::addr_t m_args_addr; /// Stores the address for our step through function
62  /// result structure.
64  lldb::addr_t m_isa_addr; /// isa_addr and sel_addr are the keys we will use to
65  /// cache the implementation.
67  lldb::ThreadPlanSP m_func_sp; /// This is the function call plan. We fill it
68  /// at start, then set it to NULL when this plan
69  /// is done. That way we know to go on to:
70  lldb::ThreadPlanSP m_run_to_sp; /// The plan that runs to the target.
71  FunctionCaller *m_impl_function; /// This is a pointer to a impl function that
72  /// is owned by the client that pushes this
73  /// plan.
74  lldb::addr_t m_sel_str_addr; /// If this is not LLDB_INVALID_ADDRESS then it
75  /// is the address we wrote the selector string
76  /// to. We need to deallocate it when the
77  /// function call is done.
78  std::string m_sel_str; /// This is the string we wrote to memory - we
79  /// use it for caching, but only if
80  /// m_sel_str_addr is non-null.
81 };
82 
84 public:
87  llvm::StringRef dispatch_func_name);
88 
90 
91  void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
92 
93  bool ShouldStop(Event *event_ptr) override;
94 
95  bool StopOthers() override { return false; }
96 
97  bool MischiefManaged() override;
98 
99  bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
100 
101  void SetFlagsToDefault() override {
103  }
104 
105 protected:
106  bool DoPlanExplainsStop(Event *event_ptr) override;
107 
109  std::string m_dispatch_func_name; /// Which dispatch function we're stepping
110  /// through.
111  lldb::ThreadPlanSP m_objc_step_through_sp; /// When we hit an objc_msgSend,
112  /// we'll use this plan to get to
113  /// its target.
114  std::vector<lldb::BreakpointSP> m_msgSend_bkpts; /// Breakpoints on the objc
115  /// dispatch functions.
116  bool m_at_msg_send; /// Are we currently handling an msg_send
117 
118 };
119 
120 } // namespace lldb_private
121 
122 #endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLETHREADPLANSTEPTHROUGHOBJCTRAMPOLINE_H
lldb_private::AppleThreadPlanStepThroughDirectDispatch::m_at_msg_send
bool m_at_msg_send
Breakpoints on the objc dispatch functions.
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:116
lldb_private::AppleThreadPlanStepThroughDirectDispatch::m_objc_step_through_sp
lldb::ThreadPlanSP m_objc_step_through_sp
Which dispatch function we're stepping through.
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:111
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::StopOthers
bool StopOthers() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:44
lldb_private::Event
Definition: Event.h:182
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::DoPlanExplainsStop
bool DoPlanExplainsStop(Event *event_ptr) override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:104
ThreadPlanStepOut.h
lldb_private::AppleThreadPlanStepThroughDirectDispatch::DoPlanExplainsStop
bool DoPlanExplainsStop(Event *event_ptr) override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:309
lldb_private::AppleThreadPlanStepThroughDirectDispatch::GetDescription
void GetDescription(Stream *s, lldb::DescriptionLevel level) override
Print a description of this thread to the stream s.
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:286
lldb_private::ThreadPlanStepOut
Definition: ThreadPlanStepOut.h:18
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::MischiefManaged
bool MischiefManaged() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:214
lldb_private::ValueList
Definition: Value.h:157
lldb_private::Stream
Definition: Stream.h:28
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_func_sp
lldb::ThreadPlanSP m_func_sp
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:67
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::AppleThreadPlanStepThroughObjCTrampoline
AppleThreadPlanStepThroughObjCTrampoline(Thread &thread, AppleObjCTrampolineHandler &trampoline_handler, ValueList &values, lldb::addr_t isa_addr, lldb::addr_t sel_addr, lldb::addr_t sel_str_addr, llvm::StringRef sel_str)
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:33
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_impl_function
FunctionCaller * m_impl_function
The plan that runs to the target.
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:71
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::~AppleThreadPlanStepThroughObjCTrampoline
~AppleThreadPlanStepThroughObjCTrampoline() override
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::ValidatePlan
bool ValidatePlan(Stream *error) override
Returns whether this plan could be successfully created.
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:100
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::InitializeFunctionCaller
bool InitializeFunctionCaller()
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:56
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::GetDescription
void GetDescription(Stream *s, lldb::DescriptionLevel level) override
Print a description of this thread to the stream s.
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:88
lldb_private::AppleThreadPlanStepThroughDirectDispatch::~AppleThreadPlanStepThroughDirectDispatch
~AppleThreadPlanStepThroughDirectDispatch() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:280
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_args_addr
lldb::addr_t m_args_addr
The handler itself.
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:61
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ThreadPlan
Definition: ThreadPlan.h:287
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::GetPlanRunState
lldb::StateType GetPlanRunState() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:112
lldb_private::Thread
Definition: Thread.h:61
lldb_private::AppleThreadPlanStepThroughDirectDispatch::SetFlagsToDefault
void SetFlagsToDefault() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:101
lldb_private::AppleThreadPlanStepThroughDirectDispatch::StopOthers
bool StopOthers() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:95
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_isa_addr
lldb::addr_t m_isa_addr
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:64
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::WillStop
bool WillStop() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:218
lldb-enumerations.h
lldb_private::AppleThreadPlanStepThroughObjCTrampoline
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:23
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::AppleObjCTrampolineHandler
Definition: AppleObjCTrampolineHandler.h:21
lldb_private::ThreadPlanShouldStopHere::GetFlags
lldb_private::Flags & GetFlags()
Definition: ThreadPlanShouldStopHere.h:104
lldb_private::AppleThreadPlanStepThroughDirectDispatch::m_dispatch_func_name
std::string m_dispatch_func_name
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:109
lldb-types.h
ThreadPlan.h
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_run_to_sp
lldb::ThreadPlanSP m_run_to_sp
This is the function call plan.
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:70
ThreadPlanStepInRange.h
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_sel_str
std::string m_sel_str
If this is not LLDB_INVALID_ADDRESS then it is the address we wrote the selector string to.
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:78
lldb_private::AppleThreadPlanStepThroughDirectDispatch::ShouldStop
bool ShouldStop(Event *event_ptr) override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:359
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_sel_str_addr
lldb::addr_t m_sel_str_addr
This is a pointer to a impl function that is owned by the client that pushes this plan.
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:74
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::PreResumeInitializeFunctionCaller
static bool PreResumeInitializeFunctionCaller(void *myself)
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:82
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::ShouldStop
bool ShouldStop(Event *event_ptr) override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:116
lldb_private::AppleThreadPlanStepThroughDirectDispatch::DoWillResume
bool DoWillResume(lldb::StateType resume_state, bool current_plan) override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:353
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::AppleThreadPlanStepThroughDirectDispatch::m_trampoline_handler
AppleObjCTrampolineHandler & m_trampoline_handler
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:108
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_sel_addr
lldb::addr_t m_sel_addr
isa_addr and sel_addr are the keys we will use to cache the implementation.
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:66
lldb_private::ThreadPlanStepInRange::GetDefaultFlagsValue
static uint32_t GetDefaultFlagsValue()
Definition: ThreadPlanStepInRange.h:43
lldb_private::Flags::Set
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
Definition: Flags.h:73
lldb_private::AppleThreadPlanStepThroughDirectDispatch::m_msgSend_bkpts
std::vector< lldb::BreakpointSP > m_msgSend_bkpts
When we hit an objc_msgSend, we'll use this plan to get to its target.
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:114
lldb::StateType
StateType
Process and Thread States.
Definition: lldb-enumerations.h:73
lldb_private::AppleThreadPlanStepThroughDirectDispatch::AppleThreadPlanStepThroughDirectDispatch
AppleThreadPlanStepThroughDirectDispatch(Thread &thread, AppleObjCTrampolineHandler &handler, llvm::StringRef dispatch_func_name)
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:242
lldb_private::AppleThreadPlanStepThroughDirectDispatch
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:83
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::DidPush
void DidPush() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:49
lldb_private::AppleThreadPlanStepThroughDirectDispatch::MischiefManaged
bool MischiefManaged() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:424
Value.h
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_input_values
ValueList m_input_values
Stores the address for our step through function result structure.
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:63
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_trampoline_handler
AppleObjCTrampolineHandler & m_trampoline_handler
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:60
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207
ThreadPlanShouldStopHere.h
AppleObjCTrampolineHandler.h
lldb_private::FunctionCaller
Definition: FunctionCaller.h:56