Path: blob/main/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
39688 views
//===-- AppleThreadPlanStepThroughObjCTrampoline.h --------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLETHREADPLANSTEPTHROUGHOBJCTRAMPOLINE_H9#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLETHREADPLANSTEPTHROUGHOBJCTRAMPOLINE_H1011#include "AppleObjCTrampolineHandler.h"12#include "lldb/Core/Value.h"13#include "lldb/Target/ThreadPlan.h"14#include "lldb/Target/ThreadPlanStepInRange.h"15#include "lldb/Target/ThreadPlanStepOut.h"16#include "lldb/Target/ThreadPlanShouldStopHere.h"17#include "lldb/lldb-enumerations.h"18#include "lldb/lldb-types.h"1920namespace lldb_private {2122class AppleThreadPlanStepThroughObjCTrampoline : public ThreadPlan {23public:24AppleThreadPlanStepThroughObjCTrampoline(25Thread &thread, AppleObjCTrampolineHandler &trampoline_handler,26ValueList &values, lldb::addr_t isa_addr, lldb::addr_t sel_addr,27lldb::addr_t sel_str_addr, llvm::StringRef sel_str);2829~AppleThreadPlanStepThroughObjCTrampoline() override;3031static bool PreResumeInitializeFunctionCaller(void *myself);3233void GetDescription(Stream *s, lldb::DescriptionLevel level) override;3435bool ValidatePlan(Stream *error) override;3637lldb::StateType GetPlanRunState() override;3839bool ShouldStop(Event *event_ptr) override;4041// The step through code might have to fill in the cache, so it is not safe42// to run only one thread.43bool StopOthers() override { return false; }4445// The base class MischiefManaged does some cleanup - so you have to call it46// in your MischiefManaged derived class.47bool MischiefManaged() override;4849void DidPush() override;5051bool WillStop() override;5253protected:54bool DoPlanExplainsStop(Event *event_ptr) override;5556private:57bool InitializeFunctionCaller();5859AppleObjCTrampolineHandler &m_trampoline_handler; /// The handler itself.60lldb::addr_t m_args_addr; /// Stores the address for our step through function61/// result structure.62ValueList m_input_values;63lldb::addr_t m_isa_addr; /// isa_addr and sel_addr are the keys we will use to64/// cache the implementation.65lldb::addr_t m_sel_addr;66lldb::ThreadPlanSP m_func_sp; /// This is the function call plan. We fill it67/// at start, then set it to NULL when this plan68/// is done. That way we know to go on to:69lldb::ThreadPlanSP m_run_to_sp; /// The plan that runs to the target.70FunctionCaller *m_impl_function; /// This is a pointer to a impl function that71/// is owned by the client that pushes this72/// plan.73lldb::addr_t m_sel_str_addr; /// If this is not LLDB_INVALID_ADDRESS then it74/// is the address we wrote the selector string75/// to. We need to deallocate it when the76/// function call is done.77std::string m_sel_str; /// This is the string we wrote to memory - we78/// use it for caching, but only if79/// m_sel_str_addr is non-null.80};8182class AppleThreadPlanStepThroughDirectDispatch: public ThreadPlanStepOut {83public:84AppleThreadPlanStepThroughDirectDispatch(Thread &thread,85AppleObjCTrampolineHandler &handler,86llvm::StringRef dispatch_func_name);8788~AppleThreadPlanStepThroughDirectDispatch() override;8990void GetDescription(Stream *s, lldb::DescriptionLevel level) override;9192bool ShouldStop(Event *event_ptr) override;9394bool StopOthers() override { return false; }9596bool MischiefManaged() override;9798bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;99100void SetFlagsToDefault() override {101GetFlags().Set(ThreadPlanStepInRange::GetDefaultFlagsValue());102}103104protected:105bool DoPlanExplainsStop(Event *event_ptr) override;106107AppleObjCTrampolineHandler &m_trampoline_handler;108std::string m_dispatch_func_name; /// Which dispatch function we're stepping109/// through.110lldb::ThreadPlanSP m_objc_step_through_sp; /// When we hit an objc_msgSend,111/// we'll use this plan to get to112/// its target.113std::vector<lldb::BreakpointSP> m_msgSend_bkpts; /// Breakpoints on the objc114/// dispatch functions.115bool m_at_msg_send; /// Are we currently handling an msg_send116117};118119} // namespace lldb_private120121#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLETHREADPLANSTEPTHROUGHOBJCTRAMPOLINE_H122123124