40 m_trampoline_handler(trampoline_handler),
42 m_isa_addr(isa_addr), m_sel_addr(sel_addr), m_impl_function(nullptr),
43 m_sel_str_addr(sel_str_addr), m_sel_str(sel_str) {}
91 s->
Printf(
"Step through ObjC trampoline");
93 s->
Printf(
"Stepping to implementation of ObjC method - obj: 0x%llx, isa: "
94 "0x%" PRIx64
", sel: 0x%" PRIx64,
136 Value target_addr_value;
145 target_addr = abi_sp->FixCodeAddress(target_addr);
149 if (target_addr == 0) {
150 LLDB_LOGF(log,
"Got target implementation of 0x0, stopping.");
156 "Implementation lookup returned msgForward function: 0x%" PRIx64
161 eSymbolContextEverything);
163 const bool abort_other_plans =
false;
164 const bool first_insn =
true;
165 const uint32_t frame_idx = 0;
174 LLDB_LOGF(log,
"Running to ObjC method implementation: 0x%" PRIx64,
179 assert(objc_runtime !=
nullptr);
185 if (dealloc_error.
Fail())
186 LLDB_LOG(log,
"Failed to deallocate the sel str at {0} - error: {1}",
190 "Adding \\{isa-addr={0}, sel-addr={1}\\} = addr={2} to cache.",
195 "Adding {isa-addr=0x%" PRIx64
", sel-addr=0x%" PRIx64
196 "} = addr=0x%" PRIx64
" to cache.",
200 m_run_to_sp = std::make_shared<ThreadPlanRunToAddress>(
241AppleThreadPlanStepThroughDirectDispatch ::
242 AppleThreadPlanStepThroughDirectDispatch(
244 llvm::StringRef dispatch_func_name)
253 m_trampoline_handler(handler),
254 m_dispatch_func_name(std::string(dispatch_func_name)),
255 m_at_msg_send(false) {
258 const AppleObjCTrampolineHandler
259 ::DispatchFunction &dispatch) {
290 s->
PutCString(
"Step through ObjC direct dispatch function.");
293 s->
Printf(
"Step through ObjC direct dispatch '%s' using breakpoints: ",
301 s->
Printf(
"%d", bkpt_sp->GetID());
319 stop_reason = stop_info_sp->GetStopReason();
324 uint64_t break_site_id = stop_info_sp->GetValue();
326 = process_sp->GetBreakpointSiteList().FindByID(break_site_id);
333 if (site_sp->IsBreakpointAtThisSite(break_sp->GetID())) {
336 if (site_sp->GetNumberOfConstituents() > 1) {
352bool AppleThreadPlanStepThroughDirectDispatch
355 m_at_msg_send =
false;
365 if (step_out_should_stop) {
380 LLDB_LOGF(log,
"ObjC Step through plan failed. Stepping out.");
392 bkpt_sp->SetEnabled(
true);
405 assert(objc_runtime);
411 LLDB_LOG(log,
"Couldn't find target for message dispatch, continuing.");
417 bkpt_sp->SetEnabled(
false);
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
A section + offset based address class.
bool SetOpcodeLoadAddress(lldb::addr_t load_addr, Target *target, AddressClass addr_class=AddressClass::eInvalid, bool allow_section_end=false)
bool AddrIsMsgForward(lldb::addr_t addr) const
lldb::addr_t SetupDispatchFunction(Thread &thread, ValueList &dispatch_values)
void ForEachDispatchFunction(std::function< void(lldb::addr_t, const DispatchFunction &)>)
FunctionCaller * GetLookupImplementationFunctionCaller()
bool ShouldStop(Event *event_ptr) override
bool m_at_msg_send
Breakpoints on the objc dispatch functions.
void GetDescription(Stream *s, lldb::DescriptionLevel level) override
Print a description of this thread to the stream s.
bool MischiefManaged() override
lldb::ThreadPlanSP m_objc_step_through_sp
Which dispatch function we're stepping through.
bool DoPlanExplainsStop(Event *event_ptr) override
std::string m_dispatch_func_name
std::vector< lldb::BreakpointSP > m_msgSend_bkpts
When we hit an objc_msgSend, we'll use this plan to get to its target.
~AppleThreadPlanStepThroughDirectDispatch() override
lldb::ThreadPlanSP m_run_to_sp
This is the function call plan.
lldb::addr_t m_args_addr
The handler itself.
lldb::addr_t m_sel_addr
isa_addr and sel_addr are the keys we will use to cache the implementation.
bool MischiefManaged() override
bool InitializeFunctionCaller()
AppleObjCTrampolineHandler & m_trampoline_handler
lldb::StateType GetPlanRunState() override
ValueList m_input_values
Stores the address for our step through function result structure.
FunctionCaller * m_impl_function
The plan that runs to the target.
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)
void GetDescription(Stream *s, lldb::DescriptionLevel level) override
Print a description of this thread to the stream s.
lldb::ThreadPlanSP m_func_sp
bool DoPlanExplainsStop(Event *event_ptr) override
bool ValidatePlan(Stream *error) override
Returns whether this plan could be successfully created.
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.
std::string m_sel_str
If this is not LLDB_INVALID_ADDRESS then it is the address we wrote the selector string to.
static bool PreResumeInitializeFunctionCaller(void *myself)
bool ShouldStop(Event *event_ptr) override
~AppleThreadPlanStepThroughObjCTrampoline() override
void SetUnwindOnError(bool unwind=false)
void SetStopOthers(bool stop_others=true)
void SetIgnoreBreakpoints(bool ignore=false)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Target * GetTargetPtr() const
Returns a pointer to the target object.
ValueType Clear(ValueType mask=~static_cast< ValueType >(0))
Clear one or more flags.
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
void DeallocateFunctionResults(ExecutionContext &exe_ctx, lldb::addr_t args_addr)
Deallocate the arguments structure.
lldb::ThreadPlanSP GetThreadPlanToCallFunction(ExecutionContext &exe_ctx, lldb::addr_t args_addr, const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager)
Get a thread plan to run the function this FunctionCaller was created with.
bool FetchFunctionResults(ExecutionContext &exe_ctx, lldb::addr_t args_addr, Value &ret_value)
Get the result of the function from its struct.
virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop_others)=0
static ObjCLanguageRuntime * Get(Process &process)
void AddToMethodCache(lldb::addr_t class_addr, lldb::addr_t sel, lldb::addr_t impl_addr)
void AddPreResumeAction(PreResumeActionCallback callback, void *baton)
unsigned long long ULongLong(unsigned long long fail_value=0) const
bool Fail() const
Test for error condition.
bool Success() const
Test for success condition.
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Defines a symbol context baton that can be handed other debug core functions.
bool RemoveBreakpointByID(lldb::break_id_t break_id)
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
lldb_private::Flags & GetFlags()
bool InvokeShouldStopHereCallback(lldb::FrameComparison operation, Status &status)
bool DoWillResume(lldb::StateType resume_state, bool current_plan) override
bool DoPlanExplainsStop(Event *event_ptr) override
bool MischiefManaged() override
bool ShouldStop(Event *event_ptr) override
void PushPlan(lldb::ThreadPlanSP &thread_plan_sp)
void SetPlanComplete(bool success=true)
Thread & GetThread()
Returns the Thread that is using this thread plan.
lldb::StopInfoSP GetPrivateStopInfo()
bool GetStepInAvoidsNoDebug() const
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans)
Queues a generic thread plan.
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
lldb::ProcessSP GetProcess() const
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOutNoShouldStop(bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote report_stop_vote, Vote report_run_vote, uint32_t frame_idx, Status &status, bool continue_to_next_branch=false)
Queue the plan used to step out of the function at the current PC of a thread.
Value * GetValueAtIndex(size_t idx)
const Scalar & GetScalar() const
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
StateType
Process and Thread States.
@ eStateRunning
Process or thread is running and can't be examined.
@ eLanguageTypeObjC
Objective-C.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
StopReason
Thread stop reasons.
lldb::user_id_t GetID() const
Get accessor for the user ID.