[Lldb-commits] [llvm] [compiler-rt] [lldb] [mlir] [libc] [libcxx] [openmp] [clang] [flang] [lld] [polly] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)
@@ -0,0 +1,125 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -O0 | FileCheck %s dschuff wrote: Is there a test that covers this behavior for DAG ISel? Maybe it would make sense to add test expectations for both here? https://github.com/llvm/llvm-project/pull/77281 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [polly] [flang] [mlir] [openmp] [libc] [compiler-rt] [lld] [llvm] [lldb] [clang] [libcxx] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)
https://github.com/dschuff approved this pull request. Thanks for the fix! https://github.com/llvm/llvm-project/pull/77281 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [clang] [lld] [libcxx] [libc] [mlir] [compiler-rt] [openmp] [polly] [flang] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)
@@ -839,9 +839,11 @@ bool WebAssemblyFastISel::selectCall(const Instruction *I) { unsigned Reg; -if (Attrs.hasParamAttr(I, Attribute::SExt)) +if (Attrs.hasParamAttr(I, Attribute::SExt) || +(IsDirect && Func->hasParamAttribute(I, Attribute::SExt))) dschuff wrote: Pointers are (on their way to being) opaque; I forget whether function pointers ever had these parameters attached, but in any case they soon won't, so for indirect calls I think it should just be the instruction. https://github.com/llvm/llvm-project/pull/77281 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lld] [compiler-rt] [openmp] [flang] [lldb] [libcxx] [libc] [mlir] [llvm] [clang] [polly] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)
dschuff wrote: Yeah, sorry I missed Alex's suggestion there. There's no hurry. https://github.com/llvm/llvm-project/pull/77281 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2ae385e - [WebAssembly] Add WASM_SEC_LAST_KNOWN to BinaryFormat section types list [NFC]
Author: Derek Schuff Date: 2022-06-07T12:05:23-07:00 New Revision: 2ae385e560a62a18942cbc202cd19313c6c59470 URL: https://github.com/llvm/llvm-project/commit/2ae385e560a62a18942cbc202cd19313c6c59470 DIFF: https://github.com/llvm/llvm-project/commit/2ae385e560a62a18942cbc202cd19313c6c59470.diff LOG: [WebAssembly] Add WASM_SEC_LAST_KNOWN to BinaryFormat section types list [NFC] There are 3 places where we were using WASM_SEC_TAG as the "last" known section type, which requires updating (or leaves a bug) when a new known section type is added. Instead add a "last type" to the enum for this purpose. Differential Revision: https://reviews.llvm.org/D127164 Added: Modified: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp llvm/include/llvm/BinaryFormat/Wasm.h llvm/lib/ObjCopy/wasm/WasmReader.cpp llvm/lib/Object/WasmObjectFile.cpp Removed: diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp index 58be1d0c7dbe..905e9637493b 100644 --- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp +++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp @@ -192,7 +192,7 @@ bool ObjectFileWasm::DecodeNextSection(lldb::offset_t *offset_ptr) { m_sect_infos.push_back(section_info{*offset_ptr + c.tell(), section_length, section_id, *sect_name}); *offset_ptr += (c.tell() + section_length); - } else if (section_id <= llvm::wasm::WASM_SEC_TAG) { + } else if (section_id <= llvm::wasm::WASM_SEC_LAST_KNOWN) { m_sect_infos.push_back(section_info{*offset_ptr + c.tell(), static_cast(payload_len), section_id, ConstString()}); diff --git a/llvm/include/llvm/BinaryFormat/Wasm.h b/llvm/include/llvm/BinaryFormat/Wasm.h index 4b6a1d584077..62a6881ef36a 100644 --- a/llvm/include/llvm/BinaryFormat/Wasm.h +++ b/llvm/include/llvm/BinaryFormat/Wasm.h @@ -252,7 +252,8 @@ enum : unsigned { WASM_SEC_CODE = 10, // Function bodies (code) WASM_SEC_DATA = 11, // Data segments WASM_SEC_DATACOUNT = 12, // Data segment count - WASM_SEC_TAG = 13// Tag declarations + WASM_SEC_TAG = 13, // Tag declarations + WASM_SEC_LAST_KNOWN = WASM_SEC_TAG, }; // Type immediate encodings used in various contexts. diff --git a/llvm/lib/ObjCopy/wasm/WasmReader.cpp b/llvm/lib/ObjCopy/wasm/WasmReader.cpp index 3725c95626cf..6e7d8b5591c9 100644 --- a/llvm/lib/ObjCopy/wasm/WasmReader.cpp +++ b/llvm/lib/ObjCopy/wasm/WasmReader.cpp @@ -24,15 +24,12 @@ Expected> Reader::create() const { const WasmSection &WS = WasmObj.getWasmSection(Sec); Obj->Sections.push_back( {static_cast(WS.Type), WS.Name, WS.Content}); -// Give known sections standard names to allow them to be selected. +// Give known sections standard names to allow them to be selected. (Custom +// sections already have their names filled in by the parser). Section &ReaderSec = Obj->Sections.back(); if (ReaderSec.SectionType > WASM_SEC_CUSTOM && -ReaderSec.SectionType <= WASM_SEC_TAG) +ReaderSec.SectionType <= WASM_SEC_LAST_KNOWN) ReaderSec.Name = sectionTypeToString(ReaderSec.SectionType); -// If the section type is CUSTOM, it has a name already. If it's a new type -// of section that we don't explicitly handle here, it will have an empty -// name and objcopy won't be able to select it by name (e.g. for removal -// or dumping) but it will still be valid and able to be copied. } return std::move(Obj); } diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index 73c2f868492e..0e99c2129571 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -1729,7 +1729,7 @@ Expected WasmObjectFile::getSectionName(DataRefImpl Sec) const { const WasmSection &S = Sections[Sec.d.a]; if (S.Type == wasm::WASM_SEC_CUSTOM) return S.Name; - if (S.Type > wasm::WASM_SEC_TAG) + if (S.Type > wasm::WASM_SEC_LAST_KNOWN) return createStringError(object_error::invalid_section_index, ""); return wasm::sectionTypeToString(S.Type); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4e266ea - Make DWARFExpression::GetLocationExpression public
Author: Eric Leese Date: 2020-08-20T15:12:28-07:00 New Revision: 4e266eaf132fa7e16eb6593dcfe4f4b9f55ea092 URL: https://github.com/llvm/llvm-project/commit/4e266eaf132fa7e16eb6593dcfe4f4b9f55ea092 DIFF: https://github.com/llvm/llvm-project/commit/4e266eaf132fa7e16eb6593dcfe4f4b9f55ea092.diff LOG: Make DWARFExpression::GetLocationExpression public This method is used to get the DataExtractor when the expression is a location list. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D86090 Added: Modified: lldb/include/lldb/Expression/DWARFExpression.h Removed: diff --git a/lldb/include/lldb/Expression/DWARFExpression.h b/lldb/include/lldb/Expression/DWARFExpression.h index 6b63b186e3e43..c7d4e4b1882fd 100644 --- a/lldb/include/lldb/Expression/DWARFExpression.h +++ b/lldb/include/lldb/Expression/DWARFExpression.h @@ -219,6 +219,10 @@ class DWARFExpression { bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op); + llvm::Optional + GetLocationExpression(lldb::addr_t load_function_start, +lldb::addr_t addr) const; + private: /// Pretty-prints the location expression to a stream /// @@ -237,10 +241,6 @@ class DWARFExpression { void DumpLocation(Stream *s, const DataExtractor &data, lldb::DescriptionLevel level, ABI *abi) const; - llvm::Optional - GetLocationExpression(lldb::addr_t load_function_start, -lldb::addr_t addr) const; - /// Module which defined this expression. lldb::ModuleWP m_module_wp; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c1709e5 - Set appropriate host defines for building under emscripten
Author: Derek Schuff Date: 2020-06-18T17:00:53-07:00 New Revision: c1709e5d90e613917d616a7866ee52cfac311de6 URL: https://github.com/llvm/llvm-project/commit/c1709e5d90e613917d616a7866ee52cfac311de6 DIFF: https://github.com/llvm/llvm-project/commit/c1709e5d90e613917d616a7866ee52cfac311de6.diff LOG: Set appropriate host defines for building under emscripten Emscripten has emulations for several headers found on Linux, including spwan.h and endian.h Differential Revision: https://reviews.llvm.org/D82121 Added: Modified: lldb/include/lldb/Host/HostInfo.h lldb/source/Host/common/Host.cpp llvm/include/llvm/Support/SwapByteOrder.h Removed: diff --git a/lldb/include/lldb/Host/HostInfo.h b/lldb/include/lldb/Host/HostInfo.h index a9b10aed47c2..b7010d69d88e 100644 --- a/lldb/include/lldb/Host/HostInfo.h +++ b/lldb/include/lldb/Host/HostInfo.h @@ -35,7 +35,7 @@ #if defined(_WIN32) #include "lldb/Host/windows/HostInfoWindows.h" #define HOST_INFO_TYPE HostInfoWindows -#elif defined(__linux__) +#elif defined(__linux__) || defined(__EMSCRIPTEN__) #if defined(__ANDROID__) #include "lldb/Host/android/HostInfoAndroid.h" #define HOST_INFO_TYPE HostInfoAndroid diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index a5705c92afec..4128fa19c142 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -28,7 +28,7 @@ #if defined(__linux__) || defined(__FreeBSD__) || \ defined(__FreeBSD_kernel__) || defined(__APPLE__) || \ -defined(__NetBSD__) || defined(__OpenBSD__) +defined(__NetBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__) #if !defined(__ANDROID__) #include #endif diff --git a/llvm/include/llvm/Support/SwapByteOrder.h b/llvm/include/llvm/Support/SwapByteOrder.h index a9f43735328f..500df2355307 100644 --- a/llvm/include/llvm/Support/SwapByteOrder.h +++ b/llvm/include/llvm/Support/SwapByteOrder.h @@ -21,7 +21,8 @@ #include #endif -#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) +#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \ +defined(__EMSCRIPTEN__) #include #elif defined(_AIX) #include ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4bafcec - [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging
Author: Paolo Severini Date: 2020-01-15T16:25:35-08:00 New Revision: 4bafceced6a7641be7b090229c6ccef22cf55bff URL: https://github.com/llvm/llvm-project/commit/4bafceced6a7641be7b090229c6ccef22cf55bff DIFF: https://github.com/llvm/llvm-project/commit/4bafceced6a7641be7b090229c6ccef22cf55bff.diff LOG: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging Summary: This is the first in a series of patches to enable LLDB debugging of WebAssembly targets. Current versions of Clang emit (partial) DWARF debug information in WebAssembly modules and we can leverage this debug information to give LLDB the ability to do source-level debugging of Wasm code that runs in a WebAssembly engine. A way to do this could be to use the remote debugging functionalities provided by LLDB via the GDB-remote protocol. Remote debugging can indeed be useful not only to connect a debugger to a process running on a remote machine, but also to connect the debugger to a managed VM or script engine that runs locally, provided that the engine implements a GDB-remote stub that offers the ability to access the engine runtime internal state. To make this work, the GDB-remote protocol would need to be extended with a few Wasm-specific custom query commands, used to access aspects of the Wasm engine state (like the Wasm memory, Wasm local and global variables, and so on). Furthermore, the DWARF format would need to be enriched with a few Wasm-specific extensions, here detailed: https://yurydelendik.github.io/webassembly-dwarf. This CL introduce classes **ObjectFileWasm**, a file plugin to represent a Wasm module loaded in a debuggee process. It knows how to parse Wasm modules and store the Code section and the DWARF-specific sections. Reviewers: jasonmolenda, clayborg, labath Tags: #lldb Differential Revision: https://reviews.llvm.org/D71575 Added: lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h lldb/test/Shell/ObjectFile/wasm/basic.yaml lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml Modified: lldb/include/lldb/Utility/ArchSpec.h lldb/source/API/SystemInitializerFull.cpp lldb/source/Plugins/ObjectFile/CMakeLists.txt lldb/source/Utility/ArchSpec.cpp lldb/tools/lldb-test/SystemInitializerTest.cpp Removed: diff --git a/lldb/include/lldb/Utility/ArchSpec.h b/lldb/include/lldb/Utility/ArchSpec.h index 15e2fdb10c32..6e209dfd2e46 100644 --- a/lldb/include/lldb/Utility/ArchSpec.h +++ b/lldb/include/lldb/Utility/ArchSpec.h @@ -188,6 +188,8 @@ class ArchSpec { eCore_arc, // little endian ARC +eCore_wasm32, + kNumCores, kCore_invalid, diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp index 06f1a6cd3b75..2c567974891c 100644 --- a/lldb/source/API/SystemInitializerFull.cpp +++ b/lldb/source/API/SystemInitializerFull.cpp @@ -73,6 +73,7 @@ #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" +#include "Plugins/ObjectFile/wasm/ObjectFileWasm.h" #include "Plugins/OperatingSystem/Python/OperatingSystemPython.h" #include "Plugins/Platform/Android/PlatformAndroid.h" #include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h" @@ -177,6 +178,7 @@ llvm::Error SystemInitializerFull::Initialize() { ObjectFileELF::Initialize(); ObjectFileMachO::Initialize(); ObjectFilePECOFF::Initialize(); + wasm::ObjectFileWasm::Initialize(); ObjectContainerBSDArchive::Initialize(); ObjectContainerUniversalMachO::Initialize(); @@ -404,6 +406,7 @@ void SystemInitializerFull::Terminate() { ObjectFileELF::Terminate(); ObjectFileMachO::Terminate(); ObjectFilePECOFF::Terminate(); + wasm::ObjectFileWasm::Terminate(); ObjectContainerBSDArchive::Terminate(); ObjectContainerUniversalMachO::Terminate(); diff --git a/lldb/source/Plugins/ObjectFile/CMakeLists.txt b/lldb/source/Plugins/ObjectFile/CMakeLists.txt index 4edd667b9723..76f6d7ad0d78 100644 --- a/lldb/source/Plugins/ObjectFile/CMakeLists.txt +++ b/lldb/source/Plugins/ObjectFile/CMakeLists.txt @@ -3,3 +3,4 @@ add_subdirectory(ELF) add_subdirectory(Mach-O) add_subdirectory(PECOFF) add_subdirectory(JIT) +add_subdirectory(wasm) \ No newline at end of file diff --git a/lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt b/lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt new file mode 100644 index ..5069b6b19b95 --- /dev/null +++ b/lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt @@ -0,0 +1,11 @@ +add_lldb_library(lldbPluginObjectFileWasm PLUGIN + ObjectFileWasm.cpp + + LINK_LIBS +lldbCore +lldbHost +lldbSymbol +lldbUtility + LINK_COMPONENTS +Sup
[Lldb-commits] [lldb] 9b3254d - [LLDB] Add SymbolVendorWasm plugin for WebAssembly debugging
Author: Paolo Severini Date: 2020-01-16T09:36:17-08:00 New Revision: 9b3254dbf9f6624c772db7cfa7a3c29a0b94be8e URL: https://github.com/llvm/llvm-project/commit/9b3254dbf9f6624c772db7cfa7a3c29a0b94be8e DIFF: https://github.com/llvm/llvm-project/commit/9b3254dbf9f6624c772db7cfa7a3c29a0b94be8e.diff LOG: [LLDB] Add SymbolVendorWasm plugin for WebAssembly debugging Add plugin class SymbolVendorWasm, with the logic to manage debug symbols for Wasm modules. Reviewers: clayborg, labath, aprantl, sbc100, teemperor Reviewed By: labath Tags: #lldb Differential Revision: https://reviews.llvm.org/D72650 Added: lldb/source/Plugins/SymbolVendor/wasm/CMakeLists.txt lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml Modified: lldb/source/API/SystemInitializerFull.cpp lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h lldb/source/Plugins/SymbolVendor/CMakeLists.txt lldb/tools/lldb-test/SystemInitializerTest.cpp Removed: diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp index 2c567974891c..2bc53af91d00 100644 --- a/lldb/source/API/SystemInitializerFull.cpp +++ b/lldb/source/API/SystemInitializerFull.cpp @@ -95,6 +95,7 @@ #include "Plugins/SymbolFile/PDB/SymbolFilePDB.h" #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" #include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h" +#include "Plugins/SymbolVendor/wasm/SymbolVendorWasm.h" #include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h" #include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h" #include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h" @@ -242,6 +243,7 @@ llvm::Error SystemInitializerFull::Initialize() { SymbolFileDWARF::Initialize(); SymbolFilePDB::Initialize(); SymbolFileSymtab::Initialize(); + wasm::SymbolVendorWasm::Initialize(); UnwindAssemblyInstEmulation::Initialize(); UnwindAssembly_x86::Initialize(); @@ -334,6 +336,7 @@ void SystemInitializerFull::Terminate() { ThreadSanitizerRuntime::Terminate(); UndefinedBehaviorSanitizerRuntime::Terminate(); MainThreadCheckerRuntime::Terminate(); + wasm::SymbolVendorWasm::Terminate(); SymbolVendorELF::Terminate(); breakpad::SymbolFileBreakpad::Terminate(); SymbolFileDWARF::Terminate(); diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp index 2c918a8f9db3..bd4c3597b066 100644 --- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp +++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp @@ -72,6 +72,8 @@ GetWasmString(llvm::DataExtractor &data, llvm::DataExtractor::Cursor &c) { return ConstString(str); } +char ObjectFileWasm::ID; + void ObjectFileWasm::Initialize() { PluginManager::RegisterPlugin(GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance, @@ -177,6 +179,9 @@ bool ObjectFileWasm::DecodeNextSection(lldb::offset_t *offset_ptr) { return false; if (section_id == llvm::wasm::WASM_SEC_CUSTOM) { +// Custom sections have the id 0. Their contents consist of a name +// identifying the custom section, followed by an uninterpreted sequence +// of bytes. lldb::offset_t prev_offset = c.tell(); llvm::Optional sect_name = GetWasmString(data, c); if (!sect_name) @@ -389,6 +394,24 @@ DataExtractor ObjectFileWasm::ReadImageData(uint64_t offset, size_t size) { return data; } +llvm::Optional ObjectFileWasm::GetExternalDebugInfoFileSpec() { + static ConstString g_sect_name_external_debug_info("external_debug_info"); + + for (const section_info ยง_info : m_sect_infos) { +if (g_sect_name_external_debug_info == sect_info.name) { + const uint32_t kBufferSize = 1024; + DataExtractor section_header_data = + ReadImageData(sect_info.offset, kBufferSize); + llvm::DataExtractor data = section_header_data.GetAsLLVM(); + llvm::DataExtractor::Cursor c(0); + llvm::Optional symbols_url = GetWasmString(data, c); + if (symbols_url) +return FileSpec(symbols_url->GetStringRef()); +} + } + return llvm::None; +} + void ObjectFileWasm::Dump(Stream *s) { ModuleSP module_sp(GetModule()); if (!module_sp) diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h index 986f7f9f1679..65d237e20450 100644 --- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h +++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h @@ -52,6 +52,15 @@ class ObjectFileWasm : public ObjectFile { uint32_t GetPluginVersion() override { return 1; } /// \} + /// LLVM RTTI support + /// \{ + static char ID; + bool
[Lldb-commits] [lldb] d34e415 - [LLDB] Convert Plugins/ObjectFile/wasm/ObjectFileWasm.h to unix line endings
Author: Derek Schuff Date: 2020-01-16T09:38:37-08:00 New Revision: d34e4152e3e057b311d7d6c0c93dc30fa76aa94f URL: https://github.com/llvm/llvm-project/commit/d34e4152e3e057b311d7d6c0c93dc30fa76aa94f DIFF: https://github.com/llvm/llvm-project/commit/d34e4152e3e057b311d7d6c0c93dc30fa76aa94f.diff LOG: [LLDB] Convert Plugins/ObjectFile/wasm/ObjectFileWasm.h to unix line endings Added: Modified: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h Removed: diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h index 65d237e20450..36ef56fe2cce 100644 --- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h +++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h @@ -1,153 +1,153 @@ -//===-- ObjectFileWasm.h *- C++ -*-===// -// -// 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 -// -//===--===// - -#ifndef LLDB_PLUGINS_OBJECTFILE_WASM_OBJECTFILEWASM_H -#define LLDB_PLUGINS_OBJECTFILE_WASM_OBJECTFILEWASM_H - -#include "lldb/Symbol/ObjectFile.h" -#include "lldb/Utility/ArchSpec.h" - -namespace lldb_private { -namespace wasm { - -/// Generic Wasm object file reader. -/// -/// This class provides a generic wasm32 reader plugin implementing the -/// ObjectFile protocol. -class ObjectFileWasm : public ObjectFile { -public: - static void Initialize(); - static void Terminate(); - - static ConstString GetPluginNameStatic(); - static const char *GetPluginDescriptionStatic() { -return "WebAssembly object file reader."; - } - - static ObjectFile * - CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, - lldb::offset_t data_offset, const FileSpec *file, - lldb::offset_t file_offset, lldb::offset_t length); - - static ObjectFile *CreateMemoryInstance(const lldb::ModuleSP &module_sp, - lldb::DataBufferSP &data_sp, - const lldb::ProcessSP &process_sp, - lldb::addr_t header_addr); - - static size_t GetModuleSpecifications(const FileSpec &file, -lldb::DataBufferSP &data_sp, -lldb::offset_t data_offset, -lldb::offset_t file_offset, -lldb::offset_t length, -ModuleSpecList &specs); - - /// PluginInterface protocol. - /// \{ - ConstString GetPluginName() override { return GetPluginNameStatic(); } - uint32_t GetPluginVersion() override { return 1; } - /// \} - - /// LLVM RTTI support - /// \{ - static char ID; - bool isA(const void *ClassID) const override { -return ClassID == &ID || ObjectFile::isA(ClassID); - } - static bool classof(const ObjectFile *obj) { return obj->isA(&ID); } - /// \} - - /// ObjectFile Protocol. - /// \{ - bool ParseHeader() override; - - lldb::ByteOrder GetByteOrder() const override { -return m_arch.GetByteOrder(); - } - - bool IsExecutable() const override { return true; } - - uint32_t GetAddressByteSize() const override { -return m_arch.GetAddressByteSize(); - } - - AddressClass GetAddressClass(lldb::addr_t file_addr) override { -return AddressClass::eInvalid; - } - - Symtab *GetSymtab() override; - - bool IsStripped() override { return true; } - - void CreateSections(SectionList &unified_section_list) override; - - void Dump(Stream *s) override; - - ArchSpec GetArchitecture() override { return m_arch; } - - UUID GetUUID() override { return m_uuid; } - - uint32_t GetDependentModules(FileSpecList &files) override { return 0; } - - Type CalculateType() override { return eTypeExecutable; } - - Strata CalculateStrata() override { return eStrataUser; } - - bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value, - bool value_is_offset) override; - - lldb_private::Address GetBaseAddress() override { -return IsInMemory() ? Address(m_memory_addr + m_code_section_offset) -: Address(m_code_section_offset); - } - /// \} - - /// A Wasm module that has external DWARF debug information should contain a - /// custom section named "external_debug_info", whose payload is an UTF-8 - /// encoded string that points to a Wasm module that contains the debug - /// information for this module. - llvm::Optional GetExternalDebugInfoFileSpec(); - -private: - ObjectFileWasm(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, - lldb::offset_t data_offset, const FileSpec *fil
[Lldb-commits] [lldb] 3ec28da - [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging
Author: Paolo Severini Date: 2020-02-05T14:49:36-08:00 New Revision: 3ec28da6d6430a00b46780555a87acd43fcab790 URL: https://github.com/llvm/llvm-project/commit/3ec28da6d6430a00b46780555a87acd43fcab790 DIFF: https://github.com/llvm/llvm-project/commit/3ec28da6d6430a00b46780555a87acd43fcab790.diff LOG: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging Add a dynamic loader plug-in class for WebAssembly modules. Differential Revision: https://reviews.llvm.org/D72751 Added: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_sym.yaml lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_embedded_debug_sections.yaml lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/test_wasm_external_debug_sections.yaml Modified: lldb/source/API/SystemInitializerFull.cpp lldb/source/Plugins/DynamicLoader/CMakeLists.txt lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h lldb/test/Shell/ObjectFile/wasm/basic.yaml lldb/test/Shell/ObjectFile/wasm/embedded-debug-sections.yaml lldb/test/Shell/ObjectFile/wasm/stripped-debug-sections.yaml lldb/test/Shell/ObjectFile/wasm/unified-debug-sections.yaml lldb/tools/lldb-test/SystemInitializerTest.cpp Removed: diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py new file mode 100644 index ..38b34f6d7417 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py @@ -0,0 +1,273 @@ +import lldb +import binascii +import struct +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +from gdbclientutils import * + +LLDB_INVALID_ADDRESS = 0x +load_address = 0x4 + +def format_register_value(val): +""" +Encode each byte by two hex digits in little-endian order. +""" +return ''.join(x.encode('hex') for x in struct.pack('>= 7 +if val != 0: +byte |= 0x80 # mark this byte to show that more bytes will follow +result.append(byte) +if val == 0: +break +return result + + +def encode_wasm_string(s): +""" +Encode a string as an array of UTF-8 bytes preceded by its ULEB128 length. +""" +char_array = bytearray(x.encode("utf8") for x in s) +return uleb128_encode(len(char_array)) + char_array + + +def format_bytearray_as_hexstring(byte_array): +""" +Encode a n array of bytes as a string of hexadecimal digits. +""" +return ''.join(format(x, '02x') for x in byte_array) + + +class MyResponder(MockGDBServerResponder): +current_pc = load_address + 0x0a + +def __init__(self, obj_path): +self._obj_path = obj_path +MockGDBServerResponder.__init__(self) + +def respond(self, packet): +if packet == "qProcessInfo": +return self.qProcessInfo() +if packet[0:13] == "qRegisterInfo": +return self.qRegisterInfo(packet[13:]) +return MockGDBServerResponder.respond(self, packet) + +def qSupported(self, client_supported): +return "qXfer:libraries:read+;PacketSize=1000;vContSupported-" + +def qHostInfo(self): +return "" + +def QEnableErrorStrings(self): +return "" + +def qfThreadInfo(self): +return "OK" + +def qRegisterInfo(self, index): +if int(index) == 0: +return "name:pc;alt-name:pc;bitsize:64;offset:0;encoding:uint;format:hex;set:General Purpose Registers;gcc:16;dwarf:16;generic:pc;" +return "E45" + +def qProcessInfo(self): +return "pid:1;ppid:1;uid:1;gid:1;euid:1;egid:1;name:%s;triple:%s;ptrsize:4" % (hex_encode_bytes("lldb"), hex_encode_bytes("wasm32-unknown-unknown-wasm")) + +def haltReason(self): +return "T05thread-pcs:" + format(self.current_pc, 'x') + ";thread:1;" + +def readRegister(self, register): +return format_register_value(self.current_pc) + +def qXferRead(self, obj, annex, offset, length): +if obj == "libraries": +xml = '' % ("test_wasm", load_address) +return xml, False +else: +return None, False + +def readMemory(self, addr, length): +if addr < load_address: +return "E02" +result = "" +with open(self._obj_path, mode='rb') as file: +file_content = bytearray(file.read()) +addr_from = addr - load_address +addr_to = addr_from + min(length, len(file_content) - addr_from) +for i in range(addr_from, addr_to): +result += format(file_content[i], '02x') +file.cl
[Lldb-commits] [lldb] f5f70d1 - Add missing directory from 3ec28da6
Author: Derek Schuff Date: 2020-02-05T15:49:48-08:00 New Revision: f5f70d1c8fbf12249b4b9598f10a10f12d4db029 URL: https://github.com/llvm/llvm-project/commit/f5f70d1c8fbf12249b4b9598f10a10f12d4db029 DIFF: https://github.com/llvm/llvm-project/commit/f5f70d1c8fbf12249b4b9598f10a10f12d4db029.diff LOG: Add missing directory from 3ec28da6 Also revert 4697e701b8, restoring the original patch from https://reviews.llvm.org/D72751 Added: lldb/source/Plugins/DynamicLoader/wasm-DYLD/CMakeLists.txt lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h Modified: lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py lldb/source/API/SystemInitializerFull.cpp lldb/source/Plugins/DynamicLoader/CMakeLists.txt lldb/tools/lldb-test/SystemInitializerTest.cpp Removed: diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py index eb136dce0fab..38b34f6d7417 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestWasm.py @@ -105,6 +105,7 @@ def readMemory(self, addr, length): file.close() return result + class TestWasm(GDBRemoteTestBase): def setUp(self): @@ -115,7 +116,6 @@ def tearDown(self): 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 @@ def test_load_module_with_embedded_symbols_from_remote(self): 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""" @@ -185,7 +184,7 @@ def test_load_module_with_stripped_symbols_from_remote(self): target = self.dbg.CreateTarget("") process = self.connect(target) lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, [lldb.eStateStopped]) - + num_modules = target.GetNumModules() self.assertEquals(1, num_modules) @@ -214,7 +213,6 @@ def test_load_module_with_stripped_symbols_from_remote(self): 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""" @@ -245,7 +243,7 @@ def readMemory(self, addr, length): target = self.dbg.CreateTarget("") process = self.connect(target) lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, [lldb.eStateStopped]) - + num_modules = target.GetNumModules() self.assertEquals(1, num_modules) diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp index d518c577c7d1..4b7e3337c59e 100644 --- a/lldb/source/API/SystemInitializerFull.cpp +++ b/lldb/source/API/SystemInitializerFull.cpp @@ -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(); diff --git a/lldb/source/Plugins/DynamicLoader/CMakeLists.txt b/lldb/source/Plugins/DynamicLoader/CMakeLists.txt index 9f3b2ab0e50f..f357fea02efb 100644 --- a/lldb/source/Plugins