Path: blob/main/contrib/llvm-project/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
39654 views
//===-- DynamicLoaderHexagonDYLD.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_DYNAMICLOADER_HEXAGON_DYLD_DYNAMICLOADERHEXAGONDYLD_H9#define LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_DYNAMICLOADERHEXAGONDYLD_H1011#include "lldb/Breakpoint/StoppointCallbackContext.h"12#include "lldb/Target/DynamicLoader.h"1314#include "HexagonDYLDRendezvous.h"1516class DynamicLoaderHexagonDYLD : public lldb_private::DynamicLoader {17public:18DynamicLoaderHexagonDYLD(lldb_private::Process *process);1920~DynamicLoaderHexagonDYLD() override;2122static void Initialize();2324static void Terminate();2526static llvm::StringRef GetPluginNameStatic() { return "hexagon-dyld"; }2728static llvm::StringRef GetPluginDescriptionStatic();2930static lldb_private::DynamicLoader *31CreateInstance(lldb_private::Process *process, bool force);3233// DynamicLoader protocol3435void DidAttach() override;3637void DidLaunch() override;3839lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread,40bool stop_others) override;4142lldb_private::Status CanLoadImage() override;4344lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module,45const lldb::ThreadSP thread,46lldb::addr_t tls_file_addr) override;4748// PluginInterface protocol49llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }5051protected:52/// Runtime linker rendezvous structure.53HexagonDYLDRendezvous m_rendezvous;5455/// Virtual load address of the inferior process.56lldb::addr_t m_load_offset;5758/// Virtual entry address of the inferior process.59lldb::addr_t m_entry_point;6061/// Rendezvous breakpoint.62lldb::break_id_t m_dyld_bid;6364/// Loaded module list. (link map for each module)65std::map<lldb::ModuleWP, lldb::addr_t, std::owner_less<lldb::ModuleWP>>66m_loaded_modules;6768/// Enables a breakpoint on a function called by the runtime69/// linker each time a module is loaded or unloaded.70bool SetRendezvousBreakpoint();7172/// Callback routine which updates the current list of loaded modules based73/// on the information supplied by the runtime linker.74static bool RendezvousBreakpointHit(75void *baton, lldb_private::StoppointCallbackContext *context,76lldb::user_id_t break_id, lldb::user_id_t break_loc_id);7778/// Helper method for RendezvousBreakpointHit. Updates LLDB's current set79/// of loaded modules.80void RefreshModules();8182/// Updates the load address of every allocatable section in \p module.83///84/// \param module The module to traverse.85///86/// \param link_map_addr The virtual address of the link map for the @p87/// module.88///89/// \param base_addr The virtual base address \p module is loaded at.90void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr,91lldb::addr_t base_addr,92bool base_addr_is_offset) override;9394/// Removes the loaded sections from the target in \p module.95///96/// \param module The module to traverse.97void UnloadSections(const lldb::ModuleSP module) override;9899/// Callback routine invoked when we hit the breakpoint on process entry.100///101/// This routine is responsible for resolving the load addresses of all102/// dependent modules required by the inferior and setting up the rendezvous103/// breakpoint.104static bool105EntryBreakpointHit(void *baton,106lldb_private::StoppointCallbackContext *context,107lldb::user_id_t break_id, lldb::user_id_t break_loc_id);108109/// Helper for the entry breakpoint callback. Resolves the load addresses110/// of all dependent modules.111void LoadAllCurrentModules();112113/// Computes a value for m_load_offset returning the computed address on114/// success and LLDB_INVALID_ADDRESS on failure.115lldb::addr_t ComputeLoadOffset();116117/// Computes a value for m_entry_point returning the computed address on118/// success and LLDB_INVALID_ADDRESS on failure.119lldb::addr_t GetEntryPoint();120121/// Checks to see if the target module has changed, updates the target122/// accordingly and returns the target executable module.123lldb::ModuleSP GetTargetExecutable();124125/// return the address of the Rendezvous breakpoint126lldb::addr_t FindRendezvousBreakpointAddress();127128private:129const lldb_private::SectionList *130GetSectionListFromModule(const lldb::ModuleSP module) const;131};132133#endif // LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_DYNAMICLOADERHEXAGONDYLD_H134135136