[Lldb-commits] [lldb] Logging setup for lldb-dap extension (PR #146884)
award999 wrote: So the approach in this PR still makes use of VSCode log rotation and persisting, where the log file goes in the same folder as LogOutputChannel would put it. So really the biggest difference I see is the verbosity of the file log vs. introducing a dependency. As long as you're fine with me moving all this to the ".info" level then I'll make that change to get something in place. Where this whole PR started was us trying to diagnose an intermittent Swift debugging failure which we have not been able to reproduce, and by the time we are able to video chat and see their screen they can not readily reproduce, but it has popped up often enough from numerous developers over the last year that something is clearly going wrong. My main concern is capturing the logging to diagnose intermittent failures without needing to configure after the fact. This approach using Winston has worked very well on numerous extensions I've worked on, but I can appreciate other developers including yourself may feel like LLDB DAP may not derive the same value from this, and for this OSS project less code to maintain is more attractive. So I'll start reverting out the dependency but at least want to move some messages from the "debug" to "info" level that would help diagnose this issue. https://github.com/llvm/llvm-project/pull/146884 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reland "[lldb][RPC] Upstream lldb-rpc-gen tool" (#146969)" Attempt 2 (PR #148996)
chelcassanova wrote: @mstorsjo @vvereschaka I can try reproducing the issue with the universal binaries on macOS, but I don't currently have a setup to try reproducing the issue with cross-compiling so I think I'll need some help there. I noted this in https://github.com/llvm/llvm-project/issues/150454, but from the error there: ``` cd /home/runner/work/llvm-mingw/llvm-mingw/llvm-project/llvm/build-thinlto-withclang-pgo-aarch64-linux-gnu && /usr/local/bin/cmake -E make_directory /home/runner/work/llvm-mingw/llvm-mingw/llvm-project/llvm/build-thinlto-withclang-pgo-aarch64-linux-gnu/tools/lldb/tools/lldb-rpc/generated && /usr/local/bin/cmake -E make_directory /home/runner/work/llvm-mingw/llvm-mingw/llvm-project/llvm/build-thinlto-withclang-pgo-aarch64-linux-gnu/tools/lldb/tools/lldb-rpc/generated/server && -p /home/runner/work/llvm-mingw/llvm-mingw/llvm-project/llvm/build-thinlto-withclang-pgo-aarch64-linux-gnu --output-dir=/home/runner/work/llvm-mingw/llvm-mingw/llvm-project/llvm/build-thinlto-withclang-pgo-aarch64-linux-gnu/tools/lldb/tools/lldb-rpc/generated --extra-arg="-USWIG" /home/runner/work/llvm-mingw/llvm-mingw/llvm-project/lldb/include/lldb/API/SBAddress.h /home/runner/work/llvm-mingw/llvm-mingw/llvm-project/lldb/include/lldb/API/SBAddressRange.h [...] /bin/sh: 1: -p: not found ``` This corresponds to this cmake command: ``` COMMAND ${LLDB_RPC_GEN_EXE} -p ${CMAKE_BINARY_DIR} --output-dir=${lldb_rpc_generated_dir} ${sysroot_arg} --extra-arg="-USWIG" ${api_headers} ``` `/bin/sh: 1: -p: not found`. From this, my guess is that the LLDB_RPC_GEN_EXE variable is not being set correctly, and this command is then attempted to be run as though the command were `-p` instead of `lldb-rpc-gen`. https://github.com/llvm/llvm-project/pull/148996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add TemplateRange and NameQualifiersRange to DemangledNameInfo (PR #150999)
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/150999 >From 9b3551c6dbf8629c49f2bf3ed3f34e7b4e52e65f Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Mon, 28 Jul 2025 18:58:44 +0200 Subject: [PATCH 1/5] [lldb] add TemplateRange and NameQualifiersRange to DemangledNameInfo --- lldb/docs/use/formatting.rst | 3 + lldb/include/lldb/Core/DemangledNameInfo.h | 25 ++ lldb/include/lldb/Core/FormatEntity.h | 1 + lldb/source/Core/FormatEntity.cpp | 3 + lldb/unittests/Core/MangledTest.cpp| 259 ++--- 5 files changed, 213 insertions(+), 78 deletions(-) diff --git a/lldb/docs/use/formatting.rst b/lldb/docs/use/formatting.rst index 39ccfed30a2ca..0b60f1e193acb 100644 --- a/lldb/docs/use/formatting.rst +++ b/lldb/docs/use/formatting.rst @@ -89,6 +89,8 @@ A complete list of currently supported format string variables is listed below: +---+-+ | ``function.name-without-args``| The name of the current function without arguments and values (used to include a function name in-line in the ``disassembly-format``) | +---+-+ +| ``function.name-qualifiers`` | Any qualifiers added after the name of a function and before its arguments or template arguments. | ++---+-+ | ``function.basename`` | The basename of the current function depending on the frame's language. E.g., for C++ the basename for ``void ns::foo::bar(int) const`` is ``bar``. | +---+-+ | ``function.prefix`` | Any prefix added to the demangled function name of the current function. This depends on the frame's language. E.g., for C++ the prefix will always be empty. | @@ -332,6 +334,7 @@ The function names displayed in backtraces/``frame info``/``thread info`` are th - ``${function.prefix}`` - ``${function.scope}`` - ``${function.basename}`` +- ``${function.name-qualifiers}`` - ``${function.template-arguments}`` - ``${function.formatted-arguments}`` - ``${function.qualifiers}`` diff --git a/lldb/include/lldb/Core/DemangledNameInfo.h b/lldb/include/lldb/Core/DemangledNameInfo.h index 9f567232dc50f..bdfcb488c2e01 100644 --- a/lldb/include/lldb/Core/DemangledNameInfo.h +++ b/lldb/include/lldb/Core/DemangledNameInfo.h @@ -30,6 +30,16 @@ struct DemangledNameInfo { /// \endcode std::pair BasenameRange; + /// A [start, end) pair for the function template arguments. + /// The basename is the name without scope qualifiers + /// and without template parameters. E.g., + /// \code{.cpp} + ///void foo::bar::someFunc(int) const && + ///^ ^ + /// start end + /// \endcode + std::pair TemplateRange; + /// A [start, end) pair for the function scope qualifiers. /// E.g., for /// \code{.cpp} @@ -59,6 +69,11 @@ struct DemangledNameInfo { /// \endcode std::pair QualifiersRange; + /// Indicates the [start, end) of the function's name qualifiers. This is a + /// catch-all rang
[Lldb-commits] [lldb] [lldb][test] Add LLDB test for UBSan trap frame recognizer (PR #151231)
https://github.com/delcypher requested changes to this pull request. https://github.com/llvm/llvm-project/pull/151231 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add LLDB test for UBSan trap frame recognizer (PR #151231)
@@ -0,0 +1,17 @@ +# REQUIRES: clang + +# RUN: %clang_host -g -O0 %S/Inputs/ubsan_add_overflow.cpp -o %t.out \ +# RUN: -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow + +# RUN: %lldb -b -s %s %t.out | FileCheck %s + +run +# CHECK: thread #{{.*}} stop reason = Undefined Behavior Sanitizer: Integer addition overflowed + +frame info +# CHECK: frame #{{.*}}`main at ubsan_add_overflow.cpp delcypher wrote: Shouldn't we be checking we skipped frame 0, and moved to frame 1? This `CHECK` line doesn't appear to do that. https://github.com/llvm/llvm-project/pull/151231 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add `ValueObject::CreateValueObjectFromScalar` and fix `Scalar::GetData` (PR #151350)
kuilpd wrote: > One big behavioral difference between your `CreateValueObjectFromValue` VO's > and the `CreateValueObjectFromAPInt` ones is that you set the child address > type to invalid, but the APInt one sets it to "load". That's fine so long as > the Value only holds ints and not pointer values. Dereference on the Value > ones will be an error - since we don't know where the children are... > > There aren't any examples of how you intend to use this yet, so I can't tell > whether that is a concern. But given it is a significant difference between > the two API's it should be called out somehow. By default its just const values, but if we aim to create a pointer type, we can just change do `ValueObject::SetAddressTypeOfChildren` after creating it. Or can just make it the default, it doesn't matter until there actually are some children, right? I'll check later if I can create pointer normally with this approach. https://github.com/llvm/llvm-project/pull/151350 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #151010)
https://github.com/Michael137 approved this pull request. https://github.com/llvm/llvm-project/pull/151010 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement RegisterContextWasm (PR #151056)
@@ -224,67 +311,68 @@ def test_load_module_with_stripped_symbols_from_remote(self): @skipIfAsan @skipIfXmlSupportMissing -def test_load_module_from_file(self): -"""Test connecting to a WebAssembly engine via GDB-remote and loading a Wasm module from a file""" +def test_simple_wasm_debugging_session(self): +"""Test connecting to a WebAssembly engine via GDB-remote, loading a +Wasm module with embedded DWARF symbols, setting a breakpoint and +checking the debuggee state""" -yaml_path = "test_wasm_embedded_debug_sections.yaml" -yaml_base, ext = os.path.splitext(yaml_path) +yaml_path = "simple.yaml" +yaml_base, _ = os.path.splitext(yaml_path) obj_path = self.getBuildArtifact(yaml_base) self.yaml2obj(yaml_path, obj_path) -self.server.responder = MyResponder(obj_path) +# Create a fake call stack. +call_stacks = [ +WasmCallStack( +[WasmStackFrame(0x019C), WasmStackFrame(0x01E5), WasmStackFrame(0x01FE)] +), +] + +# Create fake memory for our wasm locals. +self.memory = FakeMemory(0x1, 0x2) +self.memory.store_bytes( +WASM_LOCAL_ADDR, +bytes.fromhex( + "0200010002000100" +), +) + +self.server.responder = MyResponder( +obj_path, "test_wasm", call_stacks, self.memory +) target = self.dbg.CreateTarget("") +breakpoint = target.BreakpointCreateByName("add") process = self.connect(target, "wasm") lldbutil.expect_state_changes( self, self.dbg.GetListener(), process, [lldb.eStateStopped] ) +location = breakpoint.GetLocationAtIndex(0) +self.assertTrue(location and location.IsEnabled(), VALID_BREAKPOINT_LOCATION) + num_modules = target.GetNumModules() self.assertEqual(1, num_modules) -module = target.GetModuleAtIndex(0) -num_sections = module.GetNumSections() -self.assertEqual(5, num_sections) - -code_section = module.GetSectionAtIndex(0) -self.assertEqual("code", code_section.GetName()) -self.assertEqual( -load_address | code_section.GetFileOffset(), -code_section.GetLoadAddress(target), -) - -debug_info_section = module.GetSectionAtIndex(1) -self.assertEqual(".debug_info", debug_info_section.GetName()) -self.assertEqual( -LLDB_INVALID_ADDRESS, debug_info_section.GetLoadAddress(target) -) - -debug_abbrev_section = module.GetSectionAtIndex(2) -self.assertEqual(".debug_abbrev", debug_abbrev_section.GetName()) -self.assertEqual( -LLDB_INVALID_ADDRESS, debug_abbrev_section.GetLoadAddress(target) -) - -debug_line_section = module.GetSectionAtIndex(3) -self.assertEqual(".debug_line", debug_line_section.GetName()) -self.assertEqual( -LLDB_INVALID_ADDRESS, debug_line_section.GetLoadAddress(target) -) - -debug_str_section = module.GetSectionAtIndex(4) -self.assertEqual(".debug_str", debug_str_section.GetName()) -self.assertEqual( -LLDB_INVALID_ADDRESS, debug_line_section.GetLoadAddress(target) -) - thread = process.GetThreadAtIndex(0) self.assertTrue(thread.IsValid()) -frame = thread.GetFrameAtIndex(0) -self.assertTrue(frame.IsValid()) -self.assertEqual(frame.GetPC(), 0x41B3) - -frame = thread.GetFrameAtIndex(1) -self.assertTrue(frame.IsValid()) -self.assertEqual(frame.GetPC(), 0x41FE) +# Check that our frames match our fake call stack. +frame0 = thread.GetFrameAtIndex(0) +self.assertTrue(frame0.IsValid()) +self.assertEqual(frame0.GetPC(), LOAD_ADDRESS | 0x019C) +self.assertIn("add", frame0.GetFunctionName()) + +frame1 = thread.GetFrameAtIndex(1) +self.assertTrue(frame1.IsValid()) +self.assertEqual(frame1.GetPC(), LOAD_ADDRESS | 0x01E5) +self.assertIn("main", frame1.GetFunctionName()) + +# Check that we can resolve local variables. DavidSpickett wrote: I should have been more specific. I wondered if what you have implemented would allow that and if so it should be tested. But if it's not possible then the testing is fine. Does seem like a glaring omission, but not a problem with anything you've done. https://github.com/llvm/llvm-project/pull/151056 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement RegisterContextWasm (PR #151056)
@@ -0,0 +1,194 @@ +//===--===// +// +// 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 "ProcessWasm.h" +#include "ThreadWasm.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/Value.h" +#include "lldb/Utility/DataBufferHeap.h" + +#include "lldb/Target/UnixSignals.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::process_gdb_remote; +using namespace lldb_private::wasm; + +LLDB_PLUGIN_DEFINE(ProcessWasm) + +ProcessWasm::ProcessWasm(lldb::TargetSP target_sp, ListenerSP listener_sp) +: ProcessGDBRemote(target_sp, listener_sp) { + assert(target_sp); + // Wasm doesn't have any Unix-like signals as a platform concept, but pretend + // like it does to appease LLDB. + m_unix_signals_sp = UnixSignals::Create(target_sp->GetArchitecture()); +} + +void ProcessWasm::Initialize() { + static llvm::once_flag g_once_flag; + + llvm::call_once(g_once_flag, []() { +PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), CreateInstance, + DebuggerInitialize); + }); +} + +void ProcessWasm::DebuggerInitialize(Debugger &debugger) { + ProcessGDBRemote::DebuggerInitialize(debugger); +} + +llvm::StringRef ProcessWasm::GetPluginName() { return GetPluginNameStatic(); } + +llvm::StringRef ProcessWasm::GetPluginNameStatic() { return "wasm"; } + +llvm::StringRef ProcessWasm::GetPluginDescriptionStatic() { + return "GDB Remote protocol based WebAssembly debugging plug-in."; +} + +void ProcessWasm::Terminate() { + PluginManager::UnregisterPlugin(ProcessWasm::CreateInstance); +} + +lldb::ProcessSP ProcessWasm::CreateInstance(lldb::TargetSP target_sp, +ListenerSP listener_sp, +const FileSpec *crash_file_path, +bool can_connect) { + if (crash_file_path == nullptr) +return std::make_shared(target_sp, listener_sp); + return {}; +} + +bool ProcessWasm::CanDebug(lldb::TargetSP target_sp, + bool plugin_specified_by_name) { + if (plugin_specified_by_name) +return true; + + if (Module *exe_module = target_sp->GetExecutableModulePointer()) { +if (ObjectFile *exe_objfile = exe_module->GetObjectFile()) + return exe_objfile->GetArchitecture().GetMachine() == + llvm::Triple::wasm32; + } + + // However, if there is no wasm module, we return false, otherwise, + // we might use ProcessWasm to attach gdb remote. + return false; +} + +std::shared_ptr ProcessWasm::CreateThread(lldb::tid_t tid) { + return std::make_shared(*this, tid); +} + +size_t ProcessWasm::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, + Status &error) { + wasm_addr_t wasm_addr(vm_addr); + + switch (wasm_addr.GetType()) { + case WasmAddressType::Memory: + case WasmAddressType::Object: +return ProcessGDBRemote::ReadMemory(vm_addr, buf, size, error); + case WasmAddressType::Invalid: +error.FromErrorStringWithFormat( +"Wasm read failed for invalid address 0x%" PRIx64, vm_addr); +return 0; + } +} + +llvm::Expected> +ProcessWasm::GetWasmCallStack(lldb::tid_t tid) { + StreamString packet; + packet.Printf("qWasmCallStack:"); + packet.Printf("%llx", tid); + + StringExtractorGDBRemote response; + if (m_gdb_comm.SendPacketAndWaitForResponse(packet.GetString(), response) != + GDBRemoteCommunication::PacketResult::Success) +return llvm::createStringError("failed to send qWasmCallStack"); + + if (!response.IsNormalResponse()) +return llvm::createStringError("failed to get response for qWasmCallStack"); + + WritableDataBufferSP data_buffer_sp = + std::make_shared(response.GetStringRef().size() / 2, 0); + const size_t bytes = response.GetHexBytes(data_buffer_sp->GetData(), '\xcc'); + if (bytes == 0 || bytes % sizeof(uint64_t) != 0) +return llvm::createStringError("invalid response for qWasmCallStack"); + + // To match the Wasm specification, the addresses are encoded in little endian + // byte order. + DataExtractor data(data_buffer_sp, lldb::eByteOrderLittle, + GetAddressByteSize()); + lldb::offset_t offset = 0; + std::vector call_stack_pcs; + while (offset < bytes) +call_stack_pcs.push_back(data.GetU64(&offset)); + + return call_stack_pcs; +} + +llvm::Expected ProcessWasm::GetWasmLocal(int frame_index, + int index) { + StreamString packet; + packet.Printf("qWasmLocal:"); + packet.Printf("%d;%d", fram
[Lldb-commits] [lldb] [lldb] Remove %T from lit tests (PR #151343)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/151343 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove %T from lit tests (PR #151343)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/151343 >From f18f2c1b654fa6f5925109eae0277bbbceb48565 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Wed, 30 Jul 2025 14:13:02 + Subject: [PATCH 1/3] [lldb] Remove %T from lit tests %T has been deprecated for about seven years, mostly because it is not unique to each test which can lead to races. This patch updates the few remaining tests in lldb that use %T to not use it (either directly using files or creating their own temp dir). The eventual goal is to remove support for %T from llvm-lit given few tests use it and it still has racey behavior. This patch errors on the side of creating new temp dirs even when not strictly necessary to avoid needing to update filenames inside filecheck matchers. --- .../Commands/command-disassemble-process.yaml | 11 .../Shell/Commands/command-image-lookup.yaml | 9 --- .../Shell/Minidump/Windows/arm-fp-unwind.test | 9 --- .../Shell/Minidump/Windows/broken-unwind.test | 9 --- .../Shell/Minidump/Windows/find-module.test | 13 +- .../Minidump/memory-region-from-module.yaml | 6 ++--- .../Breakpad/uuid-matching-mac.test | 5 ++-- .../minidebuginfo-set-and-hit-breakpoint.test | 4 +-- .../SymbolFile/Breakpad/inline-record.test| 5 ++-- .../line-table-discontinuous-file-ids.test| 5 ++-- .../Breakpad/line-table-edgecases.test| 5 ++-- .../Breakpad/line-table-missing-file.test | 5 ++-- .../line-table-mixed-path-styles.test | 5 ++-- .../Shell/SymbolFile/Breakpad/line-table.test | 5 ++-- .../SymbolFile/Breakpad/symtab-macho.test | 5 ++-- .../Breakpad/symtab-sorted-by-size.test | 5 ++-- .../Shell/SymbolFile/Breakpad/symtab.test | 5 ++-- .../unwind-via-stack-win-no-memory-info.yaml | 5 ++-- .../SymbolFile/DWARF/dwo-missing-error.test | 1 - .../SymbolFile/DWARF/dwo-relative-path.s | 7 +++--- .../SymbolFile/DWARF/x86/debug_loclists-dwo.s | 3 ++- .../SymbolFile/DWARF/x86/debug_rnglists-dwo.s | 3 ++- .../DWARF/x86/dwo-type-in-main-file.s | 1 - .../Shell/SymbolFile/PDB/class-layout.test| 25 ++- .../test/Shell/SymbolFile/PDB/compilands.test | 9 --- .../Shell/SymbolFile/PDB/enums-layout.test| 15 +-- .../Shell/SymbolFile/PDB/func-symbols.test| 7 +++--- lldb/test/Shell/SymbolFile/PDB/pointers.test | 15 +-- .../test/Shell/SymbolFile/PDB/type-quals.test | 7 +++--- lldb/test/Shell/SymbolFile/PDB/typedefs.test | 5 ++-- lldb/test/Shell/SymbolFile/PDB/variables.test | 17 +++-- 31 files changed, 128 insertions(+), 103 deletions(-) diff --git a/lldb/test/Shell/Commands/command-disassemble-process.yaml b/lldb/test/Shell/Commands/command-disassemble-process.yaml index ce1b37bc8aea7..931e0b93e3b67 100644 --- a/lldb/test/Shell/Commands/command-disassemble-process.yaml +++ b/lldb/test/Shell/Commands/command-disassemble-process.yaml @@ -1,19 +1,20 @@ # REQUIRES: x86 -# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8 %s -o %T/command-disassemble-process.exe -# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8000 %s -o %T/command-disassemble-process.big.exe +# RUN: mkdir -p %t.dir +# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8 %s -o %t.dir/command-disassemble-process.exe +# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8000 %s -o %t.dir/command-disassemble-process.big.exe # RUN: yaml2obj --docnum=2 %s -o %t -# RUN: %lldb -c %t %T/command-disassemble-process.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.exe \ # RUN: -o "settings set interpreter.stop-command-source-on-error false" \ # RUN: -s %S/Inputs/command-disassemble-process.lldbinit -o exit \ # RUN: | FileCheck %s -# RUN: %lldb -c %t %T/command-disassemble-process.big.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.big.exe \ # RUN: -o "settings set stop-disassembly-max-size 8000" \ # RUN: -o disassemble -o exit 2>&1 | FileCheck %s --check-prefix=BIG -# RUN: %lldb -c %t %T/command-disassemble-process.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.exe \ # RUN: -o "settings set interpreter.stop-command-source-on-error false" \ # RUN: -o "disassemble --address 0xdead" -o exit 2>&1 \ # RUN: | FileCheck %s --check-prefix=INVALID diff --git a/lldb/test/Shell/Commands/command-image-lookup.yaml b/lldb/test/Shell/Commands/command-image-lookup.yaml index cf7be930517ee..fc12b99eab589 100644 --- a/lldb/test/Shell/Commands/command-image-lookup.yaml +++ b/lldb/test/Shell/Commands/command-image-lookup.yaml @@ -1,7 +1,8 @@ -# RUN: yaml2obj %s -o %T/a.out -# RUN: %lldb %T/a.out -o "image lookup --verbose --address 0x00013fa1" -o exit | FileCheck %s --check-prefix=NOINLINE -# RUN: %lldb %T/a.out -o "image lookup --verbose --address 0x00013fa2" -o exit | FileCheck %s --check-prefix=INLINE_1 -# RUN: %lldb %T/a.out -o "image lookup --verbose --address 0x00013fa8" -o exit | FileCheck %s --check-pref
[Lldb-commits] [lldb] [lldb] Implement RegisterContextWasm (PR #151056)
@@ -71,28 +124,62 @@ def qXferRead(self, obj, annex, offset, length): if obj == "libraries": xml = ( '' -% (self._module_name, load_address) +% (self._module_name, LOAD_ADDRESS) ) return xml, False else: return None, False def readMemory(self, addr, length): -if addr < load_address: +if self._memory and self._memory.contains(addr): +chunk = self._memory.get_bytes(addr, length) +return chunk.hex() DavidSpickett wrote: We the lldb community don't but at least Debian will do for s390x. Happens infrequently though. Looking at your use of it, it's all about slices of bytes rather than interpreting those as some other type. So I think it's fine. The "fix", should we need it, will be to use an array of numbers. Which is not hard to implement at short notice. https://github.com/llvm/llvm-project/pull/151056 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement RegisterContextWasm (PR #151056)
https://github.com/DavidSpickett approved this pull request. supprot -> support, in the PR description. LGTM. https://github.com/llvm/llvm-project/pull/151056 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove %T from lit tests (PR #151343)
https://github.com/boomanaiden154 closed https://github.com/llvm/llvm-project/pull/151343 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a7b58e7 - [lldb] Remove %T from lit tests (#151343)
Author: Aiden Grossman Date: 2025-07-30T09:09:54-07:00 New Revision: a7b58e74a080152c30fc5eb5f749e2254c277938 URL: https://github.com/llvm/llvm-project/commit/a7b58e74a080152c30fc5eb5f749e2254c277938 DIFF: https://github.com/llvm/llvm-project/commit/a7b58e74a080152c30fc5eb5f749e2254c277938.diff LOG: [lldb] Remove %T from lit tests (#151343) %T has been deprecated for about seven years, mostly because it is not unique to each test which can lead to races. This patch updates the few remaining tests in lldb that use %T to not use it (either directly using files or creating their own temp dir). The eventual goal is to remove support for %T from llvm-lit given few tests use it and it still has racey behavior. This patch errors on the side of creating new temp dirs even when not strictly necessary to avoid needing to update filenames inside filecheck matchers. Added: Modified: lldb/test/Shell/Commands/command-disassemble-process.yaml lldb/test/Shell/Commands/command-image-lookup.yaml lldb/test/Shell/Minidump/Windows/arm-fp-unwind.test lldb/test/Shell/Minidump/Windows/broken-unwind.test lldb/test/Shell/Minidump/Windows/find-module.test lldb/test/Shell/Minidump/memory-region-from-module.yaml lldb/test/Shell/ObjectFile/Breakpad/uuid-matching-mac.test lldb/test/Shell/ObjectFile/ELF/minidebuginfo-set-and-hit-breakpoint.test lldb/test/Shell/SymbolFile/Breakpad/inline-record.test lldb/test/Shell/SymbolFile/Breakpad/line-table-discontinuous-file-ids.test lldb/test/Shell/SymbolFile/Breakpad/line-table-edgecases.test lldb/test/Shell/SymbolFile/Breakpad/line-table-missing-file.test lldb/test/Shell/SymbolFile/Breakpad/line-table-mixed-path-styles.test lldb/test/Shell/SymbolFile/Breakpad/line-table.test lldb/test/Shell/SymbolFile/Breakpad/symtab-macho.test lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test lldb/test/Shell/SymbolFile/Breakpad/symtab.test lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win-no-memory-info.yaml lldb/test/Shell/SymbolFile/DWARF/dwo-missing-error.test lldb/test/Shell/SymbolFile/DWARF/dwo-relative-path.s lldb/test/Shell/SymbolFile/DWARF/x86/debug_loclists-dwo.s lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s lldb/test/Shell/SymbolFile/DWARF/x86/dwo-type-in-main-file.s lldb/test/Shell/SymbolFile/PDB/class-layout.test lldb/test/Shell/SymbolFile/PDB/compilands.test lldb/test/Shell/SymbolFile/PDB/enums-layout.test lldb/test/Shell/SymbolFile/PDB/func-symbols.test lldb/test/Shell/SymbolFile/PDB/pointers.test lldb/test/Shell/SymbolFile/PDB/type-quals.test lldb/test/Shell/SymbolFile/PDB/typedefs.test lldb/test/Shell/SymbolFile/PDB/variables.test Removed: diff --git a/lldb/test/Shell/Commands/command-disassemble-process.yaml b/lldb/test/Shell/Commands/command-disassemble-process.yaml index ce1b37bc8aea7..931e0b93e3b67 100644 --- a/lldb/test/Shell/Commands/command-disassemble-process.yaml +++ b/lldb/test/Shell/Commands/command-disassemble-process.yaml @@ -1,19 +1,20 @@ # REQUIRES: x86 -# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8 %s -o %T/command-disassemble-process.exe -# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8000 %s -o %T/command-disassemble-process.big.exe +# RUN: mkdir -p %t.dir +# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8 %s -o %t.dir/command-disassemble-process.exe +# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8000 %s -o %t.dir/command-disassemble-process.big.exe # RUN: yaml2obj --docnum=2 %s -o %t -# RUN: %lldb -c %t %T/command-disassemble-process.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.exe \ # RUN: -o "settings set interpreter.stop-command-source-on-error false" \ # RUN: -s %S/Inputs/command-disassemble-process.lldbinit -o exit \ # RUN: | FileCheck %s -# RUN: %lldb -c %t %T/command-disassemble-process.big.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.big.exe \ # RUN: -o "settings set stop-disassembly-max-size 8000" \ # RUN: -o disassemble -o exit 2>&1 | FileCheck %s --check-prefix=BIG -# RUN: %lldb -c %t %T/command-disassemble-process.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.exe \ # RUN: -o "settings set interpreter.stop-command-source-on-error false" \ # RUN: -o "disassemble --address 0xdead" -o exit 2>&1 \ # RUN: | FileCheck %s --check-prefix=INVALID diff --git a/lldb/test/Shell/Commands/command-image-lookup.yaml b/lldb/test/Shell/Commands/command-image-lookup.yaml index cf7be930517ee..fc12b99eab589 100644 --- a/lldb/test/Shell/Commands/command-image-lookup.yaml +++ b/lldb/test/Shell/Commands/command-image-lookup.yaml @@ -1,7 +1,8 @@ -# RUN: yaml2obj %s -o %T/a.out -# RUN: %lldb %T/a.out -o "image lookup --verbose --address 0x00013fa1" -o exit | FileCheck %s --check-prefix=NOINLINE -# RUN: %lldb %T/a.out -o "image lookup --verbose --address 0x0001000
[Lldb-commits] [lldb] [LLDB][NativePDB] Fix name access for classes in `CVTagRecord::name` (PR #151190)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/151190 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 6be3cc5 - [LLDB][NativePDB] Fix name access for classes in `CVTagRecord::name` (#151190)
Author: nerix Date: 2025-07-30T09:11:57-07:00 New Revision: 6be3cc5ad5ee0d33264bc202005e93c667b67698 URL: https://github.com/llvm/llvm-project/commit/6be3cc5ad5ee0d33264bc202005e93c667b67698 DIFF: https://github.com/llvm/llvm-project/commit/6be3cc5ad5ee0d33264bc202005e93c667b67698.diff LOG: [LLDB][NativePDB] Fix name access for classes in `CVTagRecord::name` (#151190) From https://github.com/llvm/llvm-project/pull/149876#discussion_r2240478480: The `name()` accessor checked for `m_kind == Union` and accessed `cvclass` instead of `cvunion`. This is technically wrong (maybe UB even?). In practice, this wasn't an issue, because all types in the union (`ClassRecord`/`EnumRecord`/`UnionRecord`) inherit from `TagRecord`. Added: Modified: lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h index 1f888f4de1fed..98b965c361a77 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h @@ -65,7 +65,7 @@ struct CVTagRecord { } llvm::StringRef name() const { -if (m_kind == Struct || m_kind == Union) +if (m_kind == Struct || m_kind == Class) return cvclass.Name; if (m_kind == Enum) return cvenum.Name; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][NativePDB] Fix name access for classes in `CVTagRecord::name` (PR #151190)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/151190 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update JSONTransport to use MainLoop for reading. (PR #148300)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/148300 >From ac0cf25e78f48e24847ef814a273d71bf0b98ddc Mon Sep 17 00:00:00 2001 From: John Harrison Date: Fri, 11 Jul 2025 14:24:42 -0700 Subject: [PATCH 1/4] [lldb] Update JSONTransport to use MainLoop for reading. This updates JSONTransport to use a MainLoop for reading messages. This also allows us to read in larger chunks than we did previously. With the event driven reading operations we can read in chunks and store the contents in an internal buffer. Separately we can parse the buffer and split the contents up into messages. Our previous version approach would read a byte at a time, which is less efficient. --- lldb/include/lldb/Host/JSONTransport.h| 78 ++-- lldb/source/Host/common/JSONTransport.cpp | 180 +++--- lldb/test/API/tools/lldb-dap/io/TestDAP_io.py | 12 +- lldb/tools/lldb-dap/DAP.cpp | 130 +++-- lldb/tools/lldb-dap/DAP.h | 7 + lldb/tools/lldb-dap/Transport.h | 2 +- lldb/unittests/DAP/DAPTest.cpp| 11 +- lldb/unittests/DAP/TestBase.cpp | 26 ++- lldb/unittests/DAP/TestBase.h | 21 ++ lldb/unittests/Host/JSONTransportTest.cpp | 175 +++-- .../Protocol/ProtocolMCPServerTest.cpp| 135 +++-- 11 files changed, 443 insertions(+), 334 deletions(-) diff --git a/lldb/include/lldb/Host/JSONTransport.h b/lldb/include/lldb/Host/JSONTransport.h index 4087cdf2b42f7..170aa4a8b8811 100644 --- a/lldb/include/lldb/Host/JSONTransport.h +++ b/lldb/include/lldb/Host/JSONTransport.h @@ -13,13 +13,15 @@ #ifndef LLDB_HOST_JSONTRANSPORT_H #define LLDB_HOST_JSONTRANSPORT_H +#include "lldb/Host/MainLoopBase.h" #include "lldb/lldb-forward.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/JSON.h" -#include +#include #include +#include namespace lldb_private { @@ -68,6 +70,10 @@ class TransportInvalidError : public llvm::ErrorInfo { /// A transport class that uses JSON for communication. class JSONTransport { public: + using ReadHandleUP = MainLoopBase::ReadHandleUP; + template + using Callback = std::function)>; + JSONTransport(lldb::IOObjectSP input, lldb::IOObjectSP output); virtual ~JSONTransport() = default; @@ -83,24 +89,59 @@ class JSONTransport { return WriteImpl(message); } - /// Reads the next message from the input stream. + /// Registers the transport with the MainLoop. template - llvm::Expected Read(const std::chrono::microseconds &timeout) { -llvm::Expected message = ReadImpl(timeout); -if (!message) - return message.takeError(); -return llvm::json::parse(/*JSON=*/*message); + llvm::Expected RegisterReadObject(MainLoopBase &loop, + Callback callback) { +Status error; +ReadHandleUP handle = loop.RegisterReadObject( +m_input, +[&](MainLoopBase &loop) { + char buf[1024]; + size_t len = sizeof(buf); + do { +if (llvm::Error error = m_input->Read(buf, len).takeError()) { + callback(loop, std::move(error)); + return; +} + +if (len == 0) // EOF + break; + +m_buffer.append(std::string(buf, len)); + } while (len == sizeof(buf)); + + llvm::Expected> messages = Parse(); + if (llvm::Error error = messages.takeError()) { +callback(loop, std::move(error)); +return; + } + + for (const auto &message : *messages) +if constexpr (std::is_same::value) + callback(loop, message); +else + callback(loop, llvm::json::parse(message)); + + // On EOF, request termination after handling all the messages. + if (len == 0) +callback(loop, llvm::make_error()); +}, +error); +if (error.Fail()) + return error.takeError(); +return handle; } protected: virtual void Log(llvm::StringRef message); virtual llvm::Error WriteImpl(const std::string &message) = 0; - virtual llvm::Expected - ReadImpl(const std::chrono::microseconds &timeout) = 0; + virtual llvm::Expected> Parse() = 0; lldb::IOObjectSP m_input; lldb::IOObjectSP m_output; + std::string m_buffer; }; /// A transport class for JSON with a HTTP header. @@ -111,14 +152,12 @@ class HTTPDelimitedJSONTransport : public JSONTransport { virtual ~HTTPDelimitedJSONTransport() = default; protected: - virtual llvm::Error WriteImpl(const std::string &message) override; - virtual llvm::Expected - ReadImpl(const std::chrono::microseconds &timeout) override; - - // FIXME: Support any header. - static constexpr llvm::StringLiteral kHeaderContentLength = - "Content-Length: "; - static constexpr
[Lldb-commits] [lldb] [lldb] Update JSONTransport to use MainLoop for reading. (PR #148300)
@@ -56,40 +84,88 @@ bool fromJSON(const llvm::json::Value &V, JSONTestType &T, llvm::json::Path P) { } // namespace TEST_F(HTTPDelimitedJSONTransportTest, MalformedRequests) { - std::string malformed_header = "COnTent-LenGth: -1{}\r\n\r\nnotjosn"; + std::string malformed_header = + "COnTent-LenGth: -1\r\nContent-Type: text/json\r\n\r\nnotjosn"; ASSERT_THAT_EXPECTED( input.Write(malformed_header.data(), malformed_header.size()), Succeeded()); - ASSERT_THAT_EXPECTED( - transport->Read(std::chrono::milliseconds(1)), - FailedWithMessage( - "expected 'Content-Length: ' and got 'COnTent-LenGth: '")); + RunOnce([&](llvm::Expected message) { +ASSERT_THAT_EXPECTED(message, + FailedWithMessage("invalid content length: -1")); + }); } TEST_F(HTTPDelimitedJSONTransportTest, Read) { std::string json = R"json({"str": "foo"})json"; + std::string message = + formatv("Content-Length: {0}\r\nContent-type: text/json\r\n\r\n{1}", + json.size(), json) + .str(); + ASSERT_THAT_EXPECTED(input.Write(message.data(), message.size()), + Succeeded()); + RunOnce([&](llvm::Expected message) { +ASSERT_THAT_EXPECTED(message, HasValue(testing::FieldsAre(/*str=*/"foo"))); + }); ashgti wrote: Updated this helper to return the first message instead of taking a callback. https://github.com/llvm/llvm-project/pull/148300 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update JSONTransport to use MainLoop for reading. (PR #148300)
@@ -7,163 +7,122 @@ //===--===// #include "lldb/Host/JSONTransport.h" -#include "lldb/Utility/IOObject.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/SelectHelper.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" -#include #include #include using namespace llvm; using namespace lldb; using namespace lldb_private; -/// ReadFull attempts to read the specified number of bytes. If EOF is -/// encountered, an empty string is returned. -static Expected -ReadFull(IOObject &descriptor, size_t length, - std::optional timeout = std::nullopt) { - if (!descriptor.IsValid()) -return llvm::make_error(); - - bool timeout_supported = true; - // FIXME: SelectHelper does not work with NativeFile on Win32. -#if _WIN32 - timeout_supported = descriptor.GetFdType() == IOObject::eFDTypeSocket; -#endif - - if (timeout && timeout_supported) { -SelectHelper sh; -sh.SetTimeout(*timeout); -sh.FDSetRead( -reinterpret_cast(descriptor.GetWaitableHandle())); -Status status = sh.Select(); -if (status.Fail()) { - // Convert timeouts into a specific error. - if (status.GetType() == lldb::eErrorTypePOSIX && - status.GetError() == ETIMEDOUT) -return make_error(); - return status.takeError(); -} - } - - std::string data; - data.resize(length); - Status status = descriptor.Read(data.data(), length); - if (status.Fail()) -return status.takeError(); - - // Read returns '' on EOF. - if (length == 0) -return make_error(); - - // Return the actual number of bytes read. - return data.substr(0, length); -} - -static Expected -ReadUntil(IOObject &descriptor, StringRef delimiter, - std::optional timeout = std::nullopt) { - std::string buffer; - buffer.reserve(delimiter.size() + 1); - while (!llvm::StringRef(buffer).ends_with(delimiter)) { -Expected next = -ReadFull(descriptor, buffer.empty() ? delimiter.size() : 1, timeout); -if (auto Err = next.takeError()) - return std::move(Err); -buffer += *next; - } - return buffer.substr(0, buffer.size() - delimiter.size()); -} - JSONTransport::JSONTransport(IOObjectSP input, IOObjectSP output) : m_input(std::move(input)), m_output(std::move(output)) {} void JSONTransport::Log(llvm::StringRef message) { LLDB_LOG(GetLog(LLDBLog::Host), "{0}", message); } -Expected -HTTPDelimitedJSONTransport::ReadImpl(const std::chrono::microseconds &timeout) { - if (!m_input || !m_input->IsValid()) -return llvm::make_error(); +// Parses messages based on +// https://microsoft.github.io/debug-adapter-protocol/overview#base-protocol +Expected> HTTPDelimitedJSONTransport::Parse() { + if (m_buffer.empty()) +return std::vector{}; + + std::vector messages; + StringRef buffer = m_buffer; + size_t content_length = 0, end_of_last_message = 0, cursor = 0; + do { +auto idx = buffer.find(kHeaderSeparator, cursor); +// Separator not found, we need more data. +if (idx == StringRef::npos) + break; + +auto header = buffer.slice(cursor, idx); +cursor = idx + kHeaderSeparator.size(); + +// An empty line separates the headers from the message body. +if (header.empty()) { + // Check if we have enough data or wait for the next chunk to arrive. + if (content_length + cursor > buffer.size()) +break; + + std::string body = buffer.substr(cursor, content_length).str(); + end_of_last_message = cursor + content_length; + cursor += content_length; + Logv("--> {0}", body); + messages.emplace_back(std::move(body)); + content_length = 0; + continue; +} + +// HTTP Headers are formatted like ` ':' []`. +if (!header.contains(kHeaderFieldSeparator)) + return createStringError("malformed content header"); + +auto [name, value] = header.split(kHeaderFieldSeparator); + +// Handle known headers, at the moment only "Content-Length" is specified, +// other headers are ignored. +if (name.lower() == kHeaderContentLength.lower()) { + value = value.trim(); + if (value.trim().consumeInteger(10, content_length)) +return createStringError(std::errc::invalid_argument, + "invalid content length: %s", + value.str().c_str()); +} + } while (cursor < buffer.size()); + + // Store the remainder of the buffer for the next read callback. + m_buffer = buffer.substr(end_of_last_message); - IOObject *input = m_input.get(); - Expected message_header = - ReadFull(*input, kHeaderContentLength.size(), timeout); - if (!message_header) -return message_header.takeError(); - if (*message_header != kHeaderContentLe
[Lldb-commits] [lldb] [lldb] Update JSONTransport to use MainLoop for reading. (PR #148300)
@@ -7,163 +7,122 @@ //===--===// #include "lldb/Host/JSONTransport.h" -#include "lldb/Utility/IOObject.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/SelectHelper.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" -#include #include #include using namespace llvm; using namespace lldb; using namespace lldb_private; -/// ReadFull attempts to read the specified number of bytes. If EOF is -/// encountered, an empty string is returned. -static Expected -ReadFull(IOObject &descriptor, size_t length, - std::optional timeout = std::nullopt) { - if (!descriptor.IsValid()) -return llvm::make_error(); - - bool timeout_supported = true; - // FIXME: SelectHelper does not work with NativeFile on Win32. -#if _WIN32 - timeout_supported = descriptor.GetFdType() == IOObject::eFDTypeSocket; -#endif - - if (timeout && timeout_supported) { -SelectHelper sh; -sh.SetTimeout(*timeout); -sh.FDSetRead( -reinterpret_cast(descriptor.GetWaitableHandle())); -Status status = sh.Select(); -if (status.Fail()) { - // Convert timeouts into a specific error. - if (status.GetType() == lldb::eErrorTypePOSIX && - status.GetError() == ETIMEDOUT) -return make_error(); - return status.takeError(); -} - } - - std::string data; - data.resize(length); - Status status = descriptor.Read(data.data(), length); - if (status.Fail()) -return status.takeError(); - - // Read returns '' on EOF. - if (length == 0) -return make_error(); - - // Return the actual number of bytes read. - return data.substr(0, length); -} - -static Expected -ReadUntil(IOObject &descriptor, StringRef delimiter, - std::optional timeout = std::nullopt) { - std::string buffer; - buffer.reserve(delimiter.size() + 1); - while (!llvm::StringRef(buffer).ends_with(delimiter)) { -Expected next = -ReadFull(descriptor, buffer.empty() ? delimiter.size() : 1, timeout); -if (auto Err = next.takeError()) - return std::move(Err); -buffer += *next; - } - return buffer.substr(0, buffer.size() - delimiter.size()); -} - JSONTransport::JSONTransport(IOObjectSP input, IOObjectSP output) : m_input(std::move(input)), m_output(std::move(output)) {} void JSONTransport::Log(llvm::StringRef message) { LLDB_LOG(GetLog(LLDBLog::Host), "{0}", message); } -Expected -HTTPDelimitedJSONTransport::ReadImpl(const std::chrono::microseconds &timeout) { - if (!m_input || !m_input->IsValid()) -return llvm::make_error(); +// Parses messages based on +// https://microsoft.github.io/debug-adapter-protocol/overview#base-protocol +Expected> HTTPDelimitedJSONTransport::Parse() { + if (m_buffer.empty()) +return std::vector{}; + + std::vector messages; + StringRef buffer = m_buffer; + size_t content_length = 0, end_of_last_message = 0, cursor = 0; + do { +auto idx = buffer.find(kHeaderSeparator, cursor); +// Separator not found, we need more data. +if (idx == StringRef::npos) + break; + +auto header = buffer.slice(cursor, idx); +cursor = idx + kHeaderSeparator.size(); + +// An empty line separates the headers from the message body. +if (header.empty()) { + // Check if we have enough data or wait for the next chunk to arrive. + if (content_length + cursor > buffer.size()) +break; + + std::string body = buffer.substr(cursor, content_length).str(); + end_of_last_message = cursor + content_length; + cursor += content_length; + Logv("--> {0}", body); + messages.emplace_back(std::move(body)); + content_length = 0; + continue; +} + +// HTTP Headers are formatted like ` ':' []`. +if (!header.contains(kHeaderFieldSeparator)) + return createStringError("malformed content header"); + +auto [name, value] = header.split(kHeaderFieldSeparator); + +// Handle known headers, at the moment only "Content-Length" is specified, +// other headers are ignored. +if (name.lower() == kHeaderContentLength.lower()) { + value = value.trim(); + if (value.trim().consumeInteger(10, content_length)) ashgti wrote: Switched to this instead of `consumeInteger`. https://github.com/llvm/llvm-project/pull/148300 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update JSONTransport to use MainLoop for reading. (PR #148300)
@@ -22,8 +23,28 @@ class TransportBase : public PipePairTest { protected: std::unique_ptr to_dap; std::unique_ptr from_dap; + lldb_private::MainLoop loop; void SetUp() override; + + template + void + RunOnce(std::function)> callback, + std::chrono::milliseconds timeout = std::chrono::milliseconds(100)) { ashgti wrote: Done. https://github.com/llvm/llvm-project/pull/148300 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c2548a8 - [lldb] Support DW_OP_WASM_location in DWARFExpression (#151010)
Author: Jonas Devlieghere Date: 2025-07-30T09:20:37-07:00 New Revision: c2548a8c4c581bfd7c2b7738508fff4d85413cd6 URL: https://github.com/llvm/llvm-project/commit/c2548a8c4c581bfd7c2b7738508fff4d85413cd6 DIFF: https://github.com/llvm/llvm-project/commit/c2548a8c4c581bfd7c2b7738508fff4d85413cd6.diff LOG: [lldb] Support DW_OP_WASM_location in DWARFExpression (#151010) Add support for DW_OP_WASM_location in DWARFExpression. This PR rebases #78977 and cleans up the unit test. The DWARF extensions are documented at https://yurydelendik.github.io/webassembly-dwarf/ and supported by LLVM-based toolchains such as Clang, Swift, Emscripten, and Rust. Added: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileWasm.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileWasm.h lldb/source/Utility/WasmVirtualRegisters.h Modified: lldb/include/lldb/Expression/DWARFExpression.h lldb/source/Expression/DWARFExpression.cpp lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h lldb/unittests/Expression/CMakeLists.txt lldb/unittests/Expression/DWARFExpressionTest.cpp Removed: diff --git a/lldb/include/lldb/Expression/DWARFExpression.h b/lldb/include/lldb/Expression/DWARFExpression.h index 37853c0b5a8fc..8fcc5d37b91c9 100644 --- a/lldb/include/lldb/Expression/DWARFExpression.h +++ b/lldb/include/lldb/Expression/DWARFExpression.h @@ -52,10 +52,10 @@ class DWARFExpression { GetVendorDWARFOpcodeSize(const DataExtractor &data, const lldb::offset_t data_offset, const uint8_t op) const = 0; -virtual bool ParseVendorDWARFOpcode(uint8_t op, -const DataExtractor &opcodes, -lldb::offset_t &offset, -Stack &stack) const = 0; +virtual bool +ParseVendorDWARFOpcode(uint8_t op, const DataExtractor &opcodes, + lldb::offset_t &offset, RegisterContext *reg_ctx, + lldb::RegisterKind reg_kind, Stack &stack) const = 0; Delegate(const Delegate &) = delete; Delegate &operator=(const Delegate &) = delete; @@ -163,6 +163,10 @@ class DWARFExpression { bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op) const; + static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx, + lldb::RegisterKind reg_kind, + uint32_t reg_num, Value &value); + private: /// A data extractor capable of reading opcode bytes DataExtractor m_data; diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index 79bc6c87fa9c5..391e27704b63d 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -91,9 +91,10 @@ void DWARFExpression::SetRegisterKind(RegisterKind reg_kind) { m_reg_kind = reg_kind; } -static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx, - lldb::RegisterKind reg_kind, - uint32_t reg_num, Value &value) { +llvm::Error +DWARFExpression::ReadRegisterValueAsScalar(RegisterContext *reg_ctx, + lldb::RegisterKind reg_kind, + uint32_t reg_num, Value &value) { if (reg_ctx == nullptr) return llvm::createStringError("no register context in frame"); @@ -2302,7 +2303,8 @@ llvm::Expected DWARFExpression::Evaluate( default: if (dwarf_cu) { -if (dwarf_cu->ParseVendorDWARFOpcode(op, opcodes, offset, stack)) { +if (dwarf_cu->ParseVendorDWARFOpcode(op, opcodes, offset, reg_ctx, + reg_kind, stack)) { break; } } diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp index 67963a790a4fe..b1efd25949379 100644 --- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp +++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp @@ -376,9 +376,13 @@ DataExtractor ObjectFileWasm::ReadImageData(offset_t offset, uint32_t size) { DataBufferSP buffer_sp(data_up.release()); data.SetData(buffer_sp, 0, buffer_sp->GetByteSize()); } +} else if (offset < m_data.GetByteSize()) { + size =
[Lldb-commits] [lldb] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #151010)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/151010 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update JSONTransport to use MainLoop for reading. (PR #148300)
@@ -7,127 +7,80 @@ //===--===// #include "lldb/Host/JSONTransport.h" -#include "lldb/Utility/IOObject.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/SelectHelper.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" -#include #include #include using namespace llvm; using namespace lldb; using namespace lldb_private; -/// ReadFull attempts to read the specified number of bytes. If EOF is -/// encountered, an empty string is returned. -static Expected -ReadFull(IOObject &descriptor, size_t length, - std::optional timeout = std::nullopt) { - if (!descriptor.IsValid()) -return llvm::make_error(); - - bool timeout_supported = true; - // FIXME: SelectHelper does not work with NativeFile on Win32. -#if _WIN32 - timeout_supported = descriptor.GetFdType() == IOObject::eFDTypeSocket; -#endif - - if (timeout && timeout_supported) { -SelectHelper sh; -sh.SetTimeout(*timeout); -sh.FDSetRead( -reinterpret_cast(descriptor.GetWaitableHandle())); -Status status = sh.Select(); -if (status.Fail()) { - // Convert timeouts into a specific error. - if (status.GetType() == lldb::eErrorTypePOSIX && - status.GetError() == ETIMEDOUT) -return make_error(); - return status.takeError(); -} - } - - std::string data; - data.resize(length); - Status status = descriptor.Read(data.data(), length); - if (status.Fail()) -return status.takeError(); - - // Read returns '' on EOF. - if (length == 0) -return make_error(); - - // Return the actual number of bytes read. - return data.substr(0, length); -} - -static Expected -ReadUntil(IOObject &descriptor, StringRef delimiter, - std::optional timeout = std::nullopt) { - std::string buffer; - buffer.reserve(delimiter.size() + 1); - while (!llvm::StringRef(buffer).ends_with(delimiter)) { -Expected next = -ReadFull(descriptor, buffer.empty() ? delimiter.size() : 1, timeout); -if (auto Err = next.takeError()) - return std::move(Err); -buffer += *next; - } - return buffer.substr(0, buffer.size() - delimiter.size()); -} - JSONTransport::JSONTransport(IOObjectSP input, IOObjectSP output) : m_input(std::move(input)), m_output(std::move(output)) {} void JSONTransport::Log(llvm::StringRef message) { LLDB_LOG(GetLog(LLDBLog::Host), "{0}", message); } -Expected -HTTPDelimitedJSONTransport::ReadImpl(const std::chrono::microseconds &timeout) { - if (!m_input || !m_input->IsValid()) -return llvm::make_error(); +Expected> HTTPDelimitedJSONTransport::Parse() { + if (m_buffer.empty()) +return std::vector{}; + + std::vector messages; + llvm::StringRef buf = m_buffer; + size_t content_length = 0, end_of_last_message = 0, cursor = 0; + do { +auto idx = buf.find(kHeaderSeparator, cursor); +if (idx == StringRef::npos) + break; + +auto header = buf.slice(cursor, idx); +cursor = idx + kHeaderSeparator.size(); ashgti wrote: I reworked this flow, to hopefully make it more readable. LMKWYT https://github.com/llvm/llvm-project/pull/148300 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update JSONTransport to use MainLoop for reading. (PR #148300)
@@ -7,163 +7,122 @@ //===--===// #include "lldb/Host/JSONTransport.h" -#include "lldb/Utility/IOObject.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/SelectHelper.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" -#include #include #include using namespace llvm; using namespace lldb; using namespace lldb_private; -/// ReadFull attempts to read the specified number of bytes. If EOF is -/// encountered, an empty string is returned. -static Expected -ReadFull(IOObject &descriptor, size_t length, - std::optional timeout = std::nullopt) { - if (!descriptor.IsValid()) -return llvm::make_error(); - - bool timeout_supported = true; - // FIXME: SelectHelper does not work with NativeFile on Win32. -#if _WIN32 - timeout_supported = descriptor.GetFdType() == IOObject::eFDTypeSocket; -#endif - - if (timeout && timeout_supported) { -SelectHelper sh; -sh.SetTimeout(*timeout); -sh.FDSetRead( -reinterpret_cast(descriptor.GetWaitableHandle())); -Status status = sh.Select(); -if (status.Fail()) { - // Convert timeouts into a specific error. - if (status.GetType() == lldb::eErrorTypePOSIX && - status.GetError() == ETIMEDOUT) -return make_error(); - return status.takeError(); -} - } - - std::string data; - data.resize(length); - Status status = descriptor.Read(data.data(), length); - if (status.Fail()) -return status.takeError(); - - // Read returns '' on EOF. - if (length == 0) -return make_error(); - - // Return the actual number of bytes read. - return data.substr(0, length); -} - -static Expected -ReadUntil(IOObject &descriptor, StringRef delimiter, - std::optional timeout = std::nullopt) { - std::string buffer; - buffer.reserve(delimiter.size() + 1); - while (!llvm::StringRef(buffer).ends_with(delimiter)) { -Expected next = -ReadFull(descriptor, buffer.empty() ? delimiter.size() : 1, timeout); -if (auto Err = next.takeError()) - return std::move(Err); -buffer += *next; - } - return buffer.substr(0, buffer.size() - delimiter.size()); -} - JSONTransport::JSONTransport(IOObjectSP input, IOObjectSP output) : m_input(std::move(input)), m_output(std::move(output)) {} void JSONTransport::Log(llvm::StringRef message) { LLDB_LOG(GetLog(LLDBLog::Host), "{0}", message); } -Expected -HTTPDelimitedJSONTransport::ReadImpl(const std::chrono::microseconds &timeout) { - if (!m_input || !m_input->IsValid()) -return llvm::make_error(); +// Parses messages based on +// https://microsoft.github.io/debug-adapter-protocol/overview#base-protocol +Expected> HTTPDelimitedJSONTransport::Parse() { + if (m_buffer.empty()) +return std::vector{}; + + std::vector messages; + StringRef buffer = m_buffer; + size_t content_length = 0, end_of_last_message = 0, cursor = 0; + do { +auto idx = buffer.find(kHeaderSeparator, cursor); +// Separator not found, we need more data. +if (idx == StringRef::npos) + break; + +auto header = buffer.slice(cursor, idx); +cursor = idx + kHeaderSeparator.size(); + +// An empty line separates the headers from the message body. +if (header.empty()) { + // Check if we have enough data or wait for the next chunk to arrive. + if (content_length + cursor > buffer.size()) +break; + + std::string body = buffer.substr(cursor, content_length).str(); + end_of_last_message = cursor + content_length; + cursor += content_length; + Logv("--> {0}", body); + messages.emplace_back(std::move(body)); + content_length = 0; + continue; +} + +// HTTP Headers are formatted like ` ':' []`. +if (!header.contains(kHeaderFieldSeparator)) + return createStringError("malformed content header"); + +auto [name, value] = header.split(kHeaderFieldSeparator); + +// Handle known headers, at the moment only "Content-Length" is specified, +// other headers are ignored. +if (name.lower() == kHeaderContentLength.lower()) { + value = value.trim(); + if (value.trim().consumeInteger(10, content_length)) +return createStringError(std::errc::invalid_argument, + "invalid content length: %s", + value.str().c_str()); +} + } while (cursor < buffer.size()); + + // Store the remainder of the buffer for the next read callback. + m_buffer = buffer.substr(end_of_last_message); - IOObject *input = m_input.get(); - Expected message_header = - ReadFull(*input, kHeaderContentLength.size(), timeout); - if (!message_header) -return message_header.takeError(); - if (*message_header != kHeaderContentLe
[Lldb-commits] [lldb] [lldb][rpc] Add sysroot to lldb-rpc-gen test suite invocation (PR #151291)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/151291 >From 40260f72bd61ab6d0b6b059b3c3ae68766d37479 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Wed, 30 Jul 2025 00:56:06 -0700 Subject: [PATCH] [lldb][rpc] Add sysroot to lldb-rpc-gen test suite invocation When running the lldb-rpc-gen tests On Darwin platforms, the sysroot needs to be added to the test invocation. Without it, basic includes will not be resolved and the test will fail. --- lldb/test/Shell/helper/toolchain.py | 12 1 file changed, 12 insertions(+) diff --git a/lldb/test/Shell/helper/toolchain.py b/lldb/test/Shell/helper/toolchain.py index 728f6347242f1..d12f00ef9ccc9 100644 --- a/lldb/test/Shell/helper/toolchain.py +++ b/lldb/test/Shell/helper/toolchain.py @@ -119,6 +119,17 @@ def use_lldb_substitutions(config): lldb_init = _get_lldb_init_path(config) +sysroot_arg = "" +if platform.system() in ["Darwin"]: +try: +out = subprocess.check_output(["xcrun", "--show-sdk-path"]).strip() +res = 0 +except OSError: +res = -1 +if res == 0 and out: +sdk_path = lit.util.to_string(out) +sysroot_arg = '--extra-arg="--sysroot=' + sdk_path + '"' + primary_tools = [ ToolSubst( "%lldb", @@ -163,6 +174,7 @@ def use_lldb_substitutions(config): extra_args=[ "-p " + config.lldb_build_directory + "/..", '--extra-arg="-resource-dir=' + config.clang_resource_dir + '"', +sysroot_arg, ], unresolved="ignore", ), ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update JSONTransport to use MainLoop for reading. (PR #148300)
@@ -7,163 +7,122 @@ //===--===// #include "lldb/Host/JSONTransport.h" -#include "lldb/Utility/IOObject.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/SelectHelper.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" -#include #include #include using namespace llvm; using namespace lldb; using namespace lldb_private; -/// ReadFull attempts to read the specified number of bytes. If EOF is -/// encountered, an empty string is returned. -static Expected -ReadFull(IOObject &descriptor, size_t length, - std::optional timeout = std::nullopt) { - if (!descriptor.IsValid()) -return llvm::make_error(); - - bool timeout_supported = true; - // FIXME: SelectHelper does not work with NativeFile on Win32. -#if _WIN32 - timeout_supported = descriptor.GetFdType() == IOObject::eFDTypeSocket; -#endif - - if (timeout && timeout_supported) { -SelectHelper sh; -sh.SetTimeout(*timeout); -sh.FDSetRead( -reinterpret_cast(descriptor.GetWaitableHandle())); -Status status = sh.Select(); -if (status.Fail()) { - // Convert timeouts into a specific error. - if (status.GetType() == lldb::eErrorTypePOSIX && - status.GetError() == ETIMEDOUT) -return make_error(); - return status.takeError(); -} - } - - std::string data; - data.resize(length); - Status status = descriptor.Read(data.data(), length); - if (status.Fail()) -return status.takeError(); - - // Read returns '' on EOF. - if (length == 0) -return make_error(); - - // Return the actual number of bytes read. - return data.substr(0, length); -} - -static Expected -ReadUntil(IOObject &descriptor, StringRef delimiter, - std::optional timeout = std::nullopt) { - std::string buffer; - buffer.reserve(delimiter.size() + 1); - while (!llvm::StringRef(buffer).ends_with(delimiter)) { -Expected next = -ReadFull(descriptor, buffer.empty() ? delimiter.size() : 1, timeout); -if (auto Err = next.takeError()) - return std::move(Err); -buffer += *next; - } - return buffer.substr(0, buffer.size() - delimiter.size()); -} - JSONTransport::JSONTransport(IOObjectSP input, IOObjectSP output) : m_input(std::move(input)), m_output(std::move(output)) {} void JSONTransport::Log(llvm::StringRef message) { LLDB_LOG(GetLog(LLDBLog::Host), "{0}", message); } -Expected -HTTPDelimitedJSONTransport::ReadImpl(const std::chrono::microseconds &timeout) { - if (!m_input || !m_input->IsValid()) -return llvm::make_error(); +// Parses messages based on +// https://microsoft.github.io/debug-adapter-protocol/overview#base-protocol +Expected> HTTPDelimitedJSONTransport::Parse() { + if (m_buffer.empty()) +return std::vector{}; + + std::vector messages; + StringRef buffer = m_buffer; + size_t content_length = 0, end_of_last_message = 0, cursor = 0; + do { +auto idx = buffer.find(kHeaderSeparator, cursor); +// Separator not found, we need more data. +if (idx == StringRef::npos) + break; + +auto header = buffer.slice(cursor, idx); +cursor = idx + kHeaderSeparator.size(); + +// An empty line separates the headers from the message body. +if (header.empty()) { + // Check if we have enough data or wait for the next chunk to arrive. + if (content_length + cursor > buffer.size()) +break; + + std::string body = buffer.substr(cursor, content_length).str(); + end_of_last_message = cursor + content_length; + cursor += content_length; + Logv("--> {0}", body); + messages.emplace_back(std::move(body)); + content_length = 0; + continue; +} + +// HTTP Headers are formatted like ` ':' []`. +if (!header.contains(kHeaderFieldSeparator)) + return createStringError("malformed content header"); + +auto [name, value] = header.split(kHeaderFieldSeparator); + +// Handle known headers, at the moment only "Content-Length" is specified, +// other headers are ignored. +if (name.lower() == kHeaderContentLength.lower()) { ashgti wrote: Done. https://github.com/llvm/llvm-project/pull/148300 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add TemplateRange and NameQualifiersRange to DemangledNameInfo (PR #150999)
@@ -59,6 +73,18 @@ struct DemangledNameInfo { /// \endcode std::pair QualifiersRange; + /// Indicates the [start, end) of the function's name qualifiers. This is a + /// catch-all range for anything in between the basename and the arguments, + /// that is not tracked by the rest of the pairs. + /// + /// E.g., + /// \code{.swift} + ///void foo::bar::qux(int) const && + /// ^^ + /// start end + /// \endcode Michael137 wrote: This example makes it seem there is no difference to `QualifiersRange` here. > between the basename and the arguments function arguments or template arguments? https://github.com/llvm/llvm-project/pull/150999 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add TemplateRange and NameQualifiersRange to DemangledNameInfo (PR #150999)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/150999 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add `ValueObject::CreateValueObjectFromScalar` and fix `Scalar::GetData` (PR #151350)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Ilia Kuklin (kuilpd) Changes Add `ValueObject::CreateValueObjectFromScalar` function and adjust `Scalar::GetData` to be able to both extend and truncate the data bytes in Scalar to a desired size. --- Full diff: https://github.com/llvm/llvm-project/pull/151350.diff 8 Files Affected: - (modified) lldb/include/lldb/Utility/Scalar.h (+5-1) - (modified) lldb/include/lldb/ValueObject/ValueObject.h (+6) - (modified) lldb/include/lldb/ValueObject/ValueObjectConstResult.h (+11) - (modified) lldb/source/Core/Value.cpp (+3-9) - (modified) lldb/source/Utility/Scalar.cpp (+45-15) - (modified) lldb/source/ValueObject/ValueObject.cpp (+7) - (modified) lldb/source/ValueObject/ValueObjectConstResult.cpp (+27) - (modified) lldb/unittests/Utility/ScalarTest.cpp (+18) ``diff diff --git a/lldb/include/lldb/Utility/Scalar.h b/lldb/include/lldb/Utility/Scalar.h index b4b9c7e189582..dbb260962f1d6 100644 --- a/lldb/include/lldb/Utility/Scalar.h +++ b/lldb/include/lldb/Utility/Scalar.h @@ -84,11 +84,15 @@ class Scalar { /// Store the binary representation of this value into the given storage. /// Exactly GetByteSize() bytes will be stored, and the buffer must be large /// enough to hold this data. + void GetBytes(uint8_t *storage, size_t length) const; void GetBytes(llvm::MutableArrayRef storage) const; size_t GetByteSize() const; - bool GetData(DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const; + /// Get data with a byte size of GetByteSize(). + bool GetData(DataExtractor &data) const; + /// Get data with a byte size forced to \p result_byte_size. + bool GetData(DataExtractor &data, size_t result_byte_size) const; size_t GetAsMemoryData(void *dst, size_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const; diff --git a/lldb/include/lldb/ValueObject/ValueObject.h b/lldb/include/lldb/ValueObject/ValueObject.h index 3c62f3c17619e..3f9f2b5de8dbe 100644 --- a/lldb/include/lldb/ValueObject/ValueObject.h +++ b/lldb/include/lldb/ValueObject/ValueObject.h @@ -737,6 +737,12 @@ class ValueObject { CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat &v, CompilerType type, llvm::StringRef name); + /// Create a value object containing the given Scalar value. + static lldb::ValueObjectSP CreateValueObjectFromScalar(lldb::TargetSP target, + Scalar &s, + CompilerType type, + llvm::StringRef name); + /// Create a value object containing the given boolean value. static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target, bool value, diff --git a/lldb/include/lldb/ValueObject/ValueObjectConstResult.h b/lldb/include/lldb/ValueObject/ValueObjectConstResult.h index 1e4b81c4dc7f1..6fbb15328ee5c 100644 --- a/lldb/include/lldb/ValueObject/ValueObjectConstResult.h +++ b/lldb/include/lldb/ValueObject/ValueObjectConstResult.h @@ -60,6 +60,11 @@ class ValueObjectConstResult : public ValueObject { Value &value, ConstString name, Module *module = nullptr); + static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, +const CompilerType &compiler_type, +Scalar &scalar, ConstString name, +Module *module = nullptr); + // When an expression fails to evaluate, we return an error static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, Status &&error); @@ -145,6 +150,12 @@ class ValueObjectConstResult : public ValueObject { ValueObjectManager &manager, const Value &value, ConstString name, Module *module = nullptr); + ValueObjectConstResult(ExecutionContextScope *exe_scope, + ValueObjectManager &manager, + const CompilerType &compiler_type, + const Scalar &scalar, ConstString name, + Module *module = nullptr); + ValueObjectConstResult(ExecutionContextScope *exe_scope, ValueObjectManager &manager, Status &&error); diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp index c91b3f852f986..028f0587c5790 100644 --- a/lldb/source/Core/Value.cpp +++ b/lldb/source/Core/Value.cpp @@ -347,15 +347,9 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data, else data.SetAddressByteSize(sizeof(void *)); -uint32_t limit_byte_size = UINT32_MAX; - -if (type_size) - limit_byte_size = *type_size; - -if (limit_byte_size <= m_value.Ge
[Lldb-commits] [lldb] [lldb] Add `ValueObject::CreateValueObjectFromScalar` and fix `Scalar::GetData` (PR #151350)
https://github.com/kuilpd created https://github.com/llvm/llvm-project/pull/151350 Add `ValueObject::CreateValueObjectFromScalar` function and adjust `Scalar::GetData` to be able to both extend and truncate the data bytes in Scalar to a desired size. >From ff14392e82fb5658c87b4376551a0dc366b33e8c Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Wed, 30 Jul 2025 17:39:43 +0500 Subject: [PATCH] [lldb] Add `ValueObject::CreateValueObjectFromScalar` --- lldb/include/lldb/Utility/Scalar.h| 6 +- lldb/include/lldb/ValueObject/ValueObject.h | 6 ++ .../lldb/ValueObject/ValueObjectConstResult.h | 11 lldb/source/Core/Value.cpp| 12 +--- lldb/source/Utility/Scalar.cpp| 60 ++- lldb/source/ValueObject/ValueObject.cpp | 7 +++ .../ValueObject/ValueObjectConstResult.cpp| 27 + lldb/unittests/Utility/ScalarTest.cpp | 18 ++ 8 files changed, 122 insertions(+), 25 deletions(-) diff --git a/lldb/include/lldb/Utility/Scalar.h b/lldb/include/lldb/Utility/Scalar.h index b4b9c7e189582..dbb260962f1d6 100644 --- a/lldb/include/lldb/Utility/Scalar.h +++ b/lldb/include/lldb/Utility/Scalar.h @@ -84,11 +84,15 @@ class Scalar { /// Store the binary representation of this value into the given storage. /// Exactly GetByteSize() bytes will be stored, and the buffer must be large /// enough to hold this data. + void GetBytes(uint8_t *storage, size_t length) const; void GetBytes(llvm::MutableArrayRef storage) const; size_t GetByteSize() const; - bool GetData(DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const; + /// Get data with a byte size of GetByteSize(). + bool GetData(DataExtractor &data) const; + /// Get data with a byte size forced to \p result_byte_size. + bool GetData(DataExtractor &data, size_t result_byte_size) const; size_t GetAsMemoryData(void *dst, size_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const; diff --git a/lldb/include/lldb/ValueObject/ValueObject.h b/lldb/include/lldb/ValueObject/ValueObject.h index 3c62f3c17619e..3f9f2b5de8dbe 100644 --- a/lldb/include/lldb/ValueObject/ValueObject.h +++ b/lldb/include/lldb/ValueObject/ValueObject.h @@ -737,6 +737,12 @@ class ValueObject { CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat &v, CompilerType type, llvm::StringRef name); + /// Create a value object containing the given Scalar value. + static lldb::ValueObjectSP CreateValueObjectFromScalar(lldb::TargetSP target, + Scalar &s, + CompilerType type, + llvm::StringRef name); + /// Create a value object containing the given boolean value. static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target, bool value, diff --git a/lldb/include/lldb/ValueObject/ValueObjectConstResult.h b/lldb/include/lldb/ValueObject/ValueObjectConstResult.h index 1e4b81c4dc7f1..6fbb15328ee5c 100644 --- a/lldb/include/lldb/ValueObject/ValueObjectConstResult.h +++ b/lldb/include/lldb/ValueObject/ValueObjectConstResult.h @@ -60,6 +60,11 @@ class ValueObjectConstResult : public ValueObject { Value &value, ConstString name, Module *module = nullptr); + static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, +const CompilerType &compiler_type, +Scalar &scalar, ConstString name, +Module *module = nullptr); + // When an expression fails to evaluate, we return an error static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, Status &&error); @@ -145,6 +150,12 @@ class ValueObjectConstResult : public ValueObject { ValueObjectManager &manager, const Value &value, ConstString name, Module *module = nullptr); + ValueObjectConstResult(ExecutionContextScope *exe_scope, + ValueObjectManager &manager, + const CompilerType &compiler_type, + const Scalar &scalar, ConstString name, + Module *module = nullptr); + ValueObjectConstResult(ExecutionContextScope *exe_scope, ValueObjectManager &manager, Status &&error); diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp index c91b3f852f986..028f0587c5790 100644 --- a/lldb/source/Core/Value.cpp +++ b/lldb/source/Core/Value.cpp @@ -347,15 +347,9 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data, else data.SetAddressByteSize(sizeof(void *)); -
[Lldb-commits] [lldb] [lldb] Add `ValueObject::CreateValueObjectFromScalar` and fix `Scalar::GetData` (PR #151350)
kuilpd wrote: I'm trying here an alternative way of creating a const `ValueObject`. The way it's currently done with `CreateValueObjectFromAPInt` is getting its data bytes and sending them to `ValueObject::CreateValueObjectFromData`, which creates a `ValueObjectConstResult` with `ValueType::HostAddress`, which means that when converting that `ValueObject` back to an `APInt` it needs to go through a whole process of resolving the address and re-creating a Scalar from data (please correct me if I misunderstood this process). Btw, that last when is the part where Scalar [defaults to 32 bit width](https://github.com/llvm/llvm-project/blob/56944e606a1ba24e71fc89fad1eabb97e8240d65/lldb/source/Symbol/CompilerType.cpp#L1141), but for the host width of `int`, not the target. Instead, I'm creating a `ValueObjectConstResult` straight from a `Scalar` with `ValueType::Scalar`, which is stored in a `Value` field and gets immediately returned when resolving the `ValueObject` back to a `Scalar`. As far as I understand, this is all we need from for constant values, and it makes the process of wrapping/unwrapping scalars from values object faster. I had to fix `Scalar::GetData` though, to be able to return its data bytes with a larger size then its own byte size, as otherwise it crashed other parts of LLDB when it tried to get bytes from a `Value` with a larger compiler type size. https://github.com/llvm/llvm-project/pull/151350 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels (PR #148877)
@@ -328,6 +329,21 @@ class SymbolFile : public PluginInterface { GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector &mangled_names); + /// Resolves the function corresponding to the specified LLDB function + /// call \c label. + /// + /// \param[in,out] sc_list The resolved functions will be appended to this + /// list. + /// + /// \param[in] label The FunctionCallLabel to be resolved. + /// + /// \returns An llvm::Error if the specified \c label couldn't be resolved. + /// Returns \c llvm::ErrorSuccess otherwise. + virtual llvm::Error ResolveFunctionCallLabel(SymbolContextList &sc_list, + const FunctionCallLabel &label) { Michael137 wrote: Made the return type `llvm::Expected` as you suggested https://github.com/llvm/llvm-project/pull/148877 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Expression] Encode Module and DIE UIDs into function AsmLabels (PR #148877)
@@ -26,3 +30,74 @@ Expression::Expression(ExecutionContextScope &exe_scope) m_jit_end_addr(LLDB_INVALID_ADDRESS) { assert(m_target_wp.lock()); } + +/// Returns the components of the specified function call label. +/// +/// The format of \c label is described in \c FunctionCallLabel. +/// The label prefix is not one of the components. +static llvm::Expected> +splitFunctionCallLabel(llvm::StringRef label) { + if (!label.consume_front(FunctionCallLabelPrefix)) Michael137 wrote: nice, that was exactly what I was looking for https://github.com/llvm/llvm-project/pull/148877 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][windows] use Windows APIs to print to the console (PR #149493)
https://github.com/Nerixyz commented: I can't approve anything, but it works for me on Windows 11 👍 https://github.com/llvm/llvm-project/pull/149493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][windows] use Windows APIs to print to the console (PR #149493)
https://github.com/Nerixyz edited https://github.com/llvm/llvm-project/pull/149493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb][windows] use Windows APIs to print to the console (PR #149493)
@@ -853,4 +853,6 @@ raw_ostream &operator<<(raw_ostream &OS, const std::optional &O) { } // end namespace llvm +bool write_console_impl(int FD, llvm::StringRef Data); Nerixyz wrote: This should probably be in some `llvm` namespace - not in the global one. https://github.com/llvm/llvm-project/pull/149493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] eb9e526 - [lldb] Pick the builder for the target platform (#151262)
Author: Jonas Devlieghere Date: 2025-07-30T08:24:28-07:00 New Revision: eb9e526af050611ceafa6a53b73d72a7d3ea065c URL: https://github.com/llvm/llvm-project/commit/eb9e526af050611ceafa6a53b73d72a7d3ea065c DIFF: https://github.com/llvm/llvm-project/commit/eb9e526af050611ceafa6a53b73d72a7d3ea065c.diff LOG: [lldb] Pick the builder for the target platform (#151262) Pick the builder for the target platform, not the host platform. This is necessary when running the test suite remotely on a different platform. Unlike for Darwin, both Windows and Linux us the default builder, which is why this went unnoticed on the remote-linux bots. Added: Modified: lldb/packages/Python/lldbsuite/test/lldbplatformutil.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py index a1ab06076dcb2..cea6270695dc0 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py @@ -229,7 +229,8 @@ def hasChattyStderr(test_case): def builder_module(): -return get_builder(sys.platform) +"""Return the builder for the target platform.""" +return get_builder(getPlatform()) def getArchitecture(): ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Pick the builder for the target platform (PR #151262)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/151262 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove %T from lit tests (PR #151343)
https://github.com/boomanaiden154 ready_for_review https://github.com/llvm/llvm-project/pull/151343 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove %T from lit tests (PR #151343)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Aiden Grossman (boomanaiden154) Changes %T has been deprecated for about seven years, mostly because it is not unique to each test which can lead to races. This patch updates the few remaining tests in lldb that use %T to not use it (either directly using files or creating their own temp dir). The eventual goal is to remove support for %T from llvm-lit given few tests use it and it still has racey behavior. This patch errors on the side of creating new temp dirs even when not strictly necessary to avoid needing to update filenames inside filecheck matchers. --- Patch is 32.53 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/151343.diff 31 Files Affected: - (modified) lldb/test/Shell/Commands/command-disassemble-process.yaml (+6-5) - (modified) lldb/test/Shell/Commands/command-image-lookup.yaml (+5-4) - (modified) lldb/test/Shell/Minidump/Windows/arm-fp-unwind.test (+5-4) - (modified) lldb/test/Shell/Minidump/Windows/broken-unwind.test (+5-4) - (modified) lldb/test/Shell/Minidump/Windows/find-module.test (+7-6) - (modified) lldb/test/Shell/Minidump/memory-region-from-module.yaml (+3-3) - (modified) lldb/test/Shell/ObjectFile/Breakpad/uuid-matching-mac.test (+3-2) - (modified) lldb/test/Shell/ObjectFile/ELF/minidebuginfo-set-and-hit-breakpoint.test (+2-2) - (modified) lldb/test/Shell/SymbolFile/Breakpad/inline-record.test (+3-2) - (modified) lldb/test/Shell/SymbolFile/Breakpad/line-table-discontinuous-file-ids.test (+3-2) - (modified) lldb/test/Shell/SymbolFile/Breakpad/line-table-edgecases.test (+3-2) - (modified) lldb/test/Shell/SymbolFile/Breakpad/line-table-missing-file.test (+3-2) - (modified) lldb/test/Shell/SymbolFile/Breakpad/line-table-mixed-path-styles.test (+3-2) - (modified) lldb/test/Shell/SymbolFile/Breakpad/line-table.test (+3-2) - (modified) lldb/test/Shell/SymbolFile/Breakpad/symtab-macho.test (+3-2) - (modified) lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test (+3-2) - (modified) lldb/test/Shell/SymbolFile/Breakpad/symtab.test (+3-2) - (modified) lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win-no-memory-info.yaml (+3-2) - (modified) lldb/test/Shell/SymbolFile/DWARF/dwo-missing-error.test (-1) - (modified) lldb/test/Shell/SymbolFile/DWARF/dwo-relative-path.s (+4-3) - (modified) lldb/test/Shell/SymbolFile/DWARF/x86/debug_loclists-dwo.s (+2-1) - (modified) lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s (+2-1) - (modified) lldb/test/Shell/SymbolFile/DWARF/x86/dwo-type-in-main-file.s (-1) - (modified) lldb/test/Shell/SymbolFile/PDB/class-layout.test (+13-12) - (modified) lldb/test/Shell/SymbolFile/PDB/compilands.test (+5-4) - (modified) lldb/test/Shell/SymbolFile/PDB/enums-layout.test (+8-7) - (modified) lldb/test/Shell/SymbolFile/PDB/func-symbols.test (+4-3) - (modified) lldb/test/Shell/SymbolFile/PDB/pointers.test (+8-7) - (modified) lldb/test/Shell/SymbolFile/PDB/type-quals.test (+4-3) - (modified) lldb/test/Shell/SymbolFile/PDB/typedefs.test (+3-2) - (modified) lldb/test/Shell/SymbolFile/PDB/variables.test (+9-8) ``diff diff --git a/lldb/test/Shell/Commands/command-disassemble-process.yaml b/lldb/test/Shell/Commands/command-disassemble-process.yaml index ce1b37bc8aea7..931e0b93e3b67 100644 --- a/lldb/test/Shell/Commands/command-disassemble-process.yaml +++ b/lldb/test/Shell/Commands/command-disassemble-process.yaml @@ -1,19 +1,20 @@ # REQUIRES: x86 -# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8 %s -o %T/command-disassemble-process.exe -# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8000 %s -o %T/command-disassemble-process.big.exe +# RUN: mkdir -p %t.dir +# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8 %s -o %t.dir/command-disassemble-process.exe +# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8000 %s -o %t.dir/command-disassemble-process.big.exe # RUN: yaml2obj --docnum=2 %s -o %t -# RUN: %lldb -c %t %T/command-disassemble-process.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.exe \ # RUN: -o "settings set interpreter.stop-command-source-on-error false" \ # RUN: -s %S/Inputs/command-disassemble-process.lldbinit -o exit \ # RUN: | FileCheck %s -# RUN: %lldb -c %t %T/command-disassemble-process.big.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.big.exe \ # RUN: -o "settings set stop-disassembly-max-size 8000" \ # RUN: -o disassemble -o exit 2>&1 | FileCheck %s --check-prefix=BIG -# RUN: %lldb -c %t %T/command-disassemble-process.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.exe \ # RUN: -o "settings set interpreter.stop-command-source-on-error false" \ # RUN: -o "disassemble --address 0xdead" -o exit 2>&1 \ # RUN: | FileCheck %s --check-prefix=INVALID diff --git a/lldb/test/Shell/Commands/command-image-lookup.yaml b/lldb/test/Shell/Commands/command-image-lookup.yaml index cf7be930517ee..fc12b99eab589 100644 --- a/lldb/test/Shell/Commands/command-
[Lldb-commits] [lldb] [lldb] Remove a redundant call to std::unique_ptr::get (NFC) (PR #151283)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/151283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement RegisterContextWasm (PR #151056)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/151056 >From c9cea26faaede58bcc8a68eb91425fda21455983 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 28 Jul 2025 10:38:02 -0700 Subject: [PATCH 1/3] [lldb] Support DW_OP_WASM_location in DWARFExpression Add support for DW_OP_WASM_location in DWARFExpression. This PR rebases #78977 and cleans up the unit test. --- .../include/lldb/Expression/DWARFExpression.h | 12 +- lldb/source/Expression/DWARFExpression.cpp| 10 +- .../ObjectFile/wasm/ObjectFileWasm.cpp| 6 +- .../Plugins/SymbolFile/DWARF/CMakeLists.txt | 1 + .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp| 4 +- .../Plugins/SymbolFile/DWARF/DWARFUnit.h | 8 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 4 + .../SymbolFile/DWARF/SymbolFileDWARF.h| 3 + .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp | 8 +- .../SymbolFile/DWARF/SymbolFileDWARFDwo.h | 3 +- .../SymbolFile/DWARF/SymbolFileWasm.cpp | 91 +++ .../Plugins/SymbolFile/DWARF/SymbolFileWasm.h | 34 + lldb/source/Utility/WasmVirtualRegisters.h| 53 ++ lldb/unittests/Expression/CMakeLists.txt | 2 + .../Expression/DWARFExpressionTest.cpp| 579 +- 15 files changed, 649 insertions(+), 169 deletions(-) create mode 100644 lldb/source/Plugins/SymbolFile/DWARF/SymbolFileWasm.cpp create mode 100644 lldb/source/Plugins/SymbolFile/DWARF/SymbolFileWasm.h create mode 100644 lldb/source/Utility/WasmVirtualRegisters.h diff --git a/lldb/include/lldb/Expression/DWARFExpression.h b/lldb/include/lldb/Expression/DWARFExpression.h index 37853c0b5a8fc..8fcc5d37b91c9 100644 --- a/lldb/include/lldb/Expression/DWARFExpression.h +++ b/lldb/include/lldb/Expression/DWARFExpression.h @@ -52,10 +52,10 @@ class DWARFExpression { GetVendorDWARFOpcodeSize(const DataExtractor &data, const lldb::offset_t data_offset, const uint8_t op) const = 0; -virtual bool ParseVendorDWARFOpcode(uint8_t op, -const DataExtractor &opcodes, -lldb::offset_t &offset, -Stack &stack) const = 0; +virtual bool +ParseVendorDWARFOpcode(uint8_t op, const DataExtractor &opcodes, + lldb::offset_t &offset, RegisterContext *reg_ctx, + lldb::RegisterKind reg_kind, Stack &stack) const = 0; Delegate(const Delegate &) = delete; Delegate &operator=(const Delegate &) = delete; @@ -163,6 +163,10 @@ class DWARFExpression { bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op) const; + static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx, + lldb::RegisterKind reg_kind, + uint32_t reg_num, Value &value); + private: /// A data extractor capable of reading opcode bytes DataExtractor m_data; diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index 79bc6c87fa9c5..391e27704b63d 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -91,9 +91,10 @@ void DWARFExpression::SetRegisterKind(RegisterKind reg_kind) { m_reg_kind = reg_kind; } -static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx, - lldb::RegisterKind reg_kind, - uint32_t reg_num, Value &value) { +llvm::Error +DWARFExpression::ReadRegisterValueAsScalar(RegisterContext *reg_ctx, + lldb::RegisterKind reg_kind, + uint32_t reg_num, Value &value) { if (reg_ctx == nullptr) return llvm::createStringError("no register context in frame"); @@ -2302,7 +2303,8 @@ llvm::Expected DWARFExpression::Evaluate( default: if (dwarf_cu) { -if (dwarf_cu->ParseVendorDWARFOpcode(op, opcodes, offset, stack)) { +if (dwarf_cu->ParseVendorDWARFOpcode(op, opcodes, offset, reg_ctx, + reg_kind, stack)) { break; } } diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp index 67963a790a4fe..b1efd25949379 100644 --- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp +++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp @@ -376,9 +376,13 @@ DataExtractor ObjectFileWasm::ReadImageData(offset_t offset, uint32_t size) { DataBufferSP buffer_sp(data_up.release()); data.SetData(buffer_sp, 0, buffer_sp->GetByteSize()); } +} else if (offset < m_data.GetByteSize()) { + size = + std::min(static_cast(size), m_data.GetByteSize() - offset); +
[Lldb-commits] [lldb] 5327eeb - [lldb] Remove a redundant call to std::unique_ptr::get (NFC) (#151283)
Author: Kazu Hirata Date: 2025-07-30T07:30:30-07:00 New Revision: 5327eeb0bf4eed084b1761cd1b14f3f335383e95 URL: https://github.com/llvm/llvm-project/commit/5327eeb0bf4eed084b1761cd1b14f3f335383e95 DIFF: https://github.com/llvm/llvm-project/commit/5327eeb0bf4eed084b1761cd1b14f3f335383e95.diff LOG: [lldb] Remove a redundant call to std::unique_ptr::get (NFC) (#151283) Added: Modified: lldb/source/Interpreter/ScriptInterpreter.cpp Removed: diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp index 5ee19ffda0a0b..6a654a0dafe5b 100644 --- a/lldb/source/Interpreter/ScriptInterpreter.cpp +++ b/lldb/source/Interpreter/ScriptInterpreter.cpp @@ -119,7 +119,7 @@ lldb::StreamSP ScriptInterpreter::GetOpaqueTypeFromSBStream( SymbolContext ScriptInterpreter::GetOpaqueTypeFromSBSymbolContext( const lldb::SBSymbolContext &sb_sym_ctx) const { if (sb_sym_ctx.m_opaque_up) -return *sb_sym_ctx.m_opaque_up.get(); +return *sb_sym_ctx.m_opaque_up; return {}; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove %T from lit tests (PR #151343)
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/151343 %T has been deprecated for about seven years, mostly because it is not unique to each test which can lead to races. This patch updates the few remaining tests in lldb that use %T to not use it (either directly using files or creating their own temp dir). The eventual goal is to remove support for %T from llvm-lit given few tests use it and it still has racey behavior. This patch errors on the side of creating new temp dirs even when not strictly necessary to avoid needing to update filenames inside filecheck matchers. >From f18f2c1b654fa6f5925109eae0277bbbceb48565 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Wed, 30 Jul 2025 14:13:02 + Subject: [PATCH] [lldb] Remove %T from lit tests %T has been deprecated for about seven years, mostly because it is not unique to each test which can lead to races. This patch updates the few remaining tests in lldb that use %T to not use it (either directly using files or creating their own temp dir). The eventual goal is to remove support for %T from llvm-lit given few tests use it and it still has racey behavior. This patch errors on the side of creating new temp dirs even when not strictly necessary to avoid needing to update filenames inside filecheck matchers. --- .../Commands/command-disassemble-process.yaml | 11 .../Shell/Commands/command-image-lookup.yaml | 9 --- .../Shell/Minidump/Windows/arm-fp-unwind.test | 9 --- .../Shell/Minidump/Windows/broken-unwind.test | 9 --- .../Shell/Minidump/Windows/find-module.test | 13 +- .../Minidump/memory-region-from-module.yaml | 6 ++--- .../Breakpad/uuid-matching-mac.test | 5 ++-- .../minidebuginfo-set-and-hit-breakpoint.test | 4 +-- .../SymbolFile/Breakpad/inline-record.test| 5 ++-- .../line-table-discontinuous-file-ids.test| 5 ++-- .../Breakpad/line-table-edgecases.test| 5 ++-- .../Breakpad/line-table-missing-file.test | 5 ++-- .../line-table-mixed-path-styles.test | 5 ++-- .../Shell/SymbolFile/Breakpad/line-table.test | 5 ++-- .../SymbolFile/Breakpad/symtab-macho.test | 5 ++-- .../Breakpad/symtab-sorted-by-size.test | 5 ++-- .../Shell/SymbolFile/Breakpad/symtab.test | 5 ++-- .../unwind-via-stack-win-no-memory-info.yaml | 5 ++-- .../SymbolFile/DWARF/dwo-missing-error.test | 1 - .../SymbolFile/DWARF/dwo-relative-path.s | 7 +++--- .../SymbolFile/DWARF/x86/debug_loclists-dwo.s | 3 ++- .../SymbolFile/DWARF/x86/debug_rnglists-dwo.s | 3 ++- .../DWARF/x86/dwo-type-in-main-file.s | 1 - .../Shell/SymbolFile/PDB/class-layout.test| 25 ++- .../test/Shell/SymbolFile/PDB/compilands.test | 9 --- .../Shell/SymbolFile/PDB/enums-layout.test| 15 +-- .../Shell/SymbolFile/PDB/func-symbols.test| 7 +++--- lldb/test/Shell/SymbolFile/PDB/pointers.test | 15 +-- .../test/Shell/SymbolFile/PDB/type-quals.test | 7 +++--- lldb/test/Shell/SymbolFile/PDB/typedefs.test | 5 ++-- lldb/test/Shell/SymbolFile/PDB/variables.test | 17 +++-- 31 files changed, 128 insertions(+), 103 deletions(-) diff --git a/lldb/test/Shell/Commands/command-disassemble-process.yaml b/lldb/test/Shell/Commands/command-disassemble-process.yaml index ce1b37bc8aea7..931e0b93e3b67 100644 --- a/lldb/test/Shell/Commands/command-disassemble-process.yaml +++ b/lldb/test/Shell/Commands/command-disassemble-process.yaml @@ -1,19 +1,20 @@ # REQUIRES: x86 -# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8 %s -o %T/command-disassemble-process.exe -# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8000 %s -o %T/command-disassemble-process.big.exe +# RUN: mkdir -p %t.dir +# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8 %s -o %t.dir/command-disassemble-process.exe +# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8000 %s -o %t.dir/command-disassemble-process.big.exe # RUN: yaml2obj --docnum=2 %s -o %t -# RUN: %lldb -c %t %T/command-disassemble-process.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.exe \ # RUN: -o "settings set interpreter.stop-command-source-on-error false" \ # RUN: -s %S/Inputs/command-disassemble-process.lldbinit -o exit \ # RUN: | FileCheck %s -# RUN: %lldb -c %t %T/command-disassemble-process.big.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.big.exe \ # RUN: -o "settings set stop-disassembly-max-size 8000" \ # RUN: -o disassemble -o exit 2>&1 | FileCheck %s --check-prefix=BIG -# RUN: %lldb -c %t %T/command-disassemble-process.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.exe \ # RUN: -o "settings set interpreter.stop-command-source-on-error false" \ # RUN: -o "disassemble --address 0xdead" -o exit 2>&1 \ # RUN: | FileCheck %s --check-prefix=INVALID diff --git a/lldb/test/Shell/Commands/command-image-lookup.yaml b/lldb/test/Shell/Commands/command-image-lookup.yaml index cf7be930517ee..fc12b99eab589 100644 --- a/l
[Lldb-commits] [lldb] [llvm] [lldb][windows] use Windows APIs to print to the console (PR #149493)
charles-zablit wrote: Hi @Nerixyz, is there anything else I can add to this patch to get it merged? https://github.com/llvm/llvm-project/pull/149493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement RegisterContextWasm (PR #151056)
@@ -71,28 +124,62 @@ def qXferRead(self, obj, annex, offset, length): if obj == "libraries": xml = ( '' -% (self._module_name, load_address) +% (self._module_name, LOAD_ADDRESS) ) return xml, False else: return None, False def readMemory(self, addr, length): -if addr < load_address: +if self._memory and self._memory.contains(addr): +chunk = self._memory.get_bytes(addr, length) +return chunk.hex() JDevlieghere wrote: Porbably? Do we actually run the test suite on a big endian platform? Not trying to say it's not important, but I don't have a platform to try on and I don't remember seeing other gdb_remote_client support that. https://github.com/llvm/llvm-project/pull/151056 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement RegisterContextWasm (PR #151056)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/151056 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove %T from lit tests (PR #151343)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/151343 >From f18f2c1b654fa6f5925109eae0277bbbceb48565 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Wed, 30 Jul 2025 14:13:02 + Subject: [PATCH 1/2] [lldb] Remove %T from lit tests %T has been deprecated for about seven years, mostly because it is not unique to each test which can lead to races. This patch updates the few remaining tests in lldb that use %T to not use it (either directly using files or creating their own temp dir). The eventual goal is to remove support for %T from llvm-lit given few tests use it and it still has racey behavior. This patch errors on the side of creating new temp dirs even when not strictly necessary to avoid needing to update filenames inside filecheck matchers. --- .../Commands/command-disassemble-process.yaml | 11 .../Shell/Commands/command-image-lookup.yaml | 9 --- .../Shell/Minidump/Windows/arm-fp-unwind.test | 9 --- .../Shell/Minidump/Windows/broken-unwind.test | 9 --- .../Shell/Minidump/Windows/find-module.test | 13 +- .../Minidump/memory-region-from-module.yaml | 6 ++--- .../Breakpad/uuid-matching-mac.test | 5 ++-- .../minidebuginfo-set-and-hit-breakpoint.test | 4 +-- .../SymbolFile/Breakpad/inline-record.test| 5 ++-- .../line-table-discontinuous-file-ids.test| 5 ++-- .../Breakpad/line-table-edgecases.test| 5 ++-- .../Breakpad/line-table-missing-file.test | 5 ++-- .../line-table-mixed-path-styles.test | 5 ++-- .../Shell/SymbolFile/Breakpad/line-table.test | 5 ++-- .../SymbolFile/Breakpad/symtab-macho.test | 5 ++-- .../Breakpad/symtab-sorted-by-size.test | 5 ++-- .../Shell/SymbolFile/Breakpad/symtab.test | 5 ++-- .../unwind-via-stack-win-no-memory-info.yaml | 5 ++-- .../SymbolFile/DWARF/dwo-missing-error.test | 1 - .../SymbolFile/DWARF/dwo-relative-path.s | 7 +++--- .../SymbolFile/DWARF/x86/debug_loclists-dwo.s | 3 ++- .../SymbolFile/DWARF/x86/debug_rnglists-dwo.s | 3 ++- .../DWARF/x86/dwo-type-in-main-file.s | 1 - .../Shell/SymbolFile/PDB/class-layout.test| 25 ++- .../test/Shell/SymbolFile/PDB/compilands.test | 9 --- .../Shell/SymbolFile/PDB/enums-layout.test| 15 +-- .../Shell/SymbolFile/PDB/func-symbols.test| 7 +++--- lldb/test/Shell/SymbolFile/PDB/pointers.test | 15 +-- .../test/Shell/SymbolFile/PDB/type-quals.test | 7 +++--- lldb/test/Shell/SymbolFile/PDB/typedefs.test | 5 ++-- lldb/test/Shell/SymbolFile/PDB/variables.test | 17 +++-- 31 files changed, 128 insertions(+), 103 deletions(-) diff --git a/lldb/test/Shell/Commands/command-disassemble-process.yaml b/lldb/test/Shell/Commands/command-disassemble-process.yaml index ce1b37bc8aea7..931e0b93e3b67 100644 --- a/lldb/test/Shell/Commands/command-disassemble-process.yaml +++ b/lldb/test/Shell/Commands/command-disassemble-process.yaml @@ -1,19 +1,20 @@ # REQUIRES: x86 -# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8 %s -o %T/command-disassemble-process.exe -# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8000 %s -o %T/command-disassemble-process.big.exe +# RUN: mkdir -p %t.dir +# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8 %s -o %t.dir/command-disassemble-process.exe +# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8000 %s -o %t.dir/command-disassemble-process.big.exe # RUN: yaml2obj --docnum=2 %s -o %t -# RUN: %lldb -c %t %T/command-disassemble-process.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.exe \ # RUN: -o "settings set interpreter.stop-command-source-on-error false" \ # RUN: -s %S/Inputs/command-disassemble-process.lldbinit -o exit \ # RUN: | FileCheck %s -# RUN: %lldb -c %t %T/command-disassemble-process.big.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.big.exe \ # RUN: -o "settings set stop-disassembly-max-size 8000" \ # RUN: -o disassemble -o exit 2>&1 | FileCheck %s --check-prefix=BIG -# RUN: %lldb -c %t %T/command-disassemble-process.exe \ +# RUN: %lldb -c %t %t.dir/command-disassemble-process.exe \ # RUN: -o "settings set interpreter.stop-command-source-on-error false" \ # RUN: -o "disassemble --address 0xdead" -o exit 2>&1 \ # RUN: | FileCheck %s --check-prefix=INVALID diff --git a/lldb/test/Shell/Commands/command-image-lookup.yaml b/lldb/test/Shell/Commands/command-image-lookup.yaml index cf7be930517ee..fc12b99eab589 100644 --- a/lldb/test/Shell/Commands/command-image-lookup.yaml +++ b/lldb/test/Shell/Commands/command-image-lookup.yaml @@ -1,7 +1,8 @@ -# RUN: yaml2obj %s -o %T/a.out -# RUN: %lldb %T/a.out -o "image lookup --verbose --address 0x00013fa1" -o exit | FileCheck %s --check-prefix=NOINLINE -# RUN: %lldb %T/a.out -o "image lookup --verbose --address 0x00013fa2" -o exit | FileCheck %s --check-prefix=INLINE_1 -# RUN: %lldb %T/a.out -o "image lookup --verbose --address 0x00013fa8" -o exit | FileCheck %s --check-pref
[Lldb-commits] [lldb] [lldb] Implement RegisterContextWasm (PR #151056)
@@ -0,0 +1,228 @@ +--- !WASM JDevlieghere wrote: I added the invocation to the Python files. https://github.com/llvm/llvm-project/pull/151056 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement RegisterContextWasm (PR #151056)
@@ -224,67 +311,68 @@ def test_load_module_with_stripped_symbols_from_remote(self): @skipIfAsan @skipIfXmlSupportMissing -def test_load_module_from_file(self): -"""Test connecting to a WebAssembly engine via GDB-remote and loading a Wasm module from a file""" +def test_simple_wasm_debugging_session(self): +"""Test connecting to a WebAssembly engine via GDB-remote, loading a +Wasm module with embedded DWARF symbols, setting a breakpoint and +checking the debuggee state""" -yaml_path = "test_wasm_embedded_debug_sections.yaml" -yaml_base, ext = os.path.splitext(yaml_path) +yaml_path = "simple.yaml" +yaml_base, _ = os.path.splitext(yaml_path) obj_path = self.getBuildArtifact(yaml_base) self.yaml2obj(yaml_path, obj_path) -self.server.responder = MyResponder(obj_path) +# Create a fake call stack. +call_stacks = [ +WasmCallStack( +[WasmStackFrame(0x019C), WasmStackFrame(0x01E5), WasmStackFrame(0x01FE)] +), +] + +# Create fake memory for our wasm locals. +self.memory = FakeMemory(0x1, 0x2) +self.memory.store_bytes( +WASM_LOCAL_ADDR, +bytes.fromhex( + "0200010002000100" +), +) + +self.server.responder = MyResponder( +obj_path, "test_wasm", call_stacks, self.memory +) target = self.dbg.CreateTarget("") +breakpoint = target.BreakpointCreateByName("add") process = self.connect(target, "wasm") lldbutil.expect_state_changes( self, self.dbg.GetListener(), process, [lldb.eStateStopped] ) +location = breakpoint.GetLocationAtIndex(0) +self.assertTrue(location and location.IsEnabled(), VALID_BREAKPOINT_LOCATION) + num_modules = target.GetNumModules() self.assertEqual(1, num_modules) -module = target.GetModuleAtIndex(0) -num_sections = module.GetNumSections() -self.assertEqual(5, num_sections) - -code_section = module.GetSectionAtIndex(0) -self.assertEqual("code", code_section.GetName()) -self.assertEqual( -load_address | code_section.GetFileOffset(), -code_section.GetLoadAddress(target), -) - -debug_info_section = module.GetSectionAtIndex(1) -self.assertEqual(".debug_info", debug_info_section.GetName()) -self.assertEqual( -LLDB_INVALID_ADDRESS, debug_info_section.GetLoadAddress(target) -) - -debug_abbrev_section = module.GetSectionAtIndex(2) -self.assertEqual(".debug_abbrev", debug_abbrev_section.GetName()) -self.assertEqual( -LLDB_INVALID_ADDRESS, debug_abbrev_section.GetLoadAddress(target) -) - -debug_line_section = module.GetSectionAtIndex(3) -self.assertEqual(".debug_line", debug_line_section.GetName()) -self.assertEqual( -LLDB_INVALID_ADDRESS, debug_line_section.GetLoadAddress(target) -) - -debug_str_section = module.GetSectionAtIndex(4) -self.assertEqual(".debug_str", debug_str_section.GetName()) -self.assertEqual( -LLDB_INVALID_ADDRESS, debug_line_section.GetLoadAddress(target) -) - thread = process.GetThreadAtIndex(0) self.assertTrue(thread.IsValid()) -frame = thread.GetFrameAtIndex(0) -self.assertTrue(frame.IsValid()) -self.assertEqual(frame.GetPC(), 0x41B3) - -frame = thread.GetFrameAtIndex(1) -self.assertTrue(frame.IsValid()) -self.assertEqual(frame.GetPC(), 0x41FE) +# Check that our frames match our fake call stack. +frame0 = thread.GetFrameAtIndex(0) +self.assertTrue(frame0.IsValid()) +self.assertEqual(frame0.GetPC(), LOAD_ADDRESS | 0x019C) +self.assertIn("add", frame0.GetFunctionName()) + +frame1 = thread.GetFrameAtIndex(1) +self.assertTrue(frame1.IsValid()) +self.assertEqual(frame1.GetPC(), LOAD_ADDRESS | 0x01E5) +self.assertIn("main", frame1.GetFunctionName()) + +# Check that we can resolve local variables. JDevlieghere wrote: I found [this issue](https://github.com/emscripten-core/emscripten/issues/12793) which says that you can't, but maybe things have changed in the meantime. I'll try and see what happens. https://github.com/llvm/llvm-project/pull/151056 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #151010)
@@ -0,0 +1,91 @@ +//===--===// +// +// 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 "SymbolFileWasm.h" +#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" +#include "Utility/WasmVirtualRegisters.h" +#include "lldb/Utility/LLDBLog.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::plugin::dwarf; + +SymbolFileWasm::SymbolFileWasm(ObjectFileSP objfile_sp, + SectionList *dwo_section_list) +: SymbolFileDWARF(objfile_sp, dwo_section_list) {} + +SymbolFileWasm::~SymbolFileWasm() = default; + +lldb::offset_t +SymbolFileWasm::GetVendorDWARFOpcodeSize(const DataExtractor &data, + const lldb::offset_t data_offset, + const uint8_t op) const { + if (op != llvm::dwarf::DW_OP_WASM_location) +return LLDB_INVALID_OFFSET; + + lldb::offset_t offset = data_offset; + const uint8_t wasm_op = data.GetU8(&offset); + if (wasm_op == eWasmTagOperandStack) +data.GetU32(&offset); + else +data.GetULEB128(&offset); JDevlieghere wrote: Yes that's right. If it's too obscure I can reuse the switch here. https://github.com/llvm/llvm-project/pull/151010 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add LLDB test for UBSan trap frame recognizer (PR #151231)
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/151231 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add LLDB test for UBSan trap frame recognizer (PR #151231)
https://github.com/delcypher approved this pull request. Mostly looks good. Please remove the uses of `volatile` unless there's a good reason for them to be there. Also please make the description/commit message be more descriptive. Something like ``` [lldb][NFC] Add test cases for UBSan trap reasons In https://github.com/llvm/llvm-project/pull/145967 Clang was taught to emit trap reasons on UBSan traps in debug info using the same method as `__builtin_verbose_trap`. This patch adds a test case to make sure that the existing "Verbose Trap StackFrame Recognizer" recognizes the trap reason and sets the stop reason and stack frame appropriately. ``` https://github.com/llvm/llvm-project/pull/151231 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add LLDB test for UBSan trap frame recognizer (PR #151231)
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/151231 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Add LLDB test for UBSan trap frame recognizer (PR #151231)
@@ -0,0 +1,8 @@ +#include + +int main() { + volatile int a = INT_MAX; delcypher wrote: Why is `volatile` here? https://github.com/llvm/llvm-project/pull/151231 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add software watchpoints support (PR #151195)
dlav-sc wrote: > software implemented watchpoint is going to be so slow Well, yeah, they're quite slow, especially on targets that don't support hardware stepping. I've tested this patch on both riscv and x86 and the software watchpoints work significantly faster on x86 compared to riscv. I believe this difference comes from x86 using hardware stepping while riscv relies on software stepping. However, such performance is specific to software watchpoints. Since gdb already supports software watchpoints, I don't see why we shouldn't add them to lldb as well. > I doubt it will be useful in any real program debug session The original goal of my work was to enable watchpoint functionality at any cost on targets without hardware watchpoint support, in particular riscv. Now, with some limitations and speed tradeoffs of course, software watchpoints are available. Moreover, while hardware watchpoints only work for memory locations, software watchpoints don't have this limitation. In the future, we could use them to monitor registers and other complex expressions, like gdb do. > I do wonder if we can reliably instruction step over every instruction on > every target It's hard to say for sure, but generally there are no guarantees. While developing this patch, I encountered several bugs related to stepping (https://github.com/llvm/llvm-project/pull/127506) and discovered that lldb lacks proper support for stepping through atomic sequences on riscv (https://github.com/llvm/llvm-project/pull/127505). https://github.com/llvm/llvm-project/pull/151195 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add software watchpoints support (PR #151195)
DavidSpickett wrote: > I do wonder if we can reliably instruction step over every instruction on > every target (atomics instructions/sequences seem to be a sore point). https://github.com/llvm/llvm-project/issues/34572 / https://github.com/llvm/llvm-project/issues/24318 / https://github.com/llvm/llvm-project/issues/60259 If it was just single instructions, we realise we can't step it accurately, disable all software watchpoints, and tell the user what happened. The problem with sequences is we don't know that we're in them. Very few people have complained about atomic sequences, but then again, most people don't instruction single step a lot of code. I can't think of another "sequence" thing we don't handle, but I feel like there can't be more than 2/3 things. That combined with v8.1 having single instruction atomics, mitigates it further. Let me do some research to see if it really is a handful of sequence types. https://github.com/llvm/llvm-project/pull/151195 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] add TemplateRange and NameQualifiersRange to DemangledNameInfo (PR #150999)
https://github.com/Michael137 commented: Am I missing something or is `NameQualifiersRange` not being set/used in this patch? https://github.com/llvm/llvm-project/pull/150999 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update JSONTransport to use MainLoop for reading. (PR #148300)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/148300 >From 7857cff5f79c603c72edb69f0c10294e5e042ebc Mon Sep 17 00:00:00 2001 From: John Harrison Date: Fri, 11 Jul 2025 14:24:42 -0700 Subject: [PATCH 1/5] [lldb] Update JSONTransport to use MainLoop for reading. This updates JSONTransport to use a MainLoop for reading messages. This also allows us to read in larger chunks than we did previously. With the event driven reading operations we can read in chunks and store the contents in an internal buffer. Separately we can parse the buffer and split the contents up into messages. Our previous version approach would read a byte at a time, which is less efficient. --- lldb/include/lldb/Host/JSONTransport.h| 78 ++-- lldb/source/Host/common/JSONTransport.cpp | 180 +++--- lldb/test/API/tools/lldb-dap/io/TestDAP_io.py | 12 +- lldb/tools/lldb-dap/DAP.cpp | 130 +++-- lldb/tools/lldb-dap/DAP.h | 7 + lldb/tools/lldb-dap/Transport.h | 2 +- lldb/unittests/DAP/DAPTest.cpp| 11 +- lldb/unittests/DAP/TestBase.cpp | 26 ++- lldb/unittests/DAP/TestBase.h | 21 ++ lldb/unittests/Host/JSONTransportTest.cpp | 175 +++-- .../Protocol/ProtocolMCPServerTest.cpp| 135 +++-- 11 files changed, 443 insertions(+), 334 deletions(-) diff --git a/lldb/include/lldb/Host/JSONTransport.h b/lldb/include/lldb/Host/JSONTransport.h index 4087cdf2b42f7..170aa4a8b8811 100644 --- a/lldb/include/lldb/Host/JSONTransport.h +++ b/lldb/include/lldb/Host/JSONTransport.h @@ -13,13 +13,15 @@ #ifndef LLDB_HOST_JSONTRANSPORT_H #define LLDB_HOST_JSONTRANSPORT_H +#include "lldb/Host/MainLoopBase.h" #include "lldb/lldb-forward.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/JSON.h" -#include +#include #include +#include namespace lldb_private { @@ -68,6 +70,10 @@ class TransportInvalidError : public llvm::ErrorInfo { /// A transport class that uses JSON for communication. class JSONTransport { public: + using ReadHandleUP = MainLoopBase::ReadHandleUP; + template + using Callback = std::function)>; + JSONTransport(lldb::IOObjectSP input, lldb::IOObjectSP output); virtual ~JSONTransport() = default; @@ -83,24 +89,59 @@ class JSONTransport { return WriteImpl(message); } - /// Reads the next message from the input stream. + /// Registers the transport with the MainLoop. template - llvm::Expected Read(const std::chrono::microseconds &timeout) { -llvm::Expected message = ReadImpl(timeout); -if (!message) - return message.takeError(); -return llvm::json::parse(/*JSON=*/*message); + llvm::Expected RegisterReadObject(MainLoopBase &loop, + Callback callback) { +Status error; +ReadHandleUP handle = loop.RegisterReadObject( +m_input, +[&](MainLoopBase &loop) { + char buf[1024]; + size_t len = sizeof(buf); + do { +if (llvm::Error error = m_input->Read(buf, len).takeError()) { + callback(loop, std::move(error)); + return; +} + +if (len == 0) // EOF + break; + +m_buffer.append(std::string(buf, len)); + } while (len == sizeof(buf)); + + llvm::Expected> messages = Parse(); + if (llvm::Error error = messages.takeError()) { +callback(loop, std::move(error)); +return; + } + + for (const auto &message : *messages) +if constexpr (std::is_same::value) + callback(loop, message); +else + callback(loop, llvm::json::parse(message)); + + // On EOF, request termination after handling all the messages. + if (len == 0) +callback(loop, llvm::make_error()); +}, +error); +if (error.Fail()) + return error.takeError(); +return handle; } protected: virtual void Log(llvm::StringRef message); virtual llvm::Error WriteImpl(const std::string &message) = 0; - virtual llvm::Expected - ReadImpl(const std::chrono::microseconds &timeout) = 0; + virtual llvm::Expected> Parse() = 0; lldb::IOObjectSP m_input; lldb::IOObjectSP m_output; + std::string m_buffer; }; /// A transport class for JSON with a HTTP header. @@ -111,14 +152,12 @@ class HTTPDelimitedJSONTransport : public JSONTransport { virtual ~HTTPDelimitedJSONTransport() = default; protected: - virtual llvm::Error WriteImpl(const std::string &message) override; - virtual llvm::Expected - ReadImpl(const std::chrono::microseconds &timeout) override; - - // FIXME: Support any header. - static constexpr llvm::StringLiteral kHeaderContentLength = - "Content-Length: "; - static constexpr
[Lldb-commits] [lldb] [llvm] [lldb][windows] use Windows APIs to print to the console (PR #149493)
@@ -853,4 +853,6 @@ raw_ostream &operator<<(raw_ostream &OS, const std::optional &O) { } // end namespace llvm +bool write_console_impl(int FD, llvm::StringRef Data); adrian-prantl wrote: This is making an internal API that only makes sense on Windows public — would be possible to just use a raw_fd_ostream in lldb::File.cpp instead? https://github.com/llvm/llvm-project/pull/149493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix race condition in Process::WaitForProcessToStop() (PR #144919)
athierry-oct wrote: Hi, sorry for the delay. I investigated the `TestCallThatRestarts.py` failure, and I think I’ve figured out what’s going on. Toward the end of the test, we run: ```python value = frame.EvaluateExpression("call_me (%d)" % (num_sigchld), options) ``` Then we call: ```python error = process.Continue() ``` This triggers `Process::ResumeSynchronous()`, which: - Hijacks the process events - Calls `PrivateResume()` - Waits for a stop event via `WaitForProcessToStop()` The issue is that a public stop event is sent at the end of `EvaluateExpression()`, and that event is still sitting in the primary listener’s queue when `Process::ResumeSynchronous()` hijacks the events. With my changes, that old stop event gets moved to the hijacker’s queue. So `ResumeSynchronous()` ends up grabbing it (even though it happened *before* the resume) and returns too early. It looks like moving pending events during hijacking might not always be the right thing to do. In the case of `ResumeSynchronous()`, I think we want to make sure the stop event we wait for happens *after* hijacking and resuming. One idea: we could add a `bool move_pending_events` flag to `HijackProcessEvents()` and `RestoreProcessEvents()`. It would default to `false`, and we could set it to `true` in `StopForDestroyOrDetach()`. This way, only the behavior of `StopForDestroyOrDetach()` is modified for now. I gave this a quick try, and now the `check-lldb-api` suite passes on my machine. Does that approach sound reasonable to you? https://github.com/llvm/llvm-project/pull/144919 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [windows][lldb] implement system logging on Windows (PR #150213)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/150213 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a14659a - [lldb] deactivate some tests on older SDKs (#147768)
Author: Charles Zablit Date: 2025-07-30T18:01:04+01:00 New Revision: a14659a2c8c82804b611925fa7a48fd26ef1d135 URL: https://github.com/llvm/llvm-project/commit/a14659a2c8c82804b611925fa7a48fd26ef1d135 DIFF: https://github.com/llvm/llvm-project/commit/a14659a2c8c82804b611925fa7a48fd26ef1d135.diff LOG: [lldb] deactivate some tests on older SDKs (#147768) https://github.com/llvm/llvm-project/pull/144913 was reverted because some of the Darwin tests were failing on SDKs prior to `15.0`. Only the x86 bots run on macOS `14.0`. The aarch64 ones run on macOS `15.0`. In this patch, we deactivate the failing Darwin tests on older SDKs (prior to `15.0`). Added: Modified: lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py lldb/test/API/commands/expression/import-std-module/basic/TestImportStdModule.py lldb/test/API/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py lldb/test/API/commands/expression/import-std-module/iterator/TestIteratorFromStdModule.py lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py lldb/test/API/commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContentFromStdModule.py lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py Removed: diff --git a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py index 1b21fe374ce5f..a488276c2e54d 100644 --- a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py @@ -10,6 +10,7 @@ class TestCase(TestBase): @add_test_categories(["libc++"]) @skipIf(compiler=no_match("clang")) +@skipIf(macos_version=["<", "15.0"]) @skipUnlessDarwin def test(self): self.build() diff --git a/lldb/test/API/commands/expression/import-std-module/basic/TestImportStdModule.py b/lldb/test/API/commands/expression/import-std-module/basic/TestImportStdModule.py index 0632328e6f4c4..0c242d5c8845d 100644 --- a/lldb/test/API/commands/expression/import-std-module/basic/TestImportStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/basic/TestImportStdModule.py @@ -10,6 +10,7 @@ class ImportStdModule(TestBase): @add_test_categories(["libc++"]) @skipIf(compiler=no_match("clang")) +@skipIf(macos_version=["<", "15.0"]) def test(self): self.build() @@ -38,6 +39,7 @@ def test(self): @add_test_categories(["libc++"]) @skipIf(compiler=no_match("clang")) +@skipIf(macos_version=["<", "15.0"]) def test_non_cpp_language(self): self.build() diff --git a/lldb/test/API/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py b/lldb/test/API/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py index 95953de02866a..b3241aab72ab3 100644 --- a/lldb/test/API/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py +++ b/lldb/test/API/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py @@ -15,6 +15,7 @@ class TestImportStdModuleConflicts(TestBase): @add_test_categories(["libc++"]) @skipIf(compiler=no_match("clang")) +@skipIf(macos_version=["<", "15.0"]) def test(self): self.build() diff --git a/lldb/test/API/commands/expressi
[Lldb-commits] [lldb] [lldb] deactivate some tests on older SDKs (PR #147768)
https://github.com/charles-zablit closed https://github.com/llvm/llvm-project/pull/147768 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] NFC: Clean up construction of IntrusiveRefCntPtr from raw pointers for llvm::vfs::FileSystem. (PR #151407)
https://github.com/JDevlieghere approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/151407 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support Darwin cross compilation for remote Linux test suite runs (PR #151403)
https://github.com/jasonmolenda edited https://github.com/llvm/llvm-project/pull/151403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support Darwin cross compilation for remote Linux test suite runs (PR #151403)
@@ -355,6 +355,16 @@ ifeq "$(OS)" "Windows_NT" endif endif +#-- +# Darwin cross compilation +#-- +ifeq "$(HOST_OS)" "Darwin" +ifneq "$(HOST_OS)" "$(OS)" +LDFLAGS += -fuse-ld=lld jasonmolenda wrote: I think the failure mode is that you try to run tests (on a mac, targeting a non-mac), we will try to link the test binaries with lld, which will fail immediately. Someone who doesn't know would (I think) say "Oh, I guess I need lld to build binaries for this remote target" when every test fails the same way. Is this going to work if I run the lldb testsuite on a macOS system but running the tests on iOS or other Darwin type OS. Looking through existing OS comparisons in Makefile.rules, it seems like it can be Darwin/Android/Windows_NT/FreeBSD/NetBSD (plus I'm sure Linux). So probably it calls an iOS device Darwin too. https://github.com/llvm/llvm-project/pull/151403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support Darwin cross compilation for remote Linux test suite runs (PR #151403)
https://github.com/jasonmolenda approved this pull request. lgtm. https://github.com/llvm/llvm-project/pull/151403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] support moduleId in the stackTrace response (PR #149774)
https://github.com/da-viper approved this pull request. LGTM modulo the case. https://github.com/llvm/llvm-project/pull/149774 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] support moduleId in the stackTrace response (PR #149774)
https://github.com/da-viper edited https://github.com/llvm/llvm-project/pull/149774 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support Darwin cross compilation for remote Linux test suite runs (PR #151403)
@@ -355,6 +355,16 @@ ifeq "$(OS)" "Windows_NT" endif endif +#-- +# Darwin cross compilation +#-- +ifeq "$(HOST_OS)" "Darwin" +ifneq "$(HOST_OS)" "$(OS)" +LDFLAGS += -fuse-ld=lld JDevlieghere wrote: Yeah good point, I was trying to be generic but we shouldn't use lld when targeting a remote Darwin device. https://github.com/llvm/llvm-project/pull/151403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f623702 - [lldb] Implement RegisterContextWasm (#151056)
Author: Jonas Devlieghere Date: 2025-07-30T19:51:09-07:00 New Revision: f62370290a66f8d3a47a4b25c3896983424f97bd URL: https://github.com/llvm/llvm-project/commit/f62370290a66f8d3a47a4b25c3896983424f97bd DIFF: https://github.com/llvm/llvm-project/commit/f62370290a66f8d3a47a4b25c3896983424f97bd.diff LOG: [lldb] Implement RegisterContextWasm (#151056) This PR implements a register context for Wasm, which uses virtual registers to resolve Wasm local, globals and stack values. The registers are used to implement support for `DW_OP_WASM_location` in the DWARF expression evaluator (#151010). This also adds a more comprehensive test, showing that we can use this to show local variables. Added: lldb/source/Plugins/Process/wasm/RegisterContextWasm.cpp lldb/source/Plugins/Process/wasm/RegisterContextWasm.h lldb/test/API/functionalities/gdb_remote_client/simple.c lldb/test/API/functionalities/gdb_remote_client/simple.yaml Modified: lldb/docs/resources/lldbgdbremote.md lldb/source/Plugins/Process/wasm/CMakeLists.txt lldb/source/Plugins/Process/wasm/ProcessWasm.cpp lldb/source/Plugins/Process/wasm/ProcessWasm.h lldb/source/Plugins/Process/wasm/ThreadWasm.cpp lldb/source/Plugins/Process/wasm/ThreadWasm.h lldb/test/API/functionalities/gdb_remote_client/TestWasm.py Removed: diff --git a/lldb/docs/resources/lldbgdbremote.md b/lldb/docs/resources/lldbgdbremote.md index 41628cffcc566..36b95f1073ebc 100644 --- a/lldb/docs/resources/lldbgdbremote.md +++ b/lldb/docs/resources/lldbgdbremote.md @@ -1998,22 +1998,6 @@ threads (live system debug) / cores (JTAG) in your program have stopped and allows LLDB to display and control your program correctly. -## qWasmCallStack - -Get the Wasm call stack for the given thread id. This returns a hex-encoded -list of PC values, one for each frame of the call stack. To match the Wasm -specification, the addresses are encoded in little endian byte order, even if -the endian of the Wasm runtime's host is not little endian. - -``` -send packet: $qWasmCallStack:202dbe040#08 -read packet: $9c010040e5010040fe010040# -``` - -**Priority to Implement:** Only required for Wasm support. This packed is -supported by the [WAMR](https://github.com/bytecodealliance/wasm-micro-runtime) -and [V8](https://v8.dev) Wasm runtimes. - ## qWatchpointSupportInfo Get the number of hardware watchpoints available on the remote target. @@ -2479,3 +2463,70 @@ omitting them will work fine; these numbers are always base 16. The length of the payload is not provided. A reliable, 8-bit clean, transport layer is assumed. + +## Wasm Packets + +The packet below are supported by the +[WAMR](https://github.com/bytecodealliance/wasm-micro-runtime) and +[V8](https://v8.dev) Wasm runtimes. + + +### qWasmCallStack + +Get the Wasm call stack for the given thread id. This returns a hex-encoded +list of PC values, one for each frame of the call stack. To match the Wasm +specification, the addresses are encoded in little endian byte order, even if +the endian of the Wasm runtime's host is not little endian. + +``` +send packet: $qWasmCallStack:202dbe040#08 +read packet: $9c010040e5010040fe010040# +``` + +**Priority to Implement:** Only required for Wasm support. Necessary to show +stack traces. + +### qWasmGlobal + +Get the value of a Wasm global variable for the given frame index at the given +variable index. The indexes are encoded as base 10. The result is a hex-encoded +address from where to read the value. + +``` +send packet: $qWasmGlobal:0;2#cb +read packet: $e0030100#b9 +``` + +**Priority to Implement:** Only required for Wasm support. Necessary to show +variables. + + +### qWasmLocal + +Get the value of a Wasm function argument or local variable for the given frame +index at the given variable index. The indexes are encoded as base 10. The +result is a hex-encoded address from where to read the value. + + +``` +send packet: $qWasmLocal:0;2#cb +read packet: $e0030100#b9 +``` + +**Priority to Implement:** Only required for Wasm support. Necessary to show +variables. + + +### qWasmStackValue + +Get the value of a Wasm local variable from the Wasm operand stack, for the +given frame index at the given variable index. The indexes are encoded as base +10. The result is a hex-encoded address from where to read value. + +``` +send packet: $qWasmStackValue:0;2#cb +read packet: $e0030100#b9 +``` + +**Priority to Implement:** Only required for Wasm support. Necessary to show +variables. diff --git a/lldb/source/Plugins/Process/wasm/CMakeLists.txt b/lldb/source/Plugins/Process/wasm/CMakeLists.txt index ff8a3c792ad53..779b97ec90d08 100644 --- a/lldb/source/Plugins/Process/wasm/CMakeLists.txt +++ b/lldb/source/Plugins/Process/wasm/CMakeLists.txt @@ -1,5 +1,6 @@ add_lldb_library(lldbPluginProcessWasm PLUGIN ProcessWasm.cpp + Register
[Lldb-commits] [lldb] [lldb] Implement RegisterContextWasm (PR #151056)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/151056 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement DW_CFA_val_offset and DW_CFA_val_offset_sf (PR #150732)
https://github.com/dsandersllvm updated https://github.com/llvm/llvm-project/pull/150732 >From bd27929645928939f319dc915da1a4636e4d317d Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Wed, 28 Aug 2024 19:02:21 -0700 Subject: [PATCH 1/6] [lldb] Implement DW_CFA_val_offset and DW_CFA_val_offset_sf The test for this is artificial as I'm not aware of any upstream targets that use DW_CFA_val_offset RegisterContextUnwind::ReadFrameAddress now reports how it's attempting to obtain the CFA unless all success/failure cases emit logs that clearly identify the method it was attempting. Previously several of the existing failure paths emit no message or a message that's indistinguishable from those on other paths. --- lldb/include/lldb/Symbol/UnwindPlan.h | 20 +++ lldb/include/lldb/Target/UnwindLLDB.h | 8 ++ lldb/source/Symbol/DWARFCallFrameInfo.cpp | 28 +++- lldb/source/Symbol/UnwindPlan.cpp | 17 +++ lldb/source/Target/RegisterContextUnwind.cpp | 54 +++- .../Symbol/TestDWARFCallFrameInfo.cpp | 124 ++ 6 files changed, 248 insertions(+), 3 deletions(-) diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h b/lldb/include/lldb/Symbol/UnwindPlan.h index fe8081f83c590..9587f1312aa2e 100644 --- a/lldb/include/lldb/Symbol/UnwindPlan.h +++ b/lldb/include/lldb/Symbol/UnwindPlan.h @@ -67,6 +67,7 @@ class UnwindPlan { atAFAPlusOffset, // reg = deref(AFA + offset) isAFAPlusOffset, // reg = AFA + offset inOtherRegister, // reg = other reg +isOtherRegisterPlusOffset, // reg = other reg + offset atDWARFExpression, // reg = deref(eval(dwarf_expr)) isDWARFExpression, // reg = eval(dwarf_expr) isConstant // reg = constant @@ -102,6 +103,10 @@ class UnwindPlan { bool IsInOtherRegister() const { return m_type == inOtherRegister; } + bool IsOtherRegisterPlusOffset() const { +return m_type == isOtherRegisterPlusOffset; + } + bool IsAtDWARFExpression() const { return m_type == atDWARFExpression; } bool IsDWARFExpression() const { return m_type == isDWARFExpression; } @@ -140,9 +145,17 @@ class UnwindPlan { m_location.reg_num = reg_num; } + void SetIsRegisterPlusOffset(uint32_t reg_num, int32_t offset = 0) { +m_type = isOtherRegisterPlusOffset; +m_location.reg_plus_offset.reg_num = reg_num; +m_location.reg_plus_offset.offset = offset; + } + uint32_t GetRegisterNumber() const { if (m_type == inOtherRegister) return m_location.reg_num; +if (m_type == isOtherRegisterPlusOffset) + return m_location.reg_plus_offset.reg_num; return LLDB_INVALID_REGNUM; } @@ -156,6 +169,8 @@ class UnwindPlan { case atAFAPlusOffset: case isAFAPlusOffset: return m_location.offset; +case inOtherRegister: + return m_location.reg_plus_offset.offset; default: return 0; } @@ -204,6 +219,11 @@ class UnwindPlan { } expr; // For m_type == isConstant uint64_t constant_value; +// For m_type == inOtherRegisterPlusOffset +struct { + uint32_t reg_num; + int32_t offset; +} reg_plus_offset; } m_location; }; diff --git a/lldb/include/lldb/Target/UnwindLLDB.h b/lldb/include/lldb/Target/UnwindLLDB.h index f2f65e67a7640..88180b37fd93a 100644 --- a/lldb/include/lldb/Target/UnwindLLDB.h +++ b/lldb/include/lldb/Target/UnwindLLDB.h @@ -49,6 +49,9 @@ class UnwindLLDB : public lldb_private::Unwind { // target mem (target_memory_location) eRegisterInRegister, // register is available in a (possible other) // register (register_number) + eRegisterIsRegisterPlusOffset, // register is available in a (possible + // other) register (register_number) with + // an offset applied eRegisterSavedAtHostMemoryLocation, // register is saved at a word in // lldb's address space eRegisterValueInferred,// register val was computed (and is in @@ -64,6 +67,11 @@ class UnwindLLDB : public lldb_private::Unwind { void *host_memory_location; uint64_t inferred_value; // eRegisterValueInferred - e.g. stack pointer == // cfa + offset + struct { +uint32_t +register_number; // in eRegisterKindLLDB register numbering system +uint64_t offset; + } reg_plus_offset; } location; }; diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp b/lldb/source/Symbol/DWARFCallFrameInfo.cpp index a2d748adad64a..2f8f9e9182fb2 100644 --- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp +++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp @@ -766,8 +766,32 @@ DWARFCallFrameI
[Lldb-commits] [lldb] [lldb] Fallback to expression eval when Dump of variable fails in dwim-print (PR #151374)
@@ -186,8 +182,11 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, expr); } - dump_val_object(*valobj_sp); - return; + bool failed = errorToBool(dump_val_object(*valobj_sp)); augusto2112 wrote: Looks like this loses the error, should this be preserved somehow? You could log these errors in case the overall operation succeeds and maybe combine the errors with AppendError if the overall operation fails. Not sure what the best way to do this would be, but it would be good to not lose the error if possible. https://github.com/llvm/llvm-project/pull/151374 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 90aed4d - [lldb][test] Fix running TestWithLimitDebugInfo.py on Windows (#150579)
Author: Igor Kudrin Date: 2025-07-30T12:54:58-07:00 New Revision: 90aed4dbdfe7354405db980d2b684bf91f69b4fb URL: https://github.com/llvm/llvm-project/commit/90aed4dbdfe7354405db980d2b684bf91f69b4fb DIFF: https://github.com/llvm/llvm-project/commit/90aed4dbdfe7354405db980d2b684bf91f69b4fb.diff LOG: [lldb][test] Fix running TestWithLimitDebugInfo.py on Windows (#150579) When debug info categories were set for a test method with the `@add_test_categories` decorator, they were all added to its "categories" attribute. If some of these categories were not supported, `LLDBTestResult.startTest()` skipped all variants of the test method. For example, the tests in `TestWithLimitDebugInfo.py` use the categories `dwarf` and `dwo`. However, since `dwo` is not supported on Windows, all the tests in this file were skipped, even though the tests for `dwarf` could be run. Added: Modified: lldb/packages/Python/lldbsuite/test/lldbtest.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 6eb021d7c8cfd..0fc85fcc4d2d6 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1778,16 +1778,15 @@ def no_reason(_): attrvalue, "__no_debug_info_test__", False ): # If any debug info categories were explicitly tagged, assume that list to be -# authoritative. If none were specified, try with all debug -# info formats. +# authoritative. If none were specified, try with all debug info formats. +test_method_categories = set(getattr(attrvalue, "categories", [])) all_dbginfo_categories = set( test_categories.debug_info_categories.keys() ) -categories = ( -set(getattr(attrvalue, "categories", [])) & all_dbginfo_categories -) -if not categories: -categories = [ +dbginfo_categories = test_method_categories & all_dbginfo_categories +other_categories = list(test_method_categories - all_dbginfo_categories) +if not dbginfo_categories: +dbginfo_categories = [ category for category, can_replicate in test_categories.debug_info_categories.items() if can_replicate @@ -1799,9 +1798,8 @@ def no_reason(_): skip_for_debug_info_cat_fn = getattr( attrvalue, "__skip_for_debug_info_cat_fn__", no_reason ) -for cat in categories: +for cat in dbginfo_categories: -@decorators.add_test_categories([cat]) @wraps(attrvalue) def test_method(self, attrvalue=attrvalue): return attrvalue(self) @@ -1809,6 +1807,7 @@ def test_method(self, attrvalue=attrvalue): method_name = attrname + "_" + cat test_method.__name__ = method_name test_method.debug_info = cat +test_method.categories = other_categories + [cat] xfail_reason = xfail_for_debug_info_cat_fn(cat) if xfail_reason: ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix running TestWithLimitDebugInfo.py on Windows (PR #150579)
https://github.com/igorkudrin closed https://github.com/llvm/llvm-project/pull/150579 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] support moduleId in the stackTrace response (PR #149774)
@@ -242,3 +242,36 @@ def test_StackFrameFormat(self): frame = self.get_stackFrames(format={"parameters": False, "module": True})[0] self.assertEqual(frame["name"], "a.out recurse") + +@skipIfWindows +def test_stack_frame_module_id(self): +program = self.getBuildArtifact("a.out") +self.build_and_launch(program) +source = "main.c" +lines = [line_number(source, "recurse end")] +breakpoint_ids = self.set_source_breakpoints(source, lines) +self.assertEqual( +len(breakpoint_ids), len(lines), "expect correct number of breakpoints" +) + +self.continue_to_breakpoints(breakpoint_ids) + +modules = self.dap_server.get_modules() +name_to_id = { +name: info["id"] for name, info in modules.items() if "id" in info +} + +stackFrames = self.get_stackFrames() +for frame in stackFrames: woruyu wrote: Done! https://github.com/llvm/llvm-project/pull/149774 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] support moduleId in the stackTrace response (PR #149774)
https://github.com/woruyu updated https://github.com/llvm/llvm-project/pull/149774 >From 33c94346ac2b96d9f68fd1b8d62aebfa7b273499 Mon Sep 17 00:00:00 2001 From: woruyu <1214539...@qq.com> Date: Mon, 21 Jul 2025 15:52:50 +0800 Subject: [PATCH 1/6] [lldb-dap] support moduleId in the stackTrace response --- lldb/tools/lldb-dap/JSONUtils.cpp | 9 + 1 file changed, 9 insertions(+) diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index 41ca29a405ac9..7abd9618cc71f 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -550,6 +550,15 @@ llvm::json::Value CreateStackFrame(DAP &dap, lldb::SBFrame &frame, if (frame.IsArtificial() || frame.IsHidden()) object.try_emplace("presentationHint", "subtle"); + lldb::SBModule module = frame.GetModule(); + if (module.IsValid()) { +std::string uuid = module.GetUUIDString(); +if (!uuid.empty()) + object.try_emplace("moduleId", uuid); +else + object.try_emplace("moduleId", module.GetFileSpec().GetFilename()); + } + return llvm::json::Value(std::move(object)); } >From 3c47de26e1e680e7d14727b6068da99963c21b2e Mon Sep 17 00:00:00 2001 From: woruyu <1214539...@qq.com> Date: Mon, 21 Jul 2025 17:09:08 +0800 Subject: [PATCH 2/6] fix: ci test for moduleId --- lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py index db43dbaf515cf..2743fca58e81d 100644 --- a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py +++ b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py @@ -26,6 +26,7 @@ def test_core_file(self): "column": 0, "id": 524288, "line": 4, +"moduleId":"01DF54A6-045E-657D-3F8F-FB9CE1118789-14F8BD6D", "name": "bar", "source": {"name": "main.c", "path": "/home/labath/test/main.c"}, "instructionPointerReference": "0x40011C", @@ -34,6 +35,7 @@ def test_core_file(self): "column": 0, "id": 524289, "line": 10, +"moduleId":"01DF54A6-045E-657D-3F8F-FB9CE1118789-14F8BD6D", "name": "foo", "source": {"name": "main.c", "path": "/home/labath/test/main.c"}, "instructionPointerReference": "0x400142", @@ -42,6 +44,7 @@ def test_core_file(self): "column": 0, "id": 524290, "line": 16, +"moduleId":"01DF54A6-045E-657D-3F8F-FB9CE1118789-14F8BD6D", "name": "_start", "source": {"name": "main.c", "path": "/home/labath/test/main.c"}, "instructionPointerReference": "0x40015F", >From 5359fd9fe54326f9820cc0c1a0b23f1b7e06fc93 Mon Sep 17 00:00:00 2001 From: woruyu <1214539...@qq.com> Date: Mon, 21 Jul 2025 17:21:39 +0800 Subject: [PATCH 3/6] fix: python format --- lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py index 2743fca58e81d..1143cd93a70b3 100644 --- a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py +++ b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py @@ -26,7 +26,7 @@ def test_core_file(self): "column": 0, "id": 524288, "line": 4, -"moduleId":"01DF54A6-045E-657D-3F8F-FB9CE1118789-14F8BD6D", +"moduleId": "01DF54A6-045E-657D-3F8F-FB9CE1118789-14F8BD6D", "name": "bar", "source": {"name": "main.c", "path": "/home/labath/test/main.c"}, "instructionPointerReference": "0x40011C", @@ -35,7 +35,7 @@ def test_core_file(self): "column": 0, "id": 524289, "line": 10, -"moduleId":"01DF54A6-045E-657D-3F8F-FB9CE1118789-14F8BD6D", +"moduleId": "01DF54A6-045E-657D-3F8F-FB9CE1118789-14F8BD6D", "name": "foo", "source": {"name": "main.c", "path": "/home/labath/test/main.c"}, "instructionPointerReference": "0x400142", @@ -44,7 +44,7 @@ def test_core_file(self): "column": 0, "id": 524290, "line": 16, -"moduleId":"01DF54A6-045E-657D-3F8F-FB9CE1118789-14F8BD6D", +"moduleId": "01DF54A6-045E-657D-3F8F-FB9CE1118789-14F8BD6D", "name": "_start", "source": {"name": "main.c", "path": "/home/labath/test/main.c"}, "instructionPointerReference": "0x40015F", >From 9dca8b225fa76678a8cc604c537a97e58a9fad95 Mon Sep 17 00:00:00 2001 From: woruyu <1214539...@qq
[Lldb-commits] [lldb] [lldb] Fallback to expression eval when Dump of variable fails in dwim-print (PR #151374)
@@ -182,11 +184,13 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, expr); } - bool failed = errorToBool(dump_val_object(*valobj_sp)); - if (!failed) + Error err = dump_val_object(*valobj_sp); + if (!err) return; // Dump failed, continue on to expression evaluation. + LLDB_LOG_ERROR(GetLog(LLDBLog::Expressions), std::move(err), augusto2112 wrote: I'm confused about the order of the arguments to this macro. The error comes first, then the format string, then the other parameter? https://github.com/llvm/llvm-project/pull/151374 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fallback to expression eval when Dump of variable fails in dwim-print (PR #151374)
https://github.com/augusto2112 approved this pull request. https://github.com/llvm/llvm-project/pull/151374 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fallback to expression eval when Dump of variable fails in dwim-print (PR #151374)
@@ -186,8 +182,11 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, expr); } - dump_val_object(*valobj_sp); - return; + bool failed = errorToBool(dump_val_object(*valobj_sp)); augusto2112 wrote: I'm happy with just a log of the previous errors https://github.com/llvm/llvm-project/pull/151374 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Don't use NamedTemporaryFile to test compiler support (PR #151387)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/151387 >From 97435049d503045f22e169825244c944f31968c7 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 30 Jul 2025 13:19:50 -0700 Subject: [PATCH] [lldb] Don't use NamedTemporaryFile to test compiler support You cannot use a NamedTempFile with an external process because it may not be flushed to disk. The safest and most portable approach is to close the file, call the other process and then unlink the file manually. Presumably this works fine on Linux, but it fails on Darwin when targeting remote-linux. See https://bugs.python.org/issue29573 --- .../Python/lldbsuite/support/temp_file.py | 26 .../Python/lldbsuite/test/decorators.py | 121 +- lldb/packages/Python/lldbsuite/test/dotest.py | 9 +- 3 files changed, 91 insertions(+), 65 deletions(-) create mode 100644 lldb/packages/Python/lldbsuite/support/temp_file.py diff --git a/lldb/packages/Python/lldbsuite/support/temp_file.py b/lldb/packages/Python/lldbsuite/support/temp_file.py new file mode 100644 index 0..3ea0683ec87d0 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/support/temp_file.py @@ -0,0 +1,26 @@ +""" +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 + +Prepares language bindings for LLDB build process. Run with --help +to see a description of the supported command line arguments. +""" + +import os +import tempfile + + +class OnDiskTempFile: +def __init__(self, delete=True): +self.path = None + +def __enter__(self): +fd, path = tempfile.mkstemp() +os.close(fd) +self.path = path +return self + +def __exit__(self, exc_type, exc_val, exc_tb): +if os.path.exists(self.path): +os.remove(self.path) diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index a5f58373ede75..acf9ea1a1f85f 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -20,6 +20,7 @@ from . import test_categories from . import lldbtest_config from lldbsuite.support import funcutils +from lldbsuite.support import temp_file from lldbsuite.test import lldbplatform from lldbsuite.test import lldbplatformutil @@ -94,22 +95,23 @@ def _match_decorator_property(expected, actual): def _compiler_supports( -compiler, flag, source="int main() {}", output_file=tempfile.NamedTemporaryFile() +compiler, flag, source="int main() {}", output_file=temp_file.OnDiskTempFile() ): """Test whether the compiler supports the given flag.""" -if platform.system() == "Darwin": -compiler = "xcrun " + compiler -try: -cmd = "echo '%s' | %s %s -x c -o %s -" % ( -source, -compiler, -flag, -output_file.name, -) -subprocess.check_call(cmd, shell=True) -except subprocess.CalledProcessError: -return False -return True +with output_file: +if platform.system() == "Darwin": +compiler = "xcrun " + compiler +try: +cmd = "echo '%s' | %s %s -x c -o %s -" % ( +source, +compiler, +flag, +output_file.path, +) +subprocess.check_call(cmd, shell=True) +except subprocess.CalledProcessError: +return False +return True def expectedFailureIf(condition, bugnumber=None): @@ -876,8 +878,8 @@ def skipUnlessSupportedTypeAttribute(attr): def compiler_doesnt_support_struct_attribute(): compiler_path = lldbplatformutil.getCompiler() -f = tempfile.NamedTemporaryFile() -cmd = [lldbplatformutil.getCompiler(), "-x", "c++", "-c", "-o", f.name, "-"] +f = temp_file.OnDiskTempFile() +cmd = [lldbplatformutil.getCompiler(), "-x", "c++", "-c", "-o", f.path, "-"] p = subprocess.Popen( cmd, stdin=subprocess.PIPE, @@ -902,21 +904,21 @@ def is_compiler_clang_with_call_site_info(): if not compiler.startswith("clang"): return "Test requires clang as compiler" -f = tempfile.NamedTemporaryFile() -cmd = ( -"echo 'int main() {}' | " -"%s -g -glldb -O1 -S -emit-llvm -x c -o %s -" % (compiler_path, f.name) -) -if os.popen(cmd).close() is not None: -return "Compiler can't compile with call site info enabled" +with temp_file.OnDiskTempFile() as f: +cmd = ( +"echo 'int main() {}' | " +"%s -g -glldb -O1 -S -emit-llvm -x c -o %s -" % (compiler_path, f.path) +) +if os.popen(cmd).close() is not None: +return "Compiler can'
[Lldb-commits] [lldb] [lldb] Don't use NamedTemporaryFile to test compiler support (PR #151387)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/151387 >From a0fc19ed15fac0694309d0b1c8246c3d9cc3aeba Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 30 Jul 2025 13:19:50 -0700 Subject: [PATCH] [lldb] Don't use NamedTemporaryFile to test compiler support You cannot use a NamedTempFile with an external process because it may not be flushed to disk. The safest and most portable approach is to close the file, call the other process and then unlink the file manually. Presumably this works fine on Linux, but it fails on Darwin when targeting remote-linux. See https://bugs.python.org/issue29573 --- .../Python/lldbsuite/support/temp_file.py | 26 .../Python/lldbsuite/test/decorators.py | 143 +- lldb/packages/Python/lldbsuite/test/dotest.py | 9 +- 3 files changed, 102 insertions(+), 76 deletions(-) create mode 100644 lldb/packages/Python/lldbsuite/support/temp_file.py diff --git a/lldb/packages/Python/lldbsuite/support/temp_file.py b/lldb/packages/Python/lldbsuite/support/temp_file.py new file mode 100644 index 0..3ea0683ec87d0 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/support/temp_file.py @@ -0,0 +1,26 @@ +""" +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 + +Prepares language bindings for LLDB build process. Run with --help +to see a description of the supported command line arguments. +""" + +import os +import tempfile + + +class OnDiskTempFile: +def __init__(self, delete=True): +self.path = None + +def __enter__(self): +fd, path = tempfile.mkstemp() +os.close(fd) +self.path = path +return self + +def __exit__(self, exc_type, exc_val, exc_tb): +if os.path.exists(self.path): +os.remove(self.path) diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index a5f58373ede75..bd10bcc3d6ce0 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -20,6 +20,7 @@ from . import test_categories from . import lldbtest_config from lldbsuite.support import funcutils +from lldbsuite.support import temp_file from lldbsuite.test import lldbplatform from lldbsuite.test import lldbplatformutil @@ -94,22 +95,23 @@ def _match_decorator_property(expected, actual): def _compiler_supports( -compiler, flag, source="int main() {}", output_file=tempfile.NamedTemporaryFile() +compiler, flag, source="int main() {}", output_file=temp_file.OnDiskTempFile() ): """Test whether the compiler supports the given flag.""" -if platform.system() == "Darwin": -compiler = "xcrun " + compiler -try: -cmd = "echo '%s' | %s %s -x c -o %s -" % ( -source, -compiler, -flag, -output_file.name, -) -subprocess.check_call(cmd, shell=True) -except subprocess.CalledProcessError: -return False -return True +with output_file: +if platform.system() == "Darwin": +compiler = "xcrun " + compiler +try: +cmd = "echo '%s' | %s %s -x c -o %s -" % ( +source, +compiler, +flag, +output_file.path, +) +subprocess.check_call(cmd, shell=True) +except subprocess.CalledProcessError: +return False +return True def expectedFailureIf(condition, bugnumber=None): @@ -876,19 +878,19 @@ def skipUnlessSupportedTypeAttribute(attr): def compiler_doesnt_support_struct_attribute(): compiler_path = lldbplatformutil.getCompiler() -f = tempfile.NamedTemporaryFile() -cmd = [lldbplatformutil.getCompiler(), "-x", "c++", "-c", "-o", f.name, "-"] -p = subprocess.Popen( -cmd, -stdin=subprocess.PIPE, -stdout=subprocess.PIPE, -stderr=subprocess.PIPE, -universal_newlines=True, -) -stdout, stderr = p.communicate("struct __attribute__((%s)) Test {};" % attr) -if attr in stderr: -return "Compiler does not support attribute %s" % (attr) -return None +with temp_file.OnDiskTempFile() as f: +cmd = [lldbplatformutil.getCompiler(), "-x", "c++", "-c", "-o", f.path, "-"] +p = subprocess.Popen( +cmd, +stdin=subprocess.PIPE, +stdout=subprocess.PIPE, +stderr=subprocess.PIPE, +universal_newlines=True, +) +stdout, stderr = p.communicate("struct __attribute__((%s)) Test {};" % attr) +if attr in stderr: +return "Compiler does not support attribute %s" % (attr) +r
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Make AsmLabel parameter a std::string (PR #151355)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/151355 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Make AsmLabel parameter a llvm::StringRef (PR #151355)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/151355 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [windows][lldb] implement system logging on Windows (PR #150213)
https://github.com/Michael137 approved this pull request. https://github.com/llvm/llvm-project/pull/150213 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] cade1e2 - [lldb][rpc] Only use guard names in framework script (#151391)
Author: Chelsea Cassanova Date: 2025-07-30T23:04:22-07:00 New Revision: cade1e29b2c9ab0d0ff4931231b6958ad04d1ebc URL: https://github.com/llvm/llvm-project/commit/cade1e29b2c9ab0d0ff4931231b6958ad04d1ebc DIFF: https://github.com/llvm/llvm-project/commit/cade1e29b2c9ab0d0ff4931231b6958ad04d1ebc.diff LOG: [lldb][rpc] Only use guard names in framework script (#151391) Removes the U that comes before the guards passed into the framework fixup script. Added: Modified: lldb/scripts/framework-header-fix.py lldb/test/Shell/Scripts/TestFrameworkFixScript.test lldb/test/Shell/Scripts/TestFrameworkFixUnifdef.test lldb/test/Shell/Scripts/TestRPCFrameworkFixScript.test lldb/tools/lldb-rpc/LLDBRPCHeaders.cmake Removed: diff --git a/lldb/scripts/framework-header-fix.py b/lldb/scripts/framework-header-fix.py index aa034db36968d..36c5c67c59d36 100755 --- a/lldb/scripts/framework-header-fix.py +++ b/lldb/scripts/framework-header-fix.py @@ -112,7 +112,7 @@ def main(): # but passing them in with dashes for this script causes argparse to think that they're # arguments in and of themself, so they need to passed in without dashes. if args.unifdef_guards: -unifdef_guards = ["-" + guard for guard in args.unifdef_guards] +unifdef_guards = ["-U" + guard for guard in args.unifdef_guards] # Create the framework's header dir if it doesn't already exist if not os.path.exists(os.path.dirname(output_file_path)): diff --git a/lldb/test/Shell/Scripts/TestFrameworkFixScript.test b/lldb/test/Shell/Scripts/TestFrameworkFixScript.test index 2b1818ef8d6c6..183ea3a80fe57 100644 --- a/lldb/test/Shell/Scripts/TestFrameworkFixScript.test +++ b/lldb/test/Shell/Scripts/TestFrameworkFixScript.test @@ -1,6 +1,6 @@ # Create a temp dir for output and run the framework fix script on the truncated version of SBAddress.h in the inputs dir. RUN: mkdir -p %t/Outputs -RUN: %python %p/../../../scripts/framework-header-fix.py -f lldb_main -i %p/Inputs/Main/SBAddress.h -o %t/Outputs/SBAddress.h -p /usr/bin/unifdef --unifdef_guards USWIG +RUN: %python %p/../../../scripts/framework-header-fix.py -f lldb_main -i %p/Inputs/Main/SBAddress.h -o %t/Outputs/SBAddress.h -p /usr/bin/unifdef --unifdef_guards SWIG # Check the output RUN: cat %t/Outputs/SBAddress.h | FileCheck %s diff --git a/lldb/test/Shell/Scripts/TestFrameworkFixUnifdef.test b/lldb/test/Shell/Scripts/TestFrameworkFixUnifdef.test index ba18b4b41d3a0..a4fffe4ed79a3 100644 --- a/lldb/test/Shell/Scripts/TestFrameworkFixUnifdef.test +++ b/lldb/test/Shell/Scripts/TestFrameworkFixUnifdef.test @@ -1,7 +1,7 @@ # REQUIRES: system-darwin # Create a temp dir for output and run the framework fix script on the truncated version of SBAddress.h in the inputs dir. RUN: mkdir -p %t/Outputs -RUN: %python %p/../../../scripts/framework-header-fix.py -f lldb_main -i %p/Inputs/Main/SBAddress.h -o %t/Outputs/SBAddress.h -p /usr/bin/unifdef --unifdef_guards USWIG +RUN: %python %p/../../../scripts/framework-header-fix.py -f lldb_main -i %p/Inputs/Main/SBAddress.h -o %t/Outputs/SBAddress.h -p /usr/bin/unifdef --unifdef_guards SWIG # Check the output RUN: cat %t/Outputs/SBAddress.h | FileCheck %s diff --git a/lldb/test/Shell/Scripts/TestRPCFrameworkFixScript.test b/lldb/test/Shell/Scripts/TestRPCFrameworkFixScript.test index e2080ca01a6fc..d7775c20bc447 100644 --- a/lldb/test/Shell/Scripts/TestRPCFrameworkFixScript.test +++ b/lldb/test/Shell/Scripts/TestRPCFrameworkFixScript.test @@ -1,6 +1,6 @@ # Create a temp dir for output and run the framework fix script on the truncated version of SBAddress.h in the inputs dir. RUN: mkdir -p %t/Outputs -RUN: %python %p/../../../scripts/framework-header-fix.py -f lldb_rpc -i %p/Inputs/RPC/RPCSBAddress.h -o %t/Outputs/RPCSBAddress.h -p /usr/bin/unifdef --unifdef_guards USWIG +RUN: %python %p/../../../scripts/framework-header-fix.py -f lldb_rpc -i %p/Inputs/RPC/RPCSBAddress.h -o %t/Outputs/RPCSBAddress.h -p /usr/bin/unifdef --unifdef_guards SWIG # Check the output RUN: cat %t/Outputs/RPCSBAddress.h | FileCheck %s diff --git a/lldb/tools/lldb-rpc/LLDBRPCHeaders.cmake b/lldb/tools/lldb-rpc/LLDBRPCHeaders.cmake index 6c363f411511a..2376e234cd832 100644 --- a/lldb/tools/lldb-rpc/LLDBRPCHeaders.cmake +++ b/lldb/tools/lldb-rpc/LLDBRPCHeaders.cmake @@ -79,7 +79,7 @@ function(FixIncludePaths in subfolder out) add_custom_command(OUTPUT ${parked_header} COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.py --f lldb_rpc -i ${in} -o ${parked_header} -p ${unifdef_EXECUTABLE} --unifdef_guards USWIG +-f lldb_rpc -i ${in} -o ${parked_header} -p ${unifdef_EXECUTABLE} --unifdef_guards SWIG DEPENDS ${in} COMMENT "Fixing includes in ${in}" ) ___ lldb-commits mailing list lldb-commits@lists.llvm.org h
[Lldb-commits] [lldb] [lldb][rpc] Only use guard names in framework script (PR #151391)
https://github.com/chelcassanova closed https://github.com/llvm/llvm-project/pull/151391 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Make AsmLabel parameter a llvm::StringRef (PR #151355)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/151355 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7410f6d - [lldb][TypeSystemClang] Make AsmLabel parameter a llvm::StringRef (#151355)
Author: Michael Buch Date: 2025-07-31T07:11:30+01:00 New Revision: 7410f6d31de7fded4c0efdc342ab50223d3c7250 URL: https://github.com/llvm/llvm-project/commit/7410f6d31de7fded4c0efdc342ab50223d3c7250 DIFF: https://github.com/llvm/llvm-project/commit/7410f6d31de7fded4c0efdc342ab50223d3c7250.diff LOG: [lldb][TypeSystemClang] Make AsmLabel parameter a llvm::StringRef (#151355) Split out from https://github.com/llvm/llvm-project/pull/148877 This patch prepares `TypeSystemClang` APIs to take `AsmLabel`s which concatenated strings (hence `std::string`) instead of a plain `const char*`. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h lldb/unittests/Symbol/TestTypeSystemClang.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 9f77fbc1d2434..214e260413aa4 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1991,7 +1991,7 @@ void ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context, const bool is_artificial = false; CXXMethodDecl *method_decl = m_clang_ast_context->AddMethodToCXXRecordType( -copied_clang_type.GetOpaqueQualType(), "$__lldb_expr", nullptr, +copied_clang_type.GetOpaqueQualType(), "$__lldb_expr", /*asm_label=*/{}, method_type, lldb::eAccessPublic, is_virtual, is_static, is_inline, is_explicit, is_attr_used, is_artificial); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index ba65f50a44d10..e58e28a260ab0 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -249,6 +249,14 @@ static unsigned GetCXXMethodCVQuals(const DWARFDIE &subprogram, return cv_quals; } +static std::string MakeLLDBFuncAsmLabel(const DWARFDIE &die) { + char const *name = die.GetMangledName(/*substitute_name_allowed*/ false); + if (!name) +return {}; + + return name; +} + TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc, const DWARFDIE &die, Log *log) { @@ -1231,7 +1239,7 @@ std::pair DWARFASTParserClang::ParseCXXMethod( clang::CXXMethodDecl *cxx_method_decl = m_ast.AddMethodToCXXRecordType( class_opaque_type.GetOpaqueQualType(), attrs.name.GetCString(), - attrs.mangled_name, clang_type, accessibility, attrs.is_virtual, + MakeLLDBFuncAsmLabel(die), clang_type, accessibility, attrs.is_virtual, is_static, attrs.is_inline, attrs.is_explicit, is_attr_used, attrs.is_artificial); @@ -1384,7 +1392,7 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, ignore_containing_context ? m_ast.GetTranslationUnitDecl() : containing_decl_ctx, GetOwningClangModule(die), name, clang_type, attrs.storage, -attrs.is_inline); +attrs.is_inline, MakeLLDBFuncAsmLabel(die)); std::free(name_buf); if (has_template_params) { @@ -1394,7 +1402,7 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, ignore_containing_context ? m_ast.GetTranslationUnitDecl() : containing_decl_ctx, GetOwningClangModule(die), attrs.name.GetStringRef(), clang_type, - attrs.storage, attrs.is_inline); + attrs.storage, attrs.is_inline, /*asm_label=*/{}); clang::FunctionTemplateDecl *func_template_decl = m_ast.CreateFunctionTemplateDecl( containing_decl_ctx, GetOwningClangModule(die), @@ -1406,20 +1414,6 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die, lldbassert(function_decl); if (function_decl) { - // Attach an asm() label to the FunctionDecl. - // This ensures that clang::CodeGen emits function calls - // using symbols that are mangled according to the DW_AT_linkage_name. - // If we didn't do this, the external symbols wouldn't exactly - // match the mangled name LLDB knows about and the IRExecutionUnit - // would have to fall back to searching object files for -
[Lldb-commits] [lldb] [lldb] Fix auto advance PC in `EmulateInstructionARM64` if PC >= 4G (PR #151460)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Igor Kudrin (igorkudrin) Changes The `EmulateInstructionARM64::EvaluateInstruction()` method used `uint32_t` to store the PC value, causing addresses greater than 2^32 to be truncated. As for now, the issue does not affect the mainline because the method is never called with both `eEmulateInstructionOptionAutoAdvancePC` and `eEmulateInstructionOptionIgnoreConditions` options set. However, it can trigger on a downstream that uses software stepping. --- Full diff: https://github.com/llvm/llvm-project/pull/151460.diff 2 Files Affected: - (modified) lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp (+2-2) - (modified) lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp (+125-1) ``diff diff --git a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp index 29f03fee47b0d..a8901beda3970 100644 --- a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp +++ b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp @@ -404,7 +404,7 @@ bool EmulateInstructionARM64::EvaluateInstruction(uint32_t evaluate_options) { if (!success && !m_ignore_conditions) return false; - uint32_t orig_pc_value = 0; + uint64_t orig_pc_value = 0; if (auto_advance_pc) { orig_pc_value = ReadRegisterUnsigned(eRegisterKindLLDB, gpr_pc_arm64, 0, &success); @@ -418,7 +418,7 @@ bool EmulateInstructionARM64::EvaluateInstruction(uint32_t evaluate_options) { return false; if (auto_advance_pc) { -uint32_t new_pc_value = +uint64_t new_pc_value = ReadRegisterUnsigned(eRegisterKindLLDB, gpr_pc_arm64, 0, &success); if (!success) return false; diff --git a/lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp b/lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp index 4506c200dee3b..c021d994bb062 100644 --- a/lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp +++ b/lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp @@ -13,15 +13,124 @@ #include "lldb/Core/Disassembler.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/RegisterValue.h" #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h" +#include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h" +#include "Plugins/Process/Utility/lldb-arm64-register-enums.h" using namespace lldb; using namespace lldb_private; struct Arch64EmulatorTester : public EmulateInstructionARM64 { + RegisterInfoPOSIX_arm64::GPR gpr; + uint8_t memory[64] = {0}; + uint64_t memory_offset = 0; + Arch64EmulatorTester() - : EmulateInstructionARM64(ArchSpec("arm64-apple-ios")) {} + : EmulateInstructionARM64(ArchSpec("arm64-apple-ios")) { +memset(&gpr, 0, sizeof(gpr)); +EmulateInstruction::SetCallbacks(ReadMemoryCallback, WriteMemoryCallback, + ReadRegisterCallback, + WriteRegisterCallback); + } + + static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton, + const RegisterInfo *reg_info, + RegisterValue ®_value) { +auto *tester = static_cast(instruction); +uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; +if (reg >= gpr_x1_arm64 && reg <= gpr_x28_arm64) { + reg_value.SetUInt64(tester->gpr.x[reg - gpr_x0_arm64]); + return true; +} +if (reg >= gpr_w1_arm64 && reg <= gpr_w28_arm64) { + reg_value.SetUInt32(tester->gpr.x[reg - gpr_w0_arm64]); + return true; +} +switch (reg) { +case gpr_x0_arm64: + reg_value.SetUInt64(0); + return true; +case gpr_w0_arm64: + reg_value.SetUInt32(0); + return true; +case gpr_fp_arm64: + reg_value.SetUInt64(tester->gpr.fp); + return true; +case gpr_lr_arm64: + reg_value.SetUInt64(tester->gpr.lr); + return true; +case gpr_sp_arm64: + reg_value.SetUInt64(tester->gpr.sp); + return true; +case gpr_pc_arm64: + reg_value.SetUInt64(tester->gpr.pc); + return true; +case gpr_cpsr_arm64: + reg_value.SetUInt64(tester->gpr.cpsr); + return true; +default: + return false; +} + } + + static bool WriteRegisterCallback(EmulateInstruction *instruction, +void *baton, const Context &context, +const RegisterInfo *reg_info, +const RegisterValue ®_value) { +auto *tester = static_cast(instruction); +uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; +if (reg >= gpr_x1_arm64 && reg <= gpr_x28_arm64) { + tester->gpr.x[reg - gpr_x0_arm64] = reg_value.GetAsUInt64(); + return true; +} +if (reg >= gpr_w1_arm64 && reg <= gpr_w28_arm64) { + tester->gpr.x[reg - gpr_w0_arm64] = reg_value.GetAsUInt
[Lldb-commits] [lldb] [lldb] Fix auto advance PC in `EmulateInstructionARM64` if PC >= 4G (PR #151460)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions cpp -- lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp b/lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp index c021d994b..4837bd0e3 100644 --- a/lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp +++ b/lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp @@ -175,7 +175,7 @@ TEST_F(TestAArch64Emulator, TestAutoAdvancePC) { emu.memory_offset = 0x1234567800; emu.gpr.pc = 0x1234567800; emu.gpr.x[8] = 0x1234567820; - memcpy(emu.memory, "\x08\x01\x40\xb9", 4); // ldr w8, [x8] + memcpy(emu.memory, "\x08\x01\x40\xb9", 4);// ldr w8, [x8] memcpy(emu.memory + 0x20, "\x11\x22\x33\x44", 4); // 0x44332211 ASSERT_TRUE(emu.ReadInstruction()); ASSERT_TRUE( `` https://github.com/llvm/llvm-project/pull/151460 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][FreeBSD] Add Auxv numbers for HWCAP3 and HWCAP4 (PR #151152)
https://github.com/omjavaid approved this pull request. Looks good Thanks! https://github.com/llvm/llvm-project/pull/151152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #151010)
@@ -0,0 +1,91 @@ +//===--===// +// +// 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 "SymbolFileWasm.h" +#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" +#include "Utility/WasmVirtualRegisters.h" +#include "lldb/Utility/LLDBLog.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::plugin::dwarf; + +SymbolFileWasm::SymbolFileWasm(ObjectFileSP objfile_sp, + SectionList *dwo_section_list) +: SymbolFileDWARF(objfile_sp, dwo_section_list) {} + +SymbolFileWasm::~SymbolFileWasm() = default; + +lldb::offset_t +SymbolFileWasm::GetVendorDWARFOpcodeSize(const DataExtractor &data, + const lldb::offset_t data_offset, + const uint8_t op) const { + if (op != llvm::dwarf::DW_OP_WASM_location) +return LLDB_INVALID_OFFSET; + + lldb::offset_t offset = data_offset; + const uint8_t wasm_op = data.GetU8(&offset); + if (wasm_op == eWasmTagOperandStack) +data.GetU32(&offset); + else +data.GetULEB128(&offset); Michael137 wrote: Might be misreading https://yurydelendik.github.io/webassembly-dwarf/#DWARF-expressions-and-location-descriptions, but isn't the `U32` encoding for the globals? And only in the `0x3` case? https://github.com/llvm/llvm-project/pull/151010 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #151010)
@@ -0,0 +1,91 @@ +//===--===// +// +// 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 "SymbolFileWasm.h" +#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" +#include "Utility/WasmVirtualRegisters.h" +#include "lldb/Utility/LLDBLog.h" + +using namespace lldb; +using namespace lldb_private; +using namespace lldb_private::plugin::dwarf; + +SymbolFileWasm::SymbolFileWasm(ObjectFileSP objfile_sp, + SectionList *dwo_section_list) +: SymbolFileDWARF(objfile_sp, dwo_section_list) {} + +SymbolFileWasm::~SymbolFileWasm() = default; + +lldb::offset_t +SymbolFileWasm::GetVendorDWARFOpcodeSize(const DataExtractor &data, + const lldb::offset_t data_offset, + const uint8_t op) const { + if (op != llvm::dwarf::DW_OP_WASM_location) +return LLDB_INVALID_OFFSET; + + lldb::offset_t offset = data_offset; + const uint8_t wasm_op = data.GetU8(&offset); + if (wasm_op == eWasmTagOperandStack) +data.GetU32(&offset); + else +data.GetULEB128(&offset); Michael137 wrote: Oh i see why this worked. The `wasm_op` value doesn't map to the `WasmVirtualRegisterKinds` values right? So `wasm_op == eWasmTagOperandStack` really means `wasm_op` is the `0x3` form of the `Global`s tag https://github.com/llvm/llvm-project/pull/151010 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #151010)
https://github.com/Michael137 commented: SGTM Modulo the comment in `GetVendorDWARFOpcodeSize` https://github.com/llvm/llvm-project/pull/151010 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits