LLDB  mainline
DynamicLoaderWasmDYLD.cpp
Go to the documentation of this file.
1 //===-- DynamicLoaderWasmDYLD.cpp -----------------------------------------===//
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 
10 
12 #include "lldb/Core/Module.h"
14 #include "lldb/Core/Section.h"
15 #include "lldb/Target/Process.h"
16 #include "lldb/Target/Target.h"
17 #include "lldb/Utility/Log.h"
18 
19 using namespace lldb;
20 using namespace lldb_private;
21 using namespace lldb_private::wasm;
22 
24 
26  : DynamicLoader(process) {}
27 
28 void DynamicLoaderWasmDYLD::Initialize() {
29  PluginManager::RegisterPlugin(GetPluginNameStatic(),
30  GetPluginDescriptionStatic(), CreateInstance);
31 }
32 
33 ConstString DynamicLoaderWasmDYLD::GetPluginNameStatic() {
34  static ConstString g_plugin_name("wasm-dyld");
35  return g_plugin_name;
36 }
37 
38 const char *DynamicLoaderWasmDYLD::GetPluginDescriptionStatic() {
39  return "Dynamic loader plug-in that watches for shared library "
40  "loads/unloads in WebAssembly engines.";
41 }
42 
43 DynamicLoader *DynamicLoaderWasmDYLD::CreateInstance(Process *process,
44  bool force) {
45  bool should_create = force;
46  if (!should_create) {
47  should_create =
48  (process->GetTarget().GetArchitecture().GetTriple().getArch() ==
49  llvm::Triple::wasm32);
50  }
51 
52  if (should_create)
53  return new DynamicLoaderWasmDYLD(process);
54 
55  return nullptr;
56 }
57 
58 void DynamicLoaderWasmDYLD::DidAttach() {
60  LLDB_LOGF(log, "DynamicLoaderWasmDYLD::%s()", __FUNCTION__);
61 
62  // Ask the process for the list of loaded WebAssembly modules.
63  auto error = m_process->LoadModules();
64  LLDB_LOG_ERROR(log, std::move(error), "Couldn't load modules: {0}");
65 }
66 
67 ThreadPlanSP DynamicLoaderWasmDYLD::GetStepThroughTrampolinePlan(Thread &thread,
68  bool stop) {
69  return ThreadPlanSP();
70 }
LIBLLDB_LOG_DYNAMIC_LOADER
#define LIBLLDB_LOG_DYNAMIC_LOADER
Definition: Logging.h:17
ObjectFileWasm.h
lldb_private::wasm
Definition: DynamicLoaderWasmDYLD.h:15
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:249
lldb_private::Process
Definition: Process.h:341
Module.h
DynamicLoaderWasmDYLD.h
lldb_private::Process::GetTarget
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1209
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:444
Section.h
Process.h
Target.h
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
Log.h
lldb_private::Thread
Definition: Thread.h:60
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::DynamicLoader
Definition: DynamicLoader.h:52
lldb_private::Target::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: Target.h:967
PluginManager.h
lldb_private::wasm::DynamicLoaderWasmDYLD
Definition: DynamicLoaderWasmDYLD.h:17
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
LLDB_PLUGIN_DEFINE
#define LLDB_PLUGIN_DEFINE(PluginName)
Definition: PluginManager.h:31
lldb_private::Log
Definition: Log.h:49
lldb_private::GetLogIfAnyCategoriesSet
Log * GetLogIfAnyCategoriesSet(uint32_t mask)
Definition: Logging.cpp:62
lldb
Definition: SBAddress.h:15
LLDB_LOG_ERROR
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:265