Commit f5f70d1c authored by Derek Schuff's avatar Derek Schuff
Browse files

Add missing directory from 3ec28da6

Also revert 4697e701, restoring the original patch from
https://reviews.llvm.org/D72751
parent 3ce8095c
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ class MyResponder(MockGDBServerResponder):
            file.close()
        return result


class TestWasm(GDBRemoteTestBase):

    def setUp(self):
@@ -115,7 +116,6 @@ class TestWasm(GDBRemoteTestBase):
        lldb.DBG.SetSelectedPlatform(self._initial_platform)
        super(TestWasm, self).tearDown()

    @expectedFailureAll
    def test_load_module_with_embedded_symbols_from_remote(self):
        """Test connecting to a WebAssembly engine via GDB-remote and loading a Wasm module with embedded DWARF symbols"""

@@ -158,7 +158,6 @@ class TestWasm(GDBRemoteTestBase):
        self.assertEquals(load_address | debug_line_section.GetFileOffset(), debug_line_section.GetLoadAddress(target))


    @expectedFailureAll
    def test_load_module_with_stripped_symbols_from_remote(self):
        """Test connecting to a WebAssembly engine via GDB-remote and loading a Wasm module with symbols stripped into a separate Wasm file"""

@@ -214,7 +213,6 @@ class TestWasm(GDBRemoteTestBase):
        self.assertEquals(LLDB_INVALID_ADDRESS, debug_line_section.GetLoadAddress(target))


    @expectedFailureAll
    def test_load_module_from_file(self):
        """Test connecting to a WebAssembly engine via GDB-remote and loading a Wasm module from a file"""

+3 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@
#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
#include "Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h"
#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
#include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
@@ -274,6 +275,7 @@ llvm::Error SystemInitializerFull::Initialize() {
  DynamicLoaderMacOSXDYLD::Initialize();
  DynamicLoaderMacOS::Initialize();
  DynamicLoaderPOSIXDYLD::Initialize();
  wasm::DynamicLoaderWasmDYLD::Initialize(); // before DynamicLoaderStatic.
  DynamicLoaderStatic::Initialize();
  DynamicLoaderWindowsDYLD::Initialize();

@@ -362,6 +364,7 @@ void SystemInitializerFull::Terminate() {
  DynamicLoaderMacOSXDYLD::Terminate();
  DynamicLoaderMacOS::Terminate();
  DynamicLoaderPOSIXDYLD::Terminate();
  wasm::DynamicLoaderWasmDYLD::Terminate();
  DynamicLoaderStatic::Terminate();
  DynamicLoaderWindowsDYLD::Terminate();

+1 −0
Original line number Diff line number Diff line
@@ -4,3 +4,4 @@ add_subdirectory(POSIX-DYLD)
add_subdirectory(Static)
add_subdirectory(Hexagon-DYLD)
add_subdirectory(Windows-DYLD)
add_subdirectory(wasm-DYLD)
+9 −0
Original line number Diff line number Diff line
add_lldb_library(lldbPluginDynamicLoaderWasmDYLD PLUGIN
  DynamicLoaderWasmDYLD.cpp

  LINK_LIBS
    lldbCore
    lldbTarget
  LINK_COMPONENTS
    Support
  )
+68 −0
Original line number Diff line number Diff line
//===-- DynamicLoaderWasmDYLD.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "DynamicLoaderWasmDYLD.h"

#include "Plugins/ObjectFile/wasm/ObjectFileWasm.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/Log.h"

using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::wasm;

DynamicLoaderWasmDYLD::DynamicLoaderWasmDYLD(Process *process)
    : DynamicLoader(process) {}

void DynamicLoaderWasmDYLD::Initialize() {
  PluginManager::RegisterPlugin(GetPluginNameStatic(),
                                GetPluginDescriptionStatic(), CreateInstance);
}

ConstString DynamicLoaderWasmDYLD::GetPluginNameStatic() {
  static ConstString g_plugin_name("wasm-dyld");
  return g_plugin_name;
}

const char *DynamicLoaderWasmDYLD::GetPluginDescriptionStatic() {
  return "Dynamic loader plug-in that watches for shared library "
         "loads/unloads in WebAssembly engines.";
}

DynamicLoader *DynamicLoaderWasmDYLD::CreateInstance(Process *process,
                                                     bool force) {
  bool should_create = force;
  if (!should_create) {
    should_create =
        (process->GetTarget().GetArchitecture().GetTriple().getArch() ==
         llvm::Triple::wasm32);
  }

  if (should_create)
    return new DynamicLoaderWasmDYLD(process);

  return nullptr;
}

void DynamicLoaderWasmDYLD::DidAttach() {
  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
  LLDB_LOGF(log, "DynamicLoaderWasmDYLD::%s()", __FUNCTION__);

  // Ask the process for the list of loaded WebAssembly modules.
  auto error = m_process->LoadModules();
  LLDB_LOG_ERROR(log, std::move(error), "Couldn't load modules: {0}");
}

ThreadPlanSP DynamicLoaderWasmDYLD::GetStepThroughTrampolinePlan(Thread &thread,
                                                                 bool stop) {
  return ThreadPlanSP();
}
Loading