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 
30 
31  static bool PreResumeInitializeFunctionCaller(void *myself);
32 
33  void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
34 
35  bool ValidatePlan(Stream *error) override;
36 
38 
39  bool ShouldStop(Event *event_ptr) override;
40 
41  // The step through code might have to fill in the cache, so it is not safe
42  // to run only one thread.
43  bool StopOthers() override { return false; }
44 
45  // The base class MischiefManaged does some cleanup - so you have to call it
46  // in your MischiefManaged derived class.
47  bool MischiefManaged() override;
48 
49  void DidPush() override;
50 
51  bool WillStop() override;
52 
53 protected:
54  bool DoPlanExplainsStop(Event *event_ptr) override;
55 
56 private:
58 
60  lldb::addr_t m_args_addr; /// Stores the address for our step through function
61  /// result structure.
63  lldb::addr_t m_isa_addr; /// isa_addr and sel_addr are the keys we will use to
64  /// cache the implementation.
66  lldb::ThreadPlanSP m_func_sp; /// This is the function call plan. We fill it
67  /// at start, then set it to NULL when this plan
68  /// is done. That way we know to go on to:
69  lldb::ThreadPlanSP m_run_to_sp; /// The plan that runs to the target.
70  FunctionCaller *m_impl_function; /// This is a pointer to a impl function that
71  /// is owned by the client that pushes this
72  /// plan.
73 };
74 
76 public:
79  llvm::StringRef dispatch_func_name);
80 
82 
83  void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
84 
85  bool ShouldStop(Event *event_ptr) override;
86 
87  bool StopOthers() override { return false; }
88 
89  bool MischiefManaged() override;
90 
91  bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
92 
93  void SetFlagsToDefault() override {
95  }
96 
97 protected:
98  bool DoPlanExplainsStop(Event *event_ptr) override;
99 
101  std::string m_dispatch_func_name; /// Which dispatch function we're stepping
102  /// through.
103  lldb::ThreadPlanSP m_objc_step_through_sp; /// When we hit an objc_msgSend,
104  /// we'll use this plan to get to
105  /// its target.
106  std::vector<lldb::BreakpointSP> m_msgSend_bkpts; /// Breakpoints on the objc
107  /// dispatch functions.
108  bool m_at_msg_send; /// Are we currently handling an msg_send
109 
110 };
111 
112 } // namespace lldb_private
113 
114 #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:108
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:103
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::StopOthers
bool StopOthers() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:43
lldb_private::Event
Definition: Event.h:180
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::DoPlanExplainsStop
bool DoPlanExplainsStop(Event *event_ptr) override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:100
ThreadPlanStepOut.h
lldb_private::AppleThreadPlanStepThroughDirectDispatch::DoPlanExplainsStop
bool DoPlanExplainsStop(Event *event_ptr) override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:288
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:265
lldb_private::ThreadPlanStepOut
Definition: ThreadPlanStepOut.h:18
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::MischiefManaged
bool MischiefManaged() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:193
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:66
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_impl_function
FunctionCaller * m_impl_function
The plan that runs to the target.
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:70
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:96
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::InitializeFunctionCaller
bool InitializeFunctionCaller()
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:52
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:84
lldb_private::AppleThreadPlanStepThroughDirectDispatch::~AppleThreadPlanStepThroughDirectDispatch
~AppleThreadPlanStepThroughDirectDispatch() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:259
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_args_addr
lldb::addr_t m_args_addr
The handler itself.
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:60
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ThreadPlan
Definition: ThreadPlan.h:282
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::GetPlanRunState
lldb::StateType GetPlanRunState() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:108
lldb_private::Thread
Definition: Thread.h:60
lldb_private::AppleThreadPlanStepThroughDirectDispatch::SetFlagsToDefault
void SetFlagsToDefault() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:93
lldb_private::AppleThreadPlanStepThroughDirectDispatch::StopOthers
bool StopOthers() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:87
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_isa_addr
lldb::addr_t m_isa_addr
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:63
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::WillStop
bool WillStop() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:197
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:101
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:69
ThreadPlanStepInRange.h
lldb_private::AppleThreadPlanStepThroughDirectDispatch::ShouldStop
bool ShouldStop(Event *event_ptr) override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:338
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::PreResumeInitializeFunctionCaller
static bool PreResumeInitializeFunctionCaller(void *myself)
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:78
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::ShouldStop
bool ShouldStop(Event *event_ptr) override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:112
lldb_private::AppleThreadPlanStepThroughDirectDispatch::DoWillResume
bool DoWillResume(lldb::StateType resume_state, bool current_plan) override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:332
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:100
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:65
lldb_private::ThreadPlanStepInRange::GetDefaultFlagsValue
static uint32_t GetDefaultFlagsValue()
Definition: ThreadPlanStepInRange.h:43
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::AppleThreadPlanStepThroughObjCTrampoline
AppleThreadPlanStepThroughObjCTrampoline(Thread &thread, AppleObjCTrampolineHandler &trampoline_handler, ValueList &values, lldb::addr_t isa_addr, lldb::addr_t sel_addr)
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:31
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:106
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:221
lldb_private::AppleThreadPlanStepThroughDirectDispatch
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:75
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::DidPush
void DidPush() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:45
lldb_private::AppleThreadPlanStepThroughDirectDispatch::MischiefManaged
bool MischiefManaged() override
Definition: AppleThreadPlanStepThroughObjCTrampoline.cpp:403
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:62
lldb_private::AppleThreadPlanStepThroughObjCTrampoline::m_trampoline_handler
AppleObjCTrampolineHandler & m_trampoline_handler
Definition: AppleThreadPlanStepThroughObjCTrampoline.h:59
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