Path: blob/main/contrib/llvm-project/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
39648 views
//===-- DynamicLoaderWasmDYLD.cpp -----------------------------------------===//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#include "DynamicLoaderWasmDYLD.h"910#include "Plugins/ObjectFile/wasm/ObjectFileWasm.h"11#include "lldb/Core/Module.h"12#include "lldb/Core/PluginManager.h"13#include "lldb/Core/Section.h"14#include "lldb/Target/Process.h"15#include "lldb/Target/Target.h"16#include "lldb/Utility/LLDBLog.h"17#include "lldb/Utility/Log.h"1819using namespace lldb;20using namespace lldb_private;21using namespace lldb_private::wasm;2223LLDB_PLUGIN_DEFINE(DynamicLoaderWasmDYLD)2425DynamicLoaderWasmDYLD::DynamicLoaderWasmDYLD(Process *process)26: DynamicLoader(process) {}2728void DynamicLoaderWasmDYLD::Initialize() {29PluginManager::RegisterPlugin(GetPluginNameStatic(),30GetPluginDescriptionStatic(), CreateInstance);31}3233llvm::StringRef DynamicLoaderWasmDYLD::GetPluginDescriptionStatic() {34return "Dynamic loader plug-in that watches for shared library "35"loads/unloads in WebAssembly engines.";36}3738DynamicLoader *DynamicLoaderWasmDYLD::CreateInstance(Process *process,39bool force) {40bool should_create = force;41if (!should_create) {42should_create =43(process->GetTarget().GetArchitecture().GetTriple().getArch() ==44llvm::Triple::wasm32);45}4647if (should_create)48return new DynamicLoaderWasmDYLD(process);4950return nullptr;51}5253void DynamicLoaderWasmDYLD::DidAttach() {54Log *log = GetLog(LLDBLog::DynamicLoader);55LLDB_LOGF(log, "DynamicLoaderWasmDYLD::%s()", __FUNCTION__);5657// Ask the process for the list of loaded WebAssembly modules.58auto error = m_process->LoadModules();59LLDB_LOG_ERROR(log, std::move(error), "Couldn't load modules: {0}");60}6162ThreadPlanSP DynamicLoaderWasmDYLD::GetStepThroughTrampolinePlan(Thread &thread,63bool stop) {64return ThreadPlanSP();65}6667lldb::ModuleSP DynamicLoaderWasmDYLD::LoadModuleAtAddress(68const lldb_private::FileSpec &file, lldb::addr_t link_map_addr,69lldb::addr_t base_addr, bool base_addr_is_offset) {70if (ModuleSP module_sp = DynamicLoader::LoadModuleAtAddress(71file, link_map_addr, base_addr, base_addr_is_offset))72return module_sp;7374if (ModuleSP module_sp = m_process->ReadModuleFromMemory(file, base_addr)) {75UpdateLoadedSections(module_sp, link_map_addr, base_addr, false);76m_process->GetTarget().GetImages().AppendIfNeeded(module_sp);77return module_sp;78}7980return nullptr;81}828384