[Lldb-commits] [lldb] [lldb] Recognize MTE fault Mach exceptions (PR #159117)
JDevlieghere wrote: > How will this be tested? We can run API tests on iOS, right? I get that only > you at Apple are likely to be able to do that with any convenience, but still. > > Also you'd probably save a bunch of time by doing one giant test that checks > all the little MTE additions in one go, maybe that is in fact your plan. Yeah, that was indeed my plan. Downstream this was implemented before we had hardware so at the time I wrote a test that uses an emulator (which isn't available publicly). Given that, as you said, only we can run the on-device test suite, I figured it wouldn't add much value to add a small test for this change at this time. We have some more changes in the pipeline (including from @yln) that have more comprehensive testing, so we can do one big MTE test once all the pieces land if that's okay with you. https://github.com/llvm/llvm-project/pull/159117 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-mcp] Launch lldb on demand, if needed. (PR #158701)
@@ -35,24 +41,88 @@ using namespace llvm; using namespace lldb; using namespace lldb_protocol::mcp; +using lldb_private::Environment; using lldb_private::File; +using lldb_private::FileSpec; +using lldb_private::FileSystem; +using lldb_private::Host; using lldb_private::MainLoop; using lldb_private::MainLoopBase; using lldb_private::NativeFile; namespace { +constexpr size_t kForwardIOBufferSize = 1024; + inline void exitWithError(llvm::Error Err, StringRef Prefix = "") { handleAllErrors(std::move(Err), [&](ErrorInfoBase &Info) { WithColor::error(errs(), Prefix) << Info.message() << '\n'; }); std::exit(EXIT_FAILURE); } -constexpr size_t kForwardIOBufferSize = 1024; +FileSpec driverPath() { + Environment host_env = Host::GetEnvironment(); + + // Check if an override for which lldb we're using exists, otherwise look next + // to the current binary. + std::string lldb_exe_path = host_env.lookup("LLDB_EXE_PATH"); + auto &fs = FileSystem::Instance(); + if (fs.Exists(lldb_exe_path)) { +return FileSpec(lldb_exe_path); + } + + FileSpec lldb_exec_spec = lldb_private::HostInfo::GetProgramFileSpec(); + lldb_exec_spec.SetFilename("lldb"); ashgti wrote: Added a specific name for Windows. https://github.com/llvm/llvm-project/pull/158701 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Turn LineEntry into a class and make AddressRange member optional (PR #158811)
bulbazord wrote: > Can we break this up into an NFC patch that makes `LineEntry` a class and a > separate PR for the functional change that makes `AddressRange` optional? +1. Why do you want to turn it into a class? In C++, the only difference between a class and a struct is the default access level. Structs are public by default, Classes are private by default. https://github.com/llvm/llvm-project/pull/158811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
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 origin/main HEAD --extensions cpp,h -- lldb/include/lldb/Host/JSONTransport.h lldb/include/lldb/Protocol/MCP/Protocol.h lldb/include/lldb/Protocol/MCP/Server.h lldb/include/lldb/Protocol/MCP/Transport.h lldb/source/Host/common/JSONTransport.cpp lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.h lldb/source/Plugins/Protocol/MCP/Tool.cpp lldb/source/Protocol/MCP/Server.cpp lldb/tools/lldb-dap/DAP.h lldb/tools/lldb-dap/Protocol/ProtocolBase.h lldb/tools/lldb-dap/Transport.h lldb/unittests/DAP/DAPTest.cpp lldb/unittests/DAP/Handler/DisconnectTest.cpp lldb/unittests/DAP/TestBase.cpp lldb/unittests/DAP/TestBase.h lldb/unittests/Host/JSONTransportTest.cpp lldb/unittests/Protocol/ProtocolMCPServerTest.cpp lldb/unittests/TestingSupport/Host/JSONTransportTestUtilities.h `` :warning: The reproduction instructions above might return results for more than one PR in a stack if you are using a stacked PR workflow. You can limit the results by changing `origin/main` to the base branch/commit you want to compare against. :warning: View the diff from clang-format here. ``diff diff --git a/lldb/source/Plugins/Protocol/MCP/Tool.cpp b/lldb/source/Plugins/Protocol/MCP/Tool.cpp index 176bc0c68..cb134b965 100644 --- a/lldb/source/Plugins/Protocol/MCP/Tool.cpp +++ b/lldb/source/Plugins/Protocol/MCP/Tool.cpp @@ -16,7 +16,6 @@ #include "llvm/Support/Error.h" #include #include -#include "llvm/Support/Error.h" using namespace lldb_private; using namespace lldb_protocol; `` https://github.com/llvm/llvm-project/pull/159160 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/159160 >From 5472b257f704288060ce3bad408c958c2a538e0d Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 10 Sep 2025 10:42:56 -0700 Subject: [PATCH] [lldb] Adding A new Binding helper for JSONTransport. This adds a new Binding helper class to allow mapping of incoming and outgoing requests / events to specific handlers. This should make it easier to create new protocol implementations and allow us to create a relay in the lldb-mcp binary. --- lldb/include/lldb/Host/JSONTransport.h| 376 -- lldb/include/lldb/Protocol/MCP/Protocol.h | 8 + lldb/include/lldb/Protocol/MCP/Server.h | 73 ++-- lldb/include/lldb/Protocol/MCP/Transport.h| 77 +++- lldb/source/Host/common/JSONTransport.cpp | 10 + .../Protocol/MCP/ProtocolServerMCP.cpp| 42 +- .../Plugins/Protocol/MCP/ProtocolServerMCP.h | 20 +- lldb/source/Protocol/MCP/Server.cpp | 212 +++--- lldb/tools/lldb-dap/DAP.h | 6 +- lldb/tools/lldb-dap/Protocol/ProtocolBase.h | 6 +- lldb/tools/lldb-dap/Transport.h | 6 +- lldb/unittests/DAP/DAPTest.cpp| 20 +- lldb/unittests/DAP/Handler/DisconnectTest.cpp | 4 +- lldb/unittests/DAP/TestBase.cpp | 42 +- lldb/unittests/DAP/TestBase.h | 122 +++--- lldb/unittests/Host/JSONTransportTest.cpp | 332 .../Protocol/ProtocolMCPServerTest.cpp| 282 +++-- .../Host/JSONTransportTestUtilities.h | 96 - 18 files changed, 1156 insertions(+), 578 deletions(-) diff --git a/lldb/include/lldb/Host/JSONTransport.h b/lldb/include/lldb/Host/JSONTransport.h index 210f33edace6e..080dce96ef3c4 100644 --- a/lldb/include/lldb/Host/JSONTransport.h +++ b/lldb/include/lldb/Host/JSONTransport.h @@ -18,6 +18,7 @@ #include "lldb/Utility/IOObject.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" +#include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" @@ -25,8 +26,11 @@ #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/JSON.h" #include "llvm/Support/raw_ostream.h" +#include +#include #include #include +#include #include #include @@ -50,17 +54,70 @@ class TransportUnhandledContentsError std::string m_unhandled_contents; }; +class InvalidParams : public llvm::ErrorInfo { +public: + static char ID; + + explicit InvalidParams(std::string method, std::string context) + : m_method(std::move(method)), m_context(std::move(context)) {} + + void log(llvm::raw_ostream &OS) const override; + std::error_code convertToErrorCode() const override; + +private: + std::string m_method; + std::string m_context; +}; + +// Value for tracking functions that have a void param or result. +using VoidT = std::monostate; + +template using Callback = llvm::unique_function; + +template +using Reply = typename std::conditional< +std::is_same_v == true, llvm::unique_function, +llvm::unique_function)>>::type; + +template +using OutgoingRequest = typename std::conditional< +std::is_same_v == true, +llvm::unique_function)>, +llvm::unique_function)>>::type; + +template +using OutgoingEvent = typename std::conditional< +std::is_same_v == true, llvm::unique_function, +llvm::unique_function>::type; + +template +Req make_request(Id id, llvm::StringRef method, + std::optional params = std::nullopt); +template +Resp make_response(const Req &req, llvm::Error error); +template +Resp make_response(const Req &req, llvm::json::Value result); +template +Evt make_event(llvm::StringRef method, + std::optional params = std::nullopt); +template +llvm::Expected get_result(const Resp &resp); +template Id get_id(const T &); +template llvm::StringRef get_method(const T &); +template llvm::json::Value get_params(const T &); + /// A transport is responsible for maintaining the connection to a client /// application, and reading/writing structured messages to it. /// /// Transports have limited thread safety requirements: /// - Messages will not be sent concurrently. /// - Messages MAY be sent while Run() is reading, or its callback is active. -template class Transport { +template +class JSONTransport { public: using Message = std::variant; - virtual ~Transport() = default; + virtual ~JSONTransport() = default; /// Sends an event, a message that does not require a response. virtual llvm::Error Send(const Evt &) = 0; @@ -90,8 +147,6 @@ template class Transport { virtual void OnClosed() = 0; }; - using MessageHandlerSP = std::shared_ptr; - /// RegisterMessageHandler registers the Transport with the given MainLoop and /// handles any incoming messages using the given MessageHandler. /// @@ -100,22 +155,293 @@ template class Transport { virtual
[Lldb-commits] [lldb] [lldb] Test global variable support of dwim-print (NFC) (PR #157908)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Dave Lee (kastiglione) Changes DIL has made frame variable support global variables, which in turn means dwim-print inherits support for global variables. --- Full diff: https://github.com/llvm/llvm-project/pull/157908.diff 2 Files Affected: - (modified) lldb/test/API/commands/dwim-print/TestDWIMPrint.py (+9-1) - (modified) lldb/test/API/commands/dwim-print/main.cpp (+3) ``diff diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py index 492d49f008a9e..82ff59f74f41f 100644 --- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py +++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py @@ -16,7 +16,7 @@ def _run_cmd(self, cmd: str) -> str: self.ci.HandleCommand(cmd, result) return result.GetOutput().rstrip() -VAR_IDENT = re.compile(r"(?:\$\d+|[\w.]+) = ") +VAR_IDENT = re.compile(r"(?:\$\d+|(?:::)?[\w.]+) = ") def _strip_result_var(self, string: str) -> str: """ @@ -185,3 +185,11 @@ def test_direct_child_access(self): self, "break inside", lldb.SBFileSpec("main.cpp") ) self._expect_cmd("dwim-print number", "frame variable") + +def test_global_variables(self): +"""Test dwim-print supports global variables.""" +self.build() +lldbutil.run_to_source_breakpoint( +self, "break here", lldb.SBFileSpec("main.cpp") +) +self._expect_cmd("dwim-print gGlobal", "frame variable") diff --git a/lldb/test/API/commands/dwim-print/main.cpp b/lldb/test/API/commands/dwim-print/main.cpp index d1abb5a85dd45..5b7cbd7da764b 100644 --- a/lldb/test/API/commands/dwim-print/main.cpp +++ b/lldb/test/API/commands/dwim-print/main.cpp @@ -1,5 +1,8 @@ extern "C" int puts(const char *s); +extern int gGlobal; +int gGlobal = 23; + struct Structure { int number = 30; void f() { puts("break inside"); } `` https://github.com/llvm/llvm-project/pull/157908 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Make flag-only options work in the ParsedCommand mode of adding commands (PR #157756)
https://github.com/JDevlieghere approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/157756 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Re-enable `TestRerunAndExprDylib.py` (PR #157872)
https://github.com/da-viper closed https://github.com/llvm/llvm-project/pull/157872 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] RISCV unwinding enable (PR #158161)
llvmbot wrote: @llvm/pr-subscribers-backend-risc-v @llvm/pr-subscribers-lldb Author: None (barsolo2000) Changes **Added emulator unwinding support for RISCV files.** Emulated Instructions: ADD (addi sp, sp, imm) STORE (sd ra, offset(sp)) LOAD (ld ra, offset(sp)). We had to overwrite SetInstructions() since UnwindAssemblyInstEmulation calls EvaluateInstruction() directly after calling SetInstruction(), but it never calls ReadInstruction(). This means that the m_decoded member variable in the instruction emulator is never properly initialized. By overriding SetInstruction(), we decode the instruction bytes and set m_decoded directly. This ensures that subsequent emulation (including unwinding) operates on the correct instruction. We also had to change the the OpCode GetOpcodeBytes function since recent changes made it so GetOpcodeBytes will return None for type eType16_32Tuples (an alternative and longer way, would've been to type check during the overwritten SetInstruction() and call a DataExtractor with .GetU16(&offset) to set the inst_data. Added a test - TestSimpleRiscvFunction (took inspiration from: [link](https://github.com/llvm/llvm-project/blob/main/lldb/unittests/UnwindAssembly/ARM64/TestArm64InstEmulation.cpp)) [--] 1 test from TestRiscvInstEmulation [ RUN ] TestRiscvInstEmulation.TestSimpleRiscvFunction [ OK ] TestRiscvInstEmulation.TestSimpleRiscvFunction (1 ms) [--] 1 test from TestRiscvInstEmulation (1 ms total) [--] Global test environment tear-down [==] 63 tests from 5 test suites ran. (11 ms total) [ PASSED ] 63 tests. --- Full diff: https://github.com/llvm/llvm-project/pull/158161.diff 5 Files Affected: - (modified) lldb/include/lldb/Core/Opcode.h (+3-1) - (modified) lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp (+162-12) - (modified) lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h (+4) - (modified) lldb/unittests/Instruction/CMakeLists.txt (+5) - (added) lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp (+188) ``diff diff --git a/lldb/include/lldb/Core/Opcode.h b/lldb/include/lldb/Core/Opcode.h index 7bbd73d039f99..7e756d3f15d22 100644 --- a/lldb/include/lldb/Core/Opcode.h +++ b/lldb/include/lldb/Core/Opcode.h @@ -223,7 +223,9 @@ class Opcode { int Dump(Stream *s, uint32_t min_byte_width) const; const void *GetOpcodeBytes() const { -return ((m_type == Opcode::eTypeBytes) ? m_data.inst.bytes : nullptr); +return ((m_type == Opcode::eTypeBytes || m_type == Opcode::eType16_32Tuples) +? m_data.inst.bytes +: nullptr); } uint32_t GetByteSize() const { diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp index 5e429a92613ce..36e6bd41ad7fa 100644 --- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp +++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp @@ -33,6 +33,10 @@ LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionRISCV, InstructionRISCV) namespace lldb_private { +// RISC-V General Purpose Register numbers +static constexpr uint32_t RISCV_GPR_SP = 2; // x2 is the stack pointer +static constexpr uint32_t RISCV_GPR_FP = 8; // x8 is the frame pointer + /// Returns all values wrapped in Optional, or std::nullopt if any of the values /// is std::nullopt. template @@ -108,6 +112,14 @@ static uint32_t FPREncodingToLLDB(uint32_t reg_encode) { return LLDB_INVALID_REGNUM; } +// Helper function to get register info from GPR encoding +static std::optional +GPREncodingToRegisterInfo(EmulateInstructionRISCV &emulator, + uint32_t reg_encode) { + uint32_t lldb_reg = GPREncodingToLLDB(reg_encode); + return emulator.GetRegisterInfo(eRegisterKindLLDB, lldb_reg); +} + bool Rd::Write(EmulateInstructionRISCV &emulator, uint64_t value) { uint32_t lldb_reg = GPREncodingToLLDB(rd); EmulateInstruction::Context ctx; @@ -230,10 +242,34 @@ Load(EmulateInstructionRISCV &emulator, I inst, uint64_t (*extend)(E)) { auto addr = LoadStoreAddr(emulator, inst); if (!addr) return false; - return transformOptional( - emulator.ReadMem(*addr), - [&](T t) { return inst.rd.Write(emulator, extend(E(t))); }) - .value_or(false); + + // Set up context for the load operation, similar to ARM64 + EmulateInstructionRISCV::Context context; + + // Get register info for base register + std::optional reg_info_rs1 = + GPREncodingToRegisterInfo(emulator, inst.rs1.rs); + + if (!reg_info_rs1) +return false; + + // Set context type based on whether this is a stack-based load + if (inst.rs1.rs == RISCV_GPR_SP) // x2 is the stack pointer in RISC-V +context.type = EmulateInstruction::eContextPopRegisterOffStack; + else +context.type = EmulateInstruction::eContextRegisterLoad; + + // Set the context address information + con
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
https://github.com/ashgti ready_for_review https://github.com/llvm/llvm-project/pull/159160 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: John Harrison (ashgti) Changes This adds a new Binding helper class to allow mapping of incoming and outgoing requests / events to specific handlers. This should make it easier to create new protocol implementations and allow us to create a relay in the lldb-mcp binary. --- Patch is 95.85 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/159160.diff 18 Files Affected: - (modified) lldb/include/lldb/Host/JSONTransport.h (+361-26) - (modified) lldb/include/lldb/Protocol/MCP/Protocol.h (+8) - (modified) lldb/include/lldb/Protocol/MCP/Server.h (+32-41) - (modified) lldb/include/lldb/Protocol/MCP/Transport.h (+75-2) - (modified) lldb/source/Host/common/JSONTransport.cpp (+10) - (modified) lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp (+19-23) - (modified) lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.h (+13-7) - (modified) lldb/source/Protocol/MCP/Server.cpp (+56-155) - (modified) lldb/tools/lldb-dap/DAP.h (+3-3) - (modified) lldb/tools/lldb-dap/Protocol/ProtocolBase.h (+4-2) - (modified) lldb/tools/lldb-dap/Transport.h (+3-3) - (modified) lldb/unittests/DAP/DAPTest.cpp (+3-17) - (modified) lldb/unittests/DAP/Handler/DisconnectTest.cpp (+2-2) - (modified) lldb/unittests/DAP/TestBase.cpp (+21-21) - (modified) lldb/unittests/DAP/TestBase.h (+53-69) - (modified) lldb/unittests/Host/JSONTransportTest.cpp (+259-79) - (modified) lldb/unittests/Protocol/ProtocolMCPServerTest.cpp (+157-123) - (modified) lldb/unittests/TestingSupport/Host/JSONTransportTestUtilities.h (+91-5) ``diff diff --git a/lldb/include/lldb/Host/JSONTransport.h b/lldb/include/lldb/Host/JSONTransport.h index 210f33edace6e..da1ae43118538 100644 --- a/lldb/include/lldb/Host/JSONTransport.h +++ b/lldb/include/lldb/Host/JSONTransport.h @@ -18,6 +18,7 @@ #include "lldb/Utility/IOObject.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" +#include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" @@ -25,8 +26,13 @@ #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/JSON.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include #include #include +#include +#include #include #include @@ -50,17 +56,70 @@ class TransportUnhandledContentsError std::string m_unhandled_contents; }; +class InvalidParams : public llvm::ErrorInfo { +public: + static char ID; + + explicit InvalidParams(std::string method, std::string context) + : m_method(std::move(method)), m_context(std::move(context)) {} + + void log(llvm::raw_ostream &OS) const override; + std::error_code convertToErrorCode() const override; + +private: + std::string m_method; + std::string m_context; +}; + +// Value for tracking functions that have a void param or result. +using VoidT = std::monostate; + +template using Callback = llvm::unique_function; + +template +using Reply = typename std::conditional< +std::is_same_v == true, llvm::unique_function, +llvm::unique_function)>>::type; + +template +using OutgoingRequest = typename std::conditional< +std::is_same_v == true, +llvm::unique_function)>, +llvm::unique_function)>>::type; + +template +using OutgoingEvent = typename std::conditional< +std::is_same_v == true, llvm::unique_function, +llvm::unique_function>::type; + +template +Req make_request(Id id, llvm::StringRef method, + std::optional params = std::nullopt); +template +Resp make_response(const Req &req, llvm::Error error); +template +Resp make_response(const Req &req, llvm::json::Value result); +template +Evt make_event(llvm::StringRef method, + std::optional params = std::nullopt); +template +llvm::Expected get_result(const Resp &resp); +template Id get_id(const T &); +template llvm::StringRef get_method(const T &); +template llvm::json::Value get_params(const T &); + /// A transport is responsible for maintaining the connection to a client /// application, and reading/writing structured messages to it. /// /// Transports have limited thread safety requirements: /// - Messages will not be sent concurrently. /// - Messages MAY be sent while Run() is reading, or its callback is active. -template class Transport { +template +class JSONTransport { public: using Message = std::variant; - virtual ~Transport() = default; + virtual ~JSONTransport() = default; /// Sends an event, a message that does not require a response. virtual llvm::Error Send(const Evt &) = 0; @@ -90,8 +149,6 @@ template class Transport { virtual void OnClosed() = 0; }; - using MessageHandlerSP = std::shared_ptr; - /// RegisterMessageHandler registers the Transport with the given MainLoop and /// handles any incoming messages using the given MessageHandler. /// @@ -100,22 +157,302 @@ template class Transport {
[Lldb-commits] [lldb] RISCV unwinding enable (PR #158161)
https://github.com/barsolo2000 updated https://github.com/llvm/llvm-project/pull/158161 >From ee3cadcf6d29c07529aac18975965da1c3422b3a Mon Sep 17 00:00:00 2001 From: Bar Soloveychik Date: Thu, 11 Sep 2025 14:06:05 -0700 Subject: [PATCH 1/6] RISCV unwinding enable --- lldb/include/lldb/Core/Opcode.h | 4 +- .../RISCV/EmulateInstructionRISCV.cpp | 165 +-- .../RISCV/EmulateInstructionRISCV.h | 4 + lldb/unittests/Instruction/CMakeLists.txt | 5 + .../RISCV/TestRiscvInstEmulation.cpp | 194 ++ 5 files changed, 359 insertions(+), 13 deletions(-) create mode 100644 lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp diff --git a/lldb/include/lldb/Core/Opcode.h b/lldb/include/lldb/Core/Opcode.h index 7bbd73d039f99..7e756d3f15d22 100644 --- a/lldb/include/lldb/Core/Opcode.h +++ b/lldb/include/lldb/Core/Opcode.h @@ -223,7 +223,9 @@ class Opcode { int Dump(Stream *s, uint32_t min_byte_width) const; const void *GetOpcodeBytes() const { -return ((m_type == Opcode::eTypeBytes) ? m_data.inst.bytes : nullptr); +return ((m_type == Opcode::eTypeBytes || m_type == Opcode::eType16_32Tuples) +? m_data.inst.bytes +: nullptr); } uint32_t GetByteSize() const { diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp index 5e429a92613ce..7a56dcaa2f2db 100644 --- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp +++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp @@ -230,10 +230,36 @@ Load(EmulateInstructionRISCV &emulator, I inst, uint64_t (*extend)(E)) { auto addr = LoadStoreAddr(emulator, inst); if (!addr) return false; - return transformOptional( - emulator.ReadMem(*addr), - [&](T t) { return inst.rd.Write(emulator, extend(E(t))); }) - .value_or(false); + + // Set up context for the load operation, similar to ARM64 + EmulateInstructionRISCV::Context context; + + // Get register info for base register + uint32_t rs1_lldb = GPREncodingToLLDB(inst.rs1.rs); + std::optional reg_info_rs1 = + emulator.GetRegisterInfo(eRegisterKindLLDB, rs1_lldb); + + if (!reg_info_rs1) +return false; + + // Set context type based on whether this is a stack-based load + if (inst.rs1.rs == 2) { // x2 is the stack pointer in RISC-V +context.type = EmulateInstruction::eContextPopRegisterOffStack; + } else { +context.type = EmulateInstruction::eContextRegisterLoad; + } + + // Set the context address information + context.SetAddress(*addr); + + // Read from memory with context and write to register + bool success = false; + uint64_t value = + emulator.ReadMemoryUnsigned(context, *addr, sizeof(T), 0, &success); + if (!success) +return false; + + return inst.rd.Write(emulator, extend(E(T(value; } template @@ -242,9 +268,38 @@ Store(EmulateInstructionRISCV &emulator, I inst) { auto addr = LoadStoreAddr(emulator, inst); if (!addr) return false; - return transformOptional( - inst.rs2.Read(emulator), - [&](uint64_t rs2) { return emulator.WriteMem(*addr, rs2); }) + + // Set up context for the store operation, similar to ARM64 + EmulateInstructionRISCV::Context context; + + // Get register info for source and base registers + uint32_t rs1_lldb = GPREncodingToLLDB(inst.rs1.rs); + uint32_t rs2_lldb = GPREncodingToLLDB(inst.rs2.rs); + std::optional reg_info_rs1 = + emulator.GetRegisterInfo(eRegisterKindLLDB, rs1_lldb); + std::optional reg_info_rs2 = + emulator.GetRegisterInfo(eRegisterKindLLDB, rs2_lldb); + + if (!reg_info_rs1 || !reg_info_rs2) +return false; + + // Set context type based on whether this is a stack-based store + if (inst.rs1.rs == 2) { // x2 is the stack pointer in RISC-V +context.type = EmulateInstruction::eContextPushRegisterOnStack; + } else { +context.type = EmulateInstruction::eContextRegisterStore; + } + + // Set the context to show which register is being stored to which base + // register + offset + context.SetRegisterToRegisterPlusOffset(*reg_info_rs2, *reg_info_rs1, + SignExt(inst.imm)); + + return transformOptional(inst.rs2.Read(emulator), + [&](uint64_t rs2) { + return emulator.WriteMemoryUnsigned( + context, *addr, rs2, sizeof(T)); + }) .value_or(false); } @@ -737,11 +792,42 @@ class Executor { bool operator()(SH inst) { return Store(m_emu, inst); } bool operator()(SW inst) { return Store(m_emu, inst); } bool operator()(ADDI inst) { -return transformOptional(inst.rs1.ReadI64(m_emu), - [&](int64_t rs1) { - return inst.rd.Write( - m_em
[Lldb-commits] [lldb] 1819798 - [lldb-dap] Add stdio redirection (#158609)
Author: Druzhkov Sergei Date: 2025-09-16T11:07:24-07:00 New Revision: 181979822743ddaf4c197e1587c0c89b5f4240a4 URL: https://github.com/llvm/llvm-project/commit/181979822743ddaf4c197e1587c0c89b5f4240a4 DIFF: https://github.com/llvm/llvm-project/commit/181979822743ddaf4c197e1587c0c89b5f4240a4.diff LOG: [lldb-dap] Add stdio redirection (#158609) As far as I understand, lldb-dap does not currently support stdio redirection. I have added support for this via a new field in the launch configuration named `stdio`. It was inspired by the same named field in [CodeLLDB](https://github.com/vadimcn/codelldb/blob/master/MANUAL.md#stdio-redirection). Added: Modified: lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py lldb/tools/lldb-dap/Handler/RequestHandler.cpp lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp lldb/tools/lldb-dap/Protocol/ProtocolRequests.h lldb/tools/lldb-dap/README.md lldb/tools/lldb-dap/package.json Removed: diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 9fe8ca22e820b..daa3e76df6d82 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -1039,6 +1039,7 @@ def request_launch( disableSTDIO=False, shellExpandArguments=False, console: Optional[str] = None, +stdio: Optional[list[str]] = None, enableAutoVariableSummaries=False, displayExtendedBacktrace=False, enableSyntheticChildDebugging=False, @@ -1090,6 +1091,8 @@ def request_launch( args_dict["sourceMap"] = sourceMap if console: args_dict["console"] = console +if stdio: +args_dict["stdio"] = stdio if postRunCommands: args_dict["postRunCommands"] = postRunCommands if customFrameFormat: diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index 83392bcd2db73..096ce5e0236a2 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -6,6 +6,7 @@ from lldbsuite.test.lldbtest import * import lldbdap_testcase import os +import pathlib import re import tempfile @@ -625,3 +626,18 @@ def test_no_lldbinit_flag(self): # Verify the initCommands were executed self.verify_commands("initCommands", output, initCommands) + +def test_stdio_redirection(self): +""" +Test stdio redirection. +""" +self.build_and_create_debug_adapter() +program = self.getBuildArtifact("a.out") + +with tempfile.NamedTemporaryFile("rt") as f: +self.launch(program, stdio=[None, f.name, None]) +self.continue_to_exit() +lines = f.readlines() +self.assertIn( +program, lines[0], "make sure program path is in first argument" +) diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp index 4fadf1c22e0e3..773891353db6a 100644 --- a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp @@ -51,6 +51,33 @@ static uint32_t SetLaunchFlag(uint32_t flags, bool flag, return flags; } +static void +SetupIORedirection(const std::vector> &stdio, + lldb::SBLaunchInfo &launch_info) { + size_t n = std::max(stdio.size(), static_cast(3)); + for (size_t i = 0; i < n; i++) { +std::optional path; +if (stdio.size() < i) + path = stdio.back(); +else + path = stdio[i]; +if (!path) + continue; +switch (i) { +case 0: + launch_info.AddOpenFileAction(i, path->c_str(), true, false); + break; +case 1: +case 2: + launch_info.AddOpenFileAction(i, path->c_str(), false, true); + break; +default: + launch_info.AddOpenFileAction(i, path->c_str(), true, true); + break; +} + } +} + static llvm::Error RunInTerminal(DAP &dap, const protocol::LaunchRequestArguments &arguments) { if (!dap.clientFeatures.contains( @@ -177,6 +204,9 @@ llvm::Error BaseRequestHandler::LaunchProcess( launch_info.SetEnvironment(env, true); } + if (!arguments.stdio.empty() && !arguments.disableSTDIO) +SetupIORedirection(arguments.stdio, launch_info); + launch_info.SetDetachOnError(arguments.detachOnError); launch_info.SetShellExpandArguments(arguments.shellExpandArguments); diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp index e1806d6230a80..b455112cd37d9 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolRequests.c
[Lldb-commits] [lldb] [lldb-dap] Add stdio redirection (PR #158609)
https://github.com/JDevlieghere approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/158609 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add stdio redirection (PR #158609)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/158609 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb-dap] Fix typo in invalidated event (PR #158338)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/158338 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb-dap] Fix typo in invalidated event (PR #158338)
https://github.com/JDevlieghere auto_merge_enabled https://github.com/llvm/llvm-project/pull/158338 ___ 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 unordered-map test (PR #156033)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/156033 >From 134d45f372d7ac528f14899b0041add13269774d Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Fri, 29 Aug 2025 15:17:29 +0100 Subject: [PATCH] [lldb][test] Fix unordered-map test. test was failing because there is an extra struct on the stored pair in map --- .../Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp | 6 -- .../TestDataFormatterStdUnorderedMap.py | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index f88a5319068a2..a10056fcd74d0 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -113,8 +113,10 @@ CompilerType lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd:: // wraps a std::pair. Peel away the internal wrapper type - whose structure is // of no value to users, to expose the std::pair. This matches the structure // returned by the std::map synthetic provider. - if (isUnorderedMap(m_backend.GetCompilerType() - .GetNonReferenceType() + CompilerType backend_type = m_backend.GetCompilerType(); + if (backend_type.IsPointerOrReferenceType()) +backend_type = backend_type.GetPointeeType(); + if (isUnorderedMap(backend_type .GetCanonicalType() .GetTypeName())) { std::string name; diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py index d2382373f4810..1e920faab6397 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py @@ -113,7 +113,6 @@ def do_test_ptr(self): Test that pointers to std::unordered_map are formatted correctly. """ -self.build() (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "Stop here", lldb.SBFileSpec("main.cpp", False) ) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [NFC][lldb-dap] Fix typo in invalidated event (PR #158338)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/158338 >From da4574994f7d98454b7c1f224a3f4ef1d7a19384 Mon Sep 17 00:00:00 2001 From: Druzhkov Sergei Date: Fri, 12 Sep 2025 20:03:42 +0300 Subject: [PATCH] [NFC][lldb-dap] Fix typo in invalidated event --- lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp | 4 ++-- lldb/tools/lldb-dap/Protocol/ProtocolEvents.h | 2 +- lldb/unittests/DAP/ProtocolTypesTest.cpp| 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp index 9598c69878d66..062b9494ec10f 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp +++ b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp @@ -51,8 +51,8 @@ llvm::json::Value toJSON(const InvalidatedEventBody &IEB) { json::Object Result{{"areas", IEB.areas}}; if (IEB.threadId) Result.insert({"threadID", IEB.threadId}); - if (IEB.frameId) -Result.insert({"frameId", IEB.frameId}); + if (IEB.stackFrameId) +Result.insert({"stackFrameId", IEB.stackFrameId}); return Result; } diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.h b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.h index 138b622e01210..cb976d3395217 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.h +++ b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.h @@ -83,7 +83,7 @@ struct InvalidatedEventBody { /// If specified, the client only needs to refetch data related to this stack /// frame (and the `threadId` is ignored). - std::optional frameId; + std::optional stackFrameId; }; llvm::json::Value toJSON(const InvalidatedEventBody::Area &); llvm::json::Value toJSON(const InvalidatedEventBody &); diff --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp b/lldb/unittests/DAP/ProtocolTypesTest.cpp index a964592495347..61d197a705e0e 100644 --- a/lldb/unittests/DAP/ProtocolTypesTest.cpp +++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp @@ -1078,13 +1078,13 @@ TEST(ProtocolTypesTest, InvalidatedEventBody) { InvalidatedEventBody body; body.areas = {InvalidatedEventBody::eAreaStacks, InvalidatedEventBody::eAreaThreads}; - body.frameId = 1; + body.stackFrameId = 1; StringRef json = R"({ "areas": [ "stacks", "threads" ], - "frameId": 1 + "stackFrameId": 1 })"; EXPECT_EQ(json, pp(body)); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 90d96b3 - [NFC][lldb-dap] Fix typo in invalidated event (#158338)
Author: Druzhkov Sergei Date: 2025-09-16T18:28:13Z New Revision: 90d96b3e9c90cccefe1c1af75b57de1b8e248c42 URL: https://github.com/llvm/llvm-project/commit/90d96b3e9c90cccefe1c1af75b57de1b8e248c42 DIFF: https://github.com/llvm/llvm-project/commit/90d96b3e9c90cccefe1c1af75b57de1b8e248c42.diff LOG: [NFC][lldb-dap] Fix typo in invalidated event (#158338) Fixed a typo in the `invalidated` event according to [DAP](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Invalidated) specification. While the field is `frameId` elsewhere, it must be `stackFrameId` in this event. Added: Modified: lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp lldb/tools/lldb-dap/Protocol/ProtocolEvents.h lldb/unittests/DAP/ProtocolTypesTest.cpp Removed: diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp index 9598c69878d66..062b9494ec10f 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp +++ b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.cpp @@ -51,8 +51,8 @@ llvm::json::Value toJSON(const InvalidatedEventBody &IEB) { json::Object Result{{"areas", IEB.areas}}; if (IEB.threadId) Result.insert({"threadID", IEB.threadId}); - if (IEB.frameId) -Result.insert({"frameId", IEB.frameId}); + if (IEB.stackFrameId) +Result.insert({"stackFrameId", IEB.stackFrameId}); return Result; } diff --git a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.h b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.h index 138b622e01210..cb976d3395217 100644 --- a/lldb/tools/lldb-dap/Protocol/ProtocolEvents.h +++ b/lldb/tools/lldb-dap/Protocol/ProtocolEvents.h @@ -83,7 +83,7 @@ struct InvalidatedEventBody { /// If specified, the client only needs to refetch data related to this stack /// frame (and the `threadId` is ignored). - std::optional frameId; + std::optional stackFrameId; }; llvm::json::Value toJSON(const InvalidatedEventBody::Area &); llvm::json::Value toJSON(const InvalidatedEventBody &); diff --git a/lldb/unittests/DAP/ProtocolTypesTest.cpp b/lldb/unittests/DAP/ProtocolTypesTest.cpp index a964592495347..61d197a705e0e 100644 --- a/lldb/unittests/DAP/ProtocolTypesTest.cpp +++ b/lldb/unittests/DAP/ProtocolTypesTest.cpp @@ -1078,13 +1078,13 @@ TEST(ProtocolTypesTest, InvalidatedEventBody) { InvalidatedEventBody body; body.areas = {InvalidatedEventBody::eAreaStacks, InvalidatedEventBody::eAreaThreads}; - body.frameId = 1; + body.stackFrameId = 1; StringRef json = R"({ "areas": [ "stacks", "threads" ], - "frameId": 1 + "stackFrameId": 1 })"; EXPECT_EQ(json, pp(body)); } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] RISCV unwinding enable (PR #158161)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/158161 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Recognize MTE fault Mach exceptions (PR #159117)
DavidSpickett wrote: The Linux version for reference - https://github.com/llvm/llvm-project/commit/d510b5f199d6e7a3062b5a6ea43181c4cc00a605 Which uses the tag manager to handle all the masking. Though it appears to be lldb-server side, I'm not sure if this Mach bit is. What's the plan for handling this generally, are you going to use the tag manager object where you can? Luckily there's not much dynamism to MTE, so copy pasting the fixed mask a few times isn't the end of the world. The tag manager abstraction is more to handle when the entire tagging scheme changes, but would still be nice for it to work for MTE everywhere. How will this be tested? We can run API tests on iOS, right? I get that only you at Apple are likely to be able to do that with any convenience, but still. https://github.com/llvm/llvm-project/pull/159117 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Recognize MTE fault Mach exceptions (PR #159117)
@@ -77,6 +77,35 @@ static void DescribeAddressBriefly(Stream &strm, const Address &addr, strm.Printf(".\n"); } +static constexpr uint8_t g_mte_tag_shift = 64 - 8; +static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f << g_mte_tag_shift; + +bool StopInfoMachException::DetermineTagMismatch(ExecutionContext &exe_ctx) { + const bool IsBadAccess = m_value == 1;// EXC_BAD_ACCESS + const bool IsMTETagFault = (m_exc_code == 0x106); // EXC_ARM_MTE_TAG_FAULT + if (!IsBadAccess || !IsMTETagFault) +return false; + + if (m_exc_data_count < 2) +return false; + + const uint64_t bad_address = m_exc_subcode; + + StreamString strm; + strm.Printf("EXC_ARM_MTE_TAG_FAULT (code=%" PRIu64 ", address=0x%" PRIx64 + ")\n", + m_exc_code, bad_address); + + const uint8_t tag = (bad_address & g_mte_tag_mask) >> g_mte_tag_shift; + const uint64_t canonical_addr = bad_address & ~g_mte_tag_mask; + strm.Printf( + "Note: MTE tag mismatch detected: pointer tag=%d, address=0x%" PRIx64, DavidSpickett wrote: The Linux version will go and fetch the allocation tag, but I am not sure whether you have access to process here to do that. https://github.com/llvm/llvm-project/pull/159117 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Recognize MTE fault Mach exceptions (PR #159117)
DavidSpickett wrote: > How will this be tested? And I don't care about re-using the existing MTE tests so much. A lot of them do tricks like assuming mmap calls will produce memory in a certain sequence that are likely not portable or even stable to begin with :) https://github.com/llvm/llvm-project/pull/159117 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] RISCV unwinding enable (PR #158161)
@@ -0,0 +1,188 @@ +//===-- TestRiscvInstEmulation.cpp ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "gtest/gtest.h" + +#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h" + +#include "lldb/Core/AddressRange.h" +#include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Utility/ArchSpec.h" + +#include "Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h" +#include "Plugins/Instruction/RISCV/EmulateInstructionRISCV.h" +#include "Plugins/Process/Utility/lldb-riscv-register-enums.h" +#include "llvm/Support/TargetSelect.h" + +using namespace lldb; +using namespace lldb_private; + +class TestRiscvInstEmulation : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + +protected: +}; + +void TestRiscvInstEmulation::SetUpTestCase() { + llvm::InitializeAllTargets(); + llvm::InitializeAllAsmPrinters(); + llvm::InitializeAllTargetMCs(); + llvm::InitializeAllDisassemblers(); + DisassemblerLLVMC::Initialize(); + EmulateInstructionRISCV::Initialize(); +} + +void TestRiscvInstEmulation::TearDownTestCase() { + DisassemblerLLVMC::Terminate(); + EmulateInstructionRISCV::Terminate(); +} + +TEST_F(TestRiscvInstEmulation, TestSimpleRiscvFunction) { + ArchSpec arch("riscv64-unknown-linux-gnu"); + // Enable compressed instruction support (RVC extension) + arch.SetFlags(ArchSpec::eRISCV_rvc); + std::unique_ptr engine( + static_cast( + UnwindAssemblyInstEmulation::CreateInstance(arch))); + ASSERT_NE(nullptr, engine); + + // RISC-V function with compressed and uncompressed instructions + // 0x: 1141 addisp, sp, -0x10 + // 0x0002: e406 sd ra, 0x8(sp) + // 0x0004: e022 sd s0, 0x0(sp) + // 0x0006: 0800 addis0, sp, 0x10 + // 0x0008: 0537 lui a0, 0x0 + // 0x000C: 00050513 mv a0, a0 + // 0x0010: 0097 auipc ra, 0x0 + // 0x0014: 80e7 jalrra + // 0x0018: 4501 li a0, 0x0 + // 0x001A: ff040113 addisp, s0, -0x10 + // 0x001E: 60a2 ld ra, 0x8(sp) + // 0x0020: 6402 ld s0, 0x0(sp) + // 0x0022: 0141 addisp, sp, 0x10 + // 0x0024: 8082 ret + uint8_t data[] = {// 0x: 1141 addi sp, sp, -0x10 +0x41, 0x11, +// 0x0002: e406 sd ra, 0x8(sp) +0x06, 0xE4, +// 0x0004: e022 sd s0, 0x0(sp) +0x22, 0xE0, +// 0x0006: 0800 addi s0, sp, 0x10 +0x00, 0x08, +// 0x0008: 0537 lui a0, 0x0 +0x37, 0x05, 0x00, 0x00, +// 0x000C: 00050513 mv a0, a0 +0x13, 0x05, 0x05, 0x00, +// 0x0010: 0097 auipc ra, 0x0 +0x97, 0x00, 0x00, 0x00, +// 0x0014: 80e7 jalr ra +0xE7, 0x80, 0x00, 0x00, +// 0x0018: 4501 li a0, 0x0 +0x01, 0x45, +// 0x001A: ff040113 addi sp, s0, -0x10 +0x13, 0x01, 0x04, 0xFF, +// 0x001E: 60a2 ld ra, 0x8(sp) +0xA2, 0x60, +// 0x0020: 6402 ld s0, 0x0(sp) +0x02, 0x64, +// 0x0022: 0141 addi sp, sp, 0x10 +0x41, 0x01, +// 0x0024: 8082 ret +0x82, 0x80}; + + // Expected UnwindPlan (prologue only - emulation stops after frame setup): + // row[0]:0: CFA=sp+0 => fp= ra= + // row[1]:2: CFA=sp+16 => fp= ra= (after stack + // allocation) row[2]:4: CFA=sp+16 => fp= ra=[CFA-8] + // (after saving ra) row[3]:6: CFA=sp+16 => fp=[CFA-16] ra=[CFA-8] + // (after saving s0/fp) row[4]:8: CFA=s0+0 => fp=[CFA-16] ra=[CFA-8] + // (after setting frame pointer: s0=sp+16) + + const UnwindPlan::Row *row; + AddressRange sample_range; + UnwindPlan unwind_plan(eRegisterKindLLDB); + UnwindPlan::Row::AbstractRegisterLocation regloc; + sample_range = AddressRange(0x1000, sizeof(data)); + + EXPECT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly( + sample_range, data, sizeof(data), unwind_plan)); + + // CFA=sp+0 => fp= ra= + row = unwind_plan.GetRowForFunctionOffset(0); + EXPECT_EQ(0, row->GetOffset()); + EXPECT_TRUE(row->GetCFAValue().GetRegisterNumber() == gpr_sp_riscv); + EXPECT_TRUE(row->GetCFAValue().IsRegisterPlusOffset() == true); + EXPE
[Lldb-commits] [lldb] RISCV unwinding enable (PR #158161)
https://github.com/JDevlieghere commented: General feedback: Comment should end with periods. We have a little RISC-V board that runs Ubuntu [1]. It would be interesting to see if this improves the test results, but that doesn't block this PR. [1] https://github.com/llvm/llvm-project/issues/55383#issuecomment-3130905288 https://github.com/llvm/llvm-project/pull/158161 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-mcp] Launch lldb on demand, if needed. (PR #158701)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/158701 >From 39b27ffc60fe30e88e42918f2c3382369f06f3df Mon Sep 17 00:00:00 2001 From: John Harrison Date: Mon, 15 Sep 2025 10:30:04 -0700 Subject: [PATCH 1/4] [lldb-mcp] Launch lldb on demand, if needed. Adding support for launching lldb with `-O protocol start MCP` if a valid ~/.lldb/lldb-mcp-*.json` file is not found. --- lldb/source/Host/common/Socket.cpp | 2 +- lldb/tools/lldb-mcp/lldb-mcp.cpp | 122 + 2 files changed, 92 insertions(+), 32 deletions(-) diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index 3511cde8bb36f..bc3d849c5c6c6 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -506,7 +506,7 @@ Socket::GetProtocolAndMode(llvm::StringRef scheme) { .Case("unix-abstract-accept", ProtocolModePair{SocketProtocol::ProtocolUnixAbstract, SocketMode::ModeAccept}) - .Cases("connect", "tcp-connect", + .Cases("connect", "tcp-connect", "connection", ProtocolModePair{SocketProtocol::ProtocolTcp, SocketMode::ModeConnect}) .Case("udp", ProtocolModePair{SocketProtocol::ProtocolTcp, diff --git a/lldb/tools/lldb-mcp/lldb-mcp.cpp b/lldb/tools/lldb-mcp/lldb-mcp.cpp index 12545dcf3a3cc..42e82709dd9df 100644 --- a/lldb/tools/lldb-mcp/lldb-mcp.cpp +++ b/lldb/tools/lldb-mcp/lldb-mcp.cpp @@ -8,12 +8,16 @@ #include "lldb/Host/Config.h" #include "lldb/Host/File.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/Host.h" #include "lldb/Host/MainLoop.h" #include "lldb/Host/MainLoopBase.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Host/Socket.h" #include "lldb/Initialization/SystemInitializerCommon.h" #include "lldb/Initialization/SystemLifetimeManager.h" #include "lldb/Protocol/MCP/Server.h" +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/UriParser.h" #include "lldb/lldb-forward.h" @@ -24,7 +28,9 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Signals.h" #include "llvm/Support/WithColor.h" +#include #include +#include #include #if defined(_WIN32) @@ -35,13 +41,19 @@ using namespace llvm; using namespace lldb; using namespace lldb_protocol::mcp; +using lldb_private::Environment; using lldb_private::File; +using lldb_private::FileSpec; +using lldb_private::FileSystem; +using lldb_private::Host; using lldb_private::MainLoop; using lldb_private::MainLoopBase; using lldb_private::NativeFile; namespace { +constexpr size_t kForwardIOBufferSize = 1024; + inline void exitWithError(llvm::Error Err, StringRef Prefix = "") { handleAllErrors(std::move(Err), [&](ErrorInfoBase &Info) { WithColor::error(errs(), Prefix) << Info.message() << '\n'; @@ -49,10 +61,68 @@ inline void exitWithError(llvm::Error Err, StringRef Prefix = "") { std::exit(EXIT_FAILURE); } -constexpr size_t kForwardIOBufferSize = 1024; +FileSpec driverPath() { + Environment host_env = Host::GetEnvironment(); + + // Check if an override for which lldb we're using exists, otherwise look next + // to the current binary. + std::string lldb_exe_path = host_env.lookup("LLDB_EXE_PATH"); + auto &fs = FileSystem::Instance(); + if (fs.Exists(lldb_exe_path)) { +return FileSpec(lldb_exe_path); + } + FileSpec lldb_exec_spec = lldb_private::HostInfo::GetProgramFileSpec(); + lldb_exec_spec.SetFilename("lldb"); + return lldb_exec_spec; +} + +llvm::Error launch() { + FileSpec lldb_exec = driverPath(); + lldb_private::ProcessLaunchInfo info; + info.SetExecutableFile(lldb_exec, + /*add_exe_file_as_first_arg=*/true); + info.GetArguments().AppendArgument("-O"); + info.GetArguments().AppendArgument("protocol start MCP"); + std::promise exit_status; + info.SetMonitorProcessCallback([&](lldb::pid_t pid, int signal, int status) { +exit_status.set_value(status); + }); + + return Host::LaunchProcess(info).takeError(); +} + +Expected loadOrStart( +lldb_private::Timeout timeout = std::chrono::seconds(30)) { + using namespace std::chrono; + bool started = false; + + auto deadline = steady_clock::now() + *timeout; + while (steady_clock::now() < deadline) { +auto servers = ServerInfo::Load(); +if (!servers) + return servers.takeError(); + +if (servers->empty()) { + if (!started) { +started = true; +if (llvm::Error err = launch()) + return std::move(err); + } + std::this_thread::sleep_for(std::chrono::microseconds(250)); + continue; +} + +if (servers->size() > 1) + return createStringError("To many MCP servers running, picking a " + "specific one is not yet implemented"); + +return servers->front(); + } + + return createStringError("timed out waiting for MCP server to start"); +} -void forwardIO(lld
[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)
JustinStitt wrote: ping. rebased and fixed tests after `Commit b24769855d97: [Clang] [Sema] Make -Wincompatible-pointer-types an error by default (#157364)` caused some tests to fail. https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add stdio redirection (PR #158609)
https://github.com/walter-erquinigo approved this pull request. https://github.com/llvm/llvm-project/pull/158609 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 30633f3 - [clang] Initialize the file system explicitly (#158381)
Author: Jan Svoboda Date: 2025-09-16T08:21:06-07:00 New Revision: 30633f30894129919050f24fdd1f8f6bc46beae0 URL: https://github.com/llvm/llvm-project/commit/30633f30894129919050f24fdd1f8f6bc46beae0 DIFF: https://github.com/llvm/llvm-project/commit/30633f30894129919050f24fdd1f8f6bc46beae0.diff LOG: [clang] Initialize the file system explicitly (#158381) This PR is a part of the effort to make the VFS used in the compiler more explicit and consistent. Instead of creating the VFS deep within the compiler (in `CompilerInstance::createFileManager()`), clients are now required to explicitly call `CompilerInstance::createVirtualFileSystem()` and provide the base VFS from the outside. This PR also helps in breaking up the dependency cycle where creating a properly configured `DiagnosticsEngine` requires a properly configured VFS, but creating properly configuring a VFS requires the `DiagnosticsEngine`. Both `CompilerInstance::create{FileManager,Diagnostics}()` now just use the VFS already in `CompilerInstance` instead of taking one as a parameter, making the VFS consistent across the instance sub-object. Added: Modified: clang-tools-extra/clang-include-fixer/IncludeFixer.cpp clang-tools-extra/clangd/Compiler.cpp clang-tools-extra/include-cleaner/unittests/RecordTest.cpp clang/include/clang/Frontend/CompilerInstance.h clang/lib/Frontend/ASTUnit.cpp clang/lib/Frontend/ChainedIncludesSource.cpp clang/lib/Frontend/CompilerInstance.cpp clang/lib/Frontend/FrontendAction.cpp clang/lib/Frontend/Rewrite/FrontendActions.cpp clang/lib/Interpreter/Interpreter.cpp clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp clang/lib/Testing/TestAST.cpp clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp clang/lib/Tooling/Tooling.cpp clang/tools/clang-import-test/clang-import-test.cpp clang/tools/clang-installapi/ClangInstallAPI.cpp clang/tools/driver/cc1_main.cpp clang/unittests/AST/ExternalASTSourceTest.cpp clang/unittests/CodeGen/TestCompiler.h clang/unittests/Driver/ToolChainTest.cpp clang/unittests/Frontend/CodeGenActionTest.cpp clang/unittests/Frontend/CompilerInstanceTest.cpp clang/unittests/Frontend/FrontendActionTest.cpp clang/unittests/Frontend/OutputStreamTest.cpp clang/unittests/Serialization/ForceCheckFileInputTest.cpp clang/unittests/Serialization/ModuleCacheTest.cpp clang/unittests/Serialization/NoCommentsTest.cpp clang/unittests/Serialization/PreambleInNamedModulesTest.cpp clang/unittests/Support/TimeProfilerTest.cpp clang/unittests/Tooling/DependencyScanning/DependencyScannerTest.cpp lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp Removed: diff --git a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp index 30bb313524cbe..d2ae13c022b23 100644 --- a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp +++ b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp @@ -94,8 +94,7 @@ bool IncludeFixerActionFactory::runInvocation( // Create the compiler's actual diagnostics engine. We want to drop all // diagnostics here. - Compiler.createDiagnostics(Files->getVirtualFileSystem(), - new clang::IgnoringDiagConsumer, + Compiler.createDiagnostics(new clang::IgnoringDiagConsumer, /*ShouldOwnClient=*/true); Compiler.createSourceManager(*Files); diff --git a/clang-tools-extra/clangd/Compiler.cpp b/clang-tools-extra/clangd/Compiler.cpp index 8b3865c8a8e5c..6ebc2eac25745 100644 --- a/clang-tools-extra/clangd/Compiler.cpp +++ b/clang-tools-extra/clangd/Compiler.cpp @@ -147,13 +147,9 @@ prepareCompilerInstance(std::unique_ptr CI, } auto Clang = std::make_unique(std::move(CI)); - Clang->createDiagnostics(*VFS, &DiagsClient, false); - - if (auto VFSWithRemapping = createVFSFromCompilerInvocation( - Clang->getInvocation(), Clang->getDiagnostics(), VFS)) -VFS = VFSWithRemapping; - Clang->createFileManager(VFS); - + Clang->createVirtualFileSystem(VFS, &DiagsClient); + Clang->createDiagnostics(&DiagsClient, false); + Clang->createFileManager(); if (!Clang->createTarget()) return nullptr; diff --git a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp index c88848ed35580..3fb49796039f2 100644 --- a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp @@ -646,9 +646,10 @@ TEST_F(PragmaIncludeTest, ExportInUnnamedBuffer) { *Diags, "clang")); auto Clang = std::make_unique(std::move(Invocation)
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Initialize the file system explicitly (PR #158381)
https://github.com/jansvoboda11 closed https://github.com/llvm/llvm-project/pull/158381 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-mcp] Fix servers accepting more than one client. (PR #158357)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/158357 >From 07a8a62569a41c881f721b2800086eb559da6fa8 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Fri, 12 Sep 2025 13:06:30 -0700 Subject: [PATCH] [lldb-mcp] Fix servers accepting more than one client. This fixes an issue where the MCP server would stop the main loop after the first client disconnects. This moves the MainLoop out of the Server instance and lifts the server up into the ProtocolServerMCP object instead. This allows us to register the client with the main loop used to accept and process requests. --- lldb/include/lldb/Host/JSONTransport.h| 19 +++-- lldb/include/lldb/Protocol/MCP/Server.h | 17 ++--- .../Protocol/MCP/ProtocolServerMCP.cpp| 24 +-- .../Plugins/Protocol/MCP/ProtocolServerMCP.h | 17 - lldb/source/Protocol/MCP/Server.cpp | 43 lldb/unittests/Host/JSONTransportTest.cpp | 2 +- .../Protocol/ProtocolMCPServerTest.cpp| 70 --- 7 files changed, 110 insertions(+), 82 deletions(-) diff --git a/lldb/include/lldb/Host/JSONTransport.h b/lldb/include/lldb/Host/JSONTransport.h index 210f33edace6e..c73021d204258 100644 --- a/lldb/include/lldb/Host/JSONTransport.h +++ b/lldb/include/lldb/Host/JSONTransport.h @@ -100,22 +100,21 @@ template class Transport { virtual llvm::Expected RegisterMessageHandler(MainLoop &loop, MessageHandler &handler) = 0; - // FIXME: Refactor mcp::Server to not directly access log on the transport. - // protected: +protected: template inline auto Logv(const char *Fmt, Ts &&...Vals) { Log(llvm::formatv(Fmt, std::forward(Vals)...).str()); } virtual void Log(llvm::StringRef message) = 0; }; -/// A JSONTransport will encode and decode messages using JSON. +/// An IOTransport sends and receives messages using an IOObject. template -class JSONTransport : public Transport { +class IOTransport : public Transport { public: using Transport::Transport; using MessageHandler = typename Transport::MessageHandler; - JSONTransport(lldb::IOObjectSP in, lldb::IOObjectSP out) + IOTransport(lldb::IOObjectSP in, lldb::IOObjectSP out) : m_in(in), m_out(out) {} llvm::Error Send(const Evt &evt) override { return Write(evt); } @@ -127,7 +126,7 @@ class JSONTransport : public Transport { Status status; MainLoop::ReadHandleUP read_handle = loop.RegisterReadObject( m_in, -std::bind(&JSONTransport::OnRead, this, std::placeholders::_1, +std::bind(&IOTransport::OnRead, this, std::placeholders::_1, std::ref(handler)), status); if (status.Fail()) { @@ -203,9 +202,9 @@ class JSONTransport : public Transport { /// A transport class for JSON with a HTTP header. template -class HTTPDelimitedJSONTransport : public JSONTransport { +class HTTPDelimitedJSONTransport : public IOTransport { public: - using JSONTransport::JSONTransport; + using IOTransport::IOTransport; protected: /// Encodes messages based on @@ -270,9 +269,9 @@ class HTTPDelimitedJSONTransport : public JSONTransport { /// A transport class for JSON RPC. template -class JSONRPCTransport : public JSONTransport { +class JSONRPCTransport : public IOTransport { public: - using JSONTransport::JSONTransport; + using IOTransport::IOTransport; protected: std::string Encode(const llvm::json::Value &message) override { diff --git a/lldb/include/lldb/Protocol/MCP/Server.h b/lldb/include/lldb/Protocol/MCP/Server.h index b674d58159550..da8fe9c38dc7f 100644 --- a/lldb/include/lldb/Protocol/MCP/Server.h +++ b/lldb/include/lldb/Protocol/MCP/Server.h @@ -29,10 +29,11 @@ namespace lldb_protocol::mcp { class Server : public MCPTransport::MessageHandler { + using ClosedCallback = llvm::unique_function; + public: - Server(std::string name, std::string version, - std::unique_ptr transport_up, - lldb_private::MainLoop &loop); + Server(std::string name, std::string version, MCPTransport &client, + LogCallback log_callback = {}, ClosedCallback closed_callback = {}); ~Server() = default; using NotificationHandler = std::function; @@ -42,8 +43,6 @@ class Server : public MCPTransport::MessageHandler { void AddNotificationHandler(llvm::StringRef method, NotificationHandler handler); - llvm::Error Run(); - protected: ServerCapabilities GetCapabilities(); @@ -73,14 +72,16 @@ class Server : public MCPTransport::MessageHandler { void OnError(llvm::Error) override; void OnClosed() override; - void TerminateLoop(); +protected: + void Log(llvm::StringRef); private: const std::string m_name; const std::string m_version; - std::unique_ptr m_transport_up; - lldb_private::MainLoop &m_loop; + MCPTransport &m_client; + LogCallback m_log_callback; + ClosedCallback m_closed_callback; llvm::StringMap> m_tools; std::vector> m_resource_providers; dif
[Lldb-commits] [lldb] [lldb-mcp] Launch lldb on demand, if needed. (PR #158701)
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 origin/main HEAD --extensions cpp -- lldb/source/Host/common/Socket.cpp lldb/tools/lldb-mcp/lldb-mcp.cpp `` :warning: The reproduction instructions above might return results for more than one PR in a stack if you are using a stacked PR workflow. You can limit the results by changing `origin/main` to the base branch/commit you want to compare against. :warning: View the diff from clang-format here. ``diff diff --git a/lldb/tools/lldb-mcp/lldb-mcp.cpp b/lldb/tools/lldb-mcp/lldb-mcp.cpp index af8424d2b..88c137bdc 100644 --- a/lldb/tools/lldb-mcp/lldb-mcp.cpp +++ b/lldb/tools/lldb-mcp/lldb-mcp.cpp @@ -68,7 +68,7 @@ FileSpec driverPath() { // to the current binary. std::string lldb_exe_path = host_env.lookup("LLDB_EXE_PATH"); auto &fs = FileSystem::Instance(); - if (fs.Exists(lldb_exe_path)) + if (fs.Exists(lldb_exe_path)) return FileSpec(lldb_exe_path); FileSpec lldb_exec_spec = lldb_private::HostInfo::GetProgramFileSpec(); `` https://github.com/llvm/llvm-project/pull/158701 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix `GetIndexOfChildMemberWithName` to handle anonymous struct in base classes (PR #158256)
https://github.com/imkiva updated https://github.com/llvm/llvm-project/pull/158256 >From 8e00d31ce15eb3255c7bafe924754752dd563fd3 Mon Sep 17 00:00:00 2001 From: imkiva Date: Fri, 12 Sep 2025 16:14:23 +0800 Subject: [PATCH 1/6] [LLDB] Fix `GetIndexOfChildMemberWithName` to handle anonymous structs in base classes Fixes #158131 Similar to #138487 but also search for child indexes in the base classes --- .../TypeSystem/Clang/TypeSystemClang.cpp| 17 + 1 file changed, 17 insertions(+) diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 39aacdb58e694..1cf73dab2e724 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -6786,6 +6786,23 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName( } if (cxx_record_decl) { + for (const clang::CXXBaseSpecifier &base_spec : cxx_record_decl->bases()) { +uint32_t base_slot = +GetIndexForRecordBase(record_decl, &base_spec, omit_empty_base_classes); +if (base_slot == UINT32_MAX) + continue; + +std::vector save = child_indexes; +child_indexes.push_back(base_slot); +CompilerType base_type = GetType(base_spec.getType()); +if (GetIndexOfChildMemberWithName(base_type.GetOpaqueQualType(), + name, omit_empty_base_classes, + child_indexes)) { + return child_indexes.size(); +} +child_indexes = std::move(save); + } + const clang::RecordDecl *parent_record_decl = cxx_record_decl; // Didn't find things easily, lets let clang do its thang... >From 3c8ce49a705f4fd1dfc304e76704a9294beb4158 Mon Sep 17 00:00:00 2001 From: imkiva Date: Fri, 12 Sep 2025 17:12:37 +0800 Subject: [PATCH 2/6] [LLDB] Add tests --- .../cpp/type_lookup_anon_base_member/Makefile | 3 ++ .../TestCppTypeLookupAnonBaseMember.py| 37 +++ .../cpp/type_lookup_anon_base_member/main.cpp | 18 + 3 files changed, 58 insertions(+) create mode 100644 lldb/test/API/lang/cpp/type_lookup_anon_base_member/Makefile create mode 100644 lldb/test/API/lang/cpp/type_lookup_anon_base_member/TestCppTypeLookupAnonBaseMember.py create mode 100644 lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_base_member/Makefile b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/Makefile new file mode 100644 index 0..8b20bcb05 --- /dev/null +++ b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_base_member/TestCppTypeLookupAnonBaseMember.py b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/TestCppTypeLookupAnonBaseMember.py new file mode 100644 index 0..8f38403acfc34 --- /dev/null +++ b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/TestCppTypeLookupAnonBaseMember.py @@ -0,0 +1,37 @@ +""" +Test that we properly print anonymous members in a base class. +""" + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * +from lldbsuite.test import decorators + + +class TestTypeLookupAnonBaseMember(TestBase): +def test_lookup_anon_base_member(self): +self.build() +(target, process, thread, bp1) = lldbutil.run_to_source_breakpoint( +self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp") +) + +thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) +frame = thread.GetFrameAtIndex(0) + +d = frame.FindVariable("d") +self.assertTrue(d.IsValid()) + +# b from Base +b = d.GetChildMemberWithName("b") +self.assertTrue(b.IsValid()) +self.assertEqual(b.GetValueAsSigned(), 1) + +# x from anonymous struct (inside Base) +x = d.GetChildMemberWithName("x") +self.assertTrue(x.IsValid()) +self.assertEqual(x.GetValueAsSigned(), 2) + +# d from Derived +a = d.GetChildMemberWithName("a") +self.assertTrue(a.IsValid()) +self.assertEqual(a.GetValueAsSigned(), 3) diff --git a/lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp new file mode 100644 index 0..f27cf4ce163f9 --- /dev/null +++ b/lldb/test/API/lang/cpp/type_lookup_anon_base_member/main.cpp @@ -0,0 +1,18 @@ +struct Base { + int b; + struct { +int x; + }; +}; + +struct Derived : public Base { + int a; +}; + +int main() { + Derived d; + d.b = 1; + d.x = 2; + d.a = 3; + return 0; // Set breakpoint here +} >From cb332933cd6ec6d0bae0ad8a01216a07587e9c1
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
https://github.com/ashgti created https://github.com/llvm/llvm-project/pull/159160 This adds a new Binding helper class to allow mapping of incoming and outgoing requests / events to specific handlers. This should make it easier to create new protocol implementations and allow us to create a relay in the lldb-mcp binary. >From 846acc325cb34e98baae102dcf7450f22af79092 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 10 Sep 2025 10:42:56 -0700 Subject: [PATCH] [lldb] Adding A new Binding helper for JSONTransport. This adds a new Binding helper class to allow mapping of incoming and outgoing requests / events to specific handlers. This should make it easier to create new protocol implementations and allow us to create a relay in the lldb-mcp binary. --- lldb/include/lldb/Host/JSONTransport.h| 374 -- lldb/include/lldb/Protocol/MCP/Protocol.h | 8 + lldb/include/lldb/Protocol/MCP/Server.h | 73 ++-- lldb/include/lldb/Protocol/MCP/Transport.h| 77 +++- lldb/source/Host/common/JSONTransport.cpp | 10 + .../Protocol/MCP/ProtocolServerMCP.cpp| 42 +- .../Plugins/Protocol/MCP/ProtocolServerMCP.h | 20 +- lldb/source/Plugins/Protocol/MCP/Tool.cpp | 1 + lldb/source/Protocol/MCP/Server.cpp | 212 +++--- lldb/tools/lldb-dap/DAP.h | 6 +- lldb/tools/lldb-dap/Protocol/ProtocolBase.h | 6 +- lldb/tools/lldb-dap/Transport.h | 6 +- lldb/unittests/DAP/DAPTest.cpp| 20 +- lldb/unittests/DAP/Handler/DisconnectTest.cpp | 4 +- lldb/unittests/DAP/TestBase.cpp | 42 +- lldb/unittests/DAP/TestBase.h | 122 +++--- lldb/unittests/Host/JSONTransportTest.cpp | 332 .../Protocol/ProtocolMCPServerTest.cpp| 282 +++-- .../Host/JSONTransportTestUtilities.h | 96 - 19 files changed, 1155 insertions(+), 578 deletions(-) diff --git a/lldb/include/lldb/Host/JSONTransport.h b/lldb/include/lldb/Host/JSONTransport.h index 210f33edace6e..02c3beb3eaeb2 100644 --- a/lldb/include/lldb/Host/JSONTransport.h +++ b/lldb/include/lldb/Host/JSONTransport.h @@ -18,6 +18,7 @@ #include "lldb/Utility/IOObject.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" +#include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" @@ -25,8 +26,11 @@ #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/JSON.h" #include "llvm/Support/raw_ostream.h" +#include +#include #include #include +#include #include #include @@ -50,17 +54,70 @@ class TransportUnhandledContentsError std::string m_unhandled_contents; }; +class InvalidParams : public llvm::ErrorInfo { +public: + static char ID; + + explicit InvalidParams(std::string method, std::string context) + : m_method(std::move(method)), m_context(std::move(context)) {} + + void log(llvm::raw_ostream &OS) const override; + std::error_code convertToErrorCode() const override; + +private: + std::string m_method; + std::string m_context; +}; + +// Value for tracking functions that have a void param or result. +using VoidT = std::monostate; + +template using Callback = llvm::unique_function; + +template +using Reply = typename std::conditional< +std::is_same_v == true, llvm::unique_function, +llvm::unique_function)>>::type; + +template +using OutgoingRequest = typename std::conditional< +std::is_same_v == true, +llvm::unique_function)>, +llvm::unique_function)>>::type; + +template +using OutgoingEvent = typename std::conditional< +std::is_same_v == true, llvm::unique_function, +llvm::unique_function>::type; + +template +Req make_request(Id id, llvm::StringRef method, + std::optional params = std::nullopt); +template +Resp make_response(const Req &req, llvm::Error error); +template +Resp make_response(const Req &req, llvm::json::Value result); +template +Evt make_event(llvm::StringRef method, + std::optional params = std::nullopt); +template +llvm::Expected get_result(const Resp &resp); +template Id get_id(const T &); +template llvm::StringRef get_method(const T &); +template llvm::json::Value get_params(const T &); + /// A transport is responsible for maintaining the connection to a client /// application, and reading/writing structured messages to it. /// /// Transports have limited thread safety requirements: /// - Messages will not be sent concurrently. /// - Messages MAY be sent while Run() is reading, or its callback is active. -template class Transport { +template +class JSONTransport { public: using Message = std::variant; - virtual ~Transport() = default; + virtual ~JSONTransport() = default; /// Sends an event, a message that does not require a response. virtual llvm::Error Send(const Evt &) = 0; @@ -90,8 +147,6 @@ template class Transport { virtua
[Lldb-commits] [lldb] [lldb] Turn LineEntry into a class and make AddressRange member optional (PR #158811)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) Changes --- Patch is 37.34 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/158811.diff 26 Files Affected: - (modified) lldb/include/lldb/Breakpoint/BreakpointLocation.h (+2-1) - (modified) lldb/include/lldb/Core/Address.h (+1-1) - (modified) lldb/include/lldb/Symbol/LineEntry.h (+17-3) - (modified) lldb/include/lldb/lldb-forward.h (+1-1) - (modified) lldb/source/API/SBLineEntry.cpp (+5-5) - (modified) lldb/source/API/SBThread.cpp (+9-4) - (modified) lldb/source/Breakpoint/BreakpointResolver.cpp (+16-6) - (modified) lldb/source/Commands/CommandObjectDisassemble.cpp (+2-2) - (modified) lldb/source/Commands/CommandObjectSource.cpp (+4-2) - (modified) lldb/source/Commands/CommandObjectTarget.cpp (+2-2) - (modified) lldb/source/Commands/CommandObjectThread.cpp (+2-2) - (modified) lldb/source/Core/AddressResolverFileLine.cpp (+2-2) - (modified) lldb/source/Core/FormatEntity.cpp (+8-7) - (modified) lldb/source/DataFormatters/TypeSummary.cpp (+2-2) - (modified) lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (+1-1) - (modified) lldb/source/Symbol/CompileUnit.cpp (+10-6) - (modified) lldb/source/Symbol/Function.cpp (+9-8) - (modified) lldb/source/Symbol/LineEntry.cpp (+37-18) - (modified) lldb/source/Symbol/LineTable.cpp (+8-7) - (modified) lldb/source/Symbol/Symbol.cpp (+4-3) - (modified) lldb/source/Symbol/SymbolContext.cpp (+20-8) - (modified) lldb/source/Target/ThreadPlanShouldStopHere.cpp (+1-1) - (modified) lldb/source/Target/ThreadPlanStepOverRange.cpp (+2-2) - (modified) lldb/source/Target/ThreadPlanStepRange.cpp (+8-4) - (modified) lldb/tools/lldb-test/lldb-test.cpp (+8-3) - (modified) lldb/unittests/Symbol/LineTableTest.cpp (+8-3) ``diff diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h b/lldb/include/lldb/Breakpoint/BreakpointLocation.h index ab2e5e170559d..6a8d9ccfc8bc7 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h +++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h @@ -279,7 +279,8 @@ class BreakpointLocation /// The line entry must have the same start address as the address for this /// location. bool SetPreferredLineEntry(const LineEntry &line_entry) { -if (m_address == line_entry.range.GetBaseAddress()) { +if (line_entry.HasValidRange() && +m_address == line_entry.GetRange().GetBaseAddress()) { m_preferred_line_entry = line_entry; return true; } diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index 85b2ab7bb3cfe..a16cb55680a68 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -30,7 +30,7 @@ class Stream; class Symbol; class SymbolContext; class Target; -struct LineEntry; +class LineEntry; /// \class Address Address.h "lldb/Core/Address.h" /// A section + offset based address class. diff --git a/lldb/include/lldb/Symbol/LineEntry.h b/lldb/include/lldb/Symbol/LineEntry.h index 8da59cf0bd24a..755729a2a1442 100644 --- a/lldb/include/lldb/Symbol/LineEntry.h +++ b/lldb/include/lldb/Symbol/LineEntry.h @@ -13,12 +13,14 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/SupportFile.h" #include "lldb/lldb-private.h" +#include namespace lldb_private { /// \class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h" /// A line table entry class. -struct LineEntry { +class LineEntry { +public: /// Default constructor. /// /// Initialize all member variables to invalid values. @@ -133,9 +135,21 @@ struct LineEntry { /// Helper to access the file. const FileSpec &GetFile() const { return file_sp->GetSpecOnly(); } - /// The section offset address range for this line entry. - AddressRange range; + /// Get the address range for this line entry. + /// \return The address range if valid, otherwise an invalid AddressRange. + const AddressRange &GetRange() const; + /// Check if this line entry has a valid address range. + bool HasValidRange() const; + + /// Set the address range for this line entry. + void SetRange(const AddressRange &range); + +private: + /// The section offset address range for this line entry (optional). + std::optional m_range; + +public: /// The source file, possibly mapped by the target.source-map setting. lldb::SupportFileSP file_sp; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index af5656b3dcad1..1dedfd0d644f7 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -306,7 +306,7 @@ class WatchpointResource; class WatchpointResourceCollection; class WatchpointSetOptions; struct CompilerContext; -struct LineEntry; +class LineEntry; struct PropertyDefinition; struct ScriptSummaryFormat; struct StatisticsOptions; diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp index 0f4936f32a074..78ff488e8927f 100644 --- a/ll
[Lldb-commits] [lldb] [lldb] Turn LineEntry into a class and make AddressRange member optional (PR #158811)
https://github.com/medismailben edited https://github.com/llvm/llvm-project/pull/158811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Turn LineEntry into a class and make AddressRange member optional (PR #158811)
https://github.com/medismailben edited https://github.com/llvm/llvm-project/pull/158811 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Disable more DAP tests on Windows (PR #158906)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changes Flakey on Windows on Arm: https://lab.llvm.org/buildbot/#/builders/141/builds/11540 See #137660 --- Full diff: https://github.com/llvm/llvm-project/pull/158906.diff 2 Files Affected: - (modified) lldb/test/API/tools/lldb-dap/io/TestDAP_io.py (+1) - (modified) lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py (+1) ``diff diff --git a/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py b/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py index af5c62a8c4eb5..246ad3ae944cc 100644 --- a/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py +++ b/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py @@ -76,6 +76,7 @@ def test_incorrect_content_length(self): process.stdin.close() self.assertEqual(process.wait(timeout=5.0), EXIT_FAILURE) +@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660 def test_partial_content_length(self): """ lldb-dap returns a failure exit code when the input stream is closed diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index 22fcd42b3d36a..83392bcd2db73 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -143,6 +143,7 @@ def test_cwd(self): ) self.assertTrue(found, "verified program working directory") +@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660 def test_debuggerRoot(self): """ Tests the "debuggerRoot" will change the working directory of `` https://github.com/llvm/llvm-project/pull/158906 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f5022bd - [lldb][test] import-std-module: skip vector tests
Author: Michael Buch Date: 2025-09-16T10:30:49+01:00 New Revision: f5022bd03e7beab522ab3684228d531ef5c0789a URL: https://github.com/llvm/llvm-project/commit/f5022bd03e7beab522ab3684228d531ef5c0789a DIFF: https://github.com/llvm/llvm-project/commit/f5022bd03e7beab522ab3684228d531ef5c0789a.diff LOG: [lldb][test] import-std-module: skip vector tests This unblocks https://github.com/llvm/llvm-project/pull/158606. The tests are failing because libc++ is now using lambdas in function bodies in the vector header. Ever since https://github.com/llvm/llvm-project/issues/149477 we bail out of importing types when we encounter lambdas. Until we fix ASTImport of `clang::LambdaExpr` nodes properly, this will need to be skipped. Added: Modified: lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py Removed: diff --git a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py index 1c3e64f14..5f43fa1ea5662 100644 --- a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py @@ -13,7 +13,9 @@ class TestDbgInfoContentVector(TestBase): @skipIf(compiler=no_match("clang")) @skipIf(compiler="clang", compiler_version=["<", "12.0"]) @skipIf(macos_version=["<", "14.0"]) -@skipIfDarwin # https://github.com/llvm/llvm-project/issues/106475 +@skipIf( +bugnumber="ASTImport of lambdas not supported: https://github.com/llvm/llvm-project/issues/149477"; +) def test(self): self.build() diff --git a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py index 2cddce09aa8b8..f0eb4758ca54b 100644 --- a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py @@ -11,6 +11,9 @@ class TestVectorOfVectors(TestBase): @add_test_categories(["libc++"]) @skipIf(compiler=no_match("clang")) @skipIf(macos_version=["<", "15.0"]) +@skipIf( +bugnumber="ASTImport of lambdas not supported: https://github.com/llvm/llvm-project/issues/149477"; +) def test(self): self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make LineEntry class and make AddressRange member optional (PR #158811)
https://github.com/medismailben created https://github.com/llvm/llvm-project/pull/158811 None >From 8ccfc58fd99356e88a16337f1fee21f104c49aa5 Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Tue, 16 Sep 2025 01:10:16 -0700 Subject: [PATCH] [lldb] Make LineEntry class and make AddressRange member optional Signed-off-by: Med Ismail Bennani --- .../lldb/Breakpoint/BreakpointLocation.h | 3 +- lldb/include/lldb/Core/Address.h | 2 +- lldb/include/lldb/Symbol/LineEntry.h | 20 ++- lldb/include/lldb/lldb-forward.h | 2 +- lldb/source/API/SBLineEntry.cpp | 10 ++-- lldb/source/API/SBThread.cpp | 13 +++-- lldb/source/Breakpoint/BreakpointResolver.cpp | 22 ++-- .../Commands/CommandObjectDisassemble.cpp | 4 +- lldb/source/Commands/CommandObjectSource.cpp | 6 +- lldb/source/Commands/CommandObjectTarget.cpp | 4 +- lldb/source/Commands/CommandObjectThread.cpp | 4 +- lldb/source/Core/AddressResolverFileLine.cpp | 4 +- lldb/source/Core/FormatEntity.cpp | 15 ++--- lldb/source/DataFormatters/TypeSummary.cpp| 4 +- .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 2 +- lldb/source/Symbol/CompileUnit.cpp| 16 -- lldb/source/Symbol/Function.cpp | 17 +++--- lldb/source/Symbol/LineEntry.cpp | 55 +-- lldb/source/Symbol/LineTable.cpp | 15 ++--- lldb/source/Symbol/Symbol.cpp | 7 ++- lldb/source/Symbol/SymbolContext.cpp | 28 +++--- .../Target/ThreadPlanShouldStopHere.cpp | 2 +- .../source/Target/ThreadPlanStepOverRange.cpp | 4 +- lldb/source/Target/ThreadPlanStepRange.cpp| 12 ++-- lldb/tools/lldb-test/lldb-test.cpp| 11 +++- lldb/unittests/Symbol/LineTableTest.cpp | 11 +++- 26 files changed, 189 insertions(+), 104 deletions(-) diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h b/lldb/include/lldb/Breakpoint/BreakpointLocation.h index ab2e5e170559d..6a8d9ccfc8bc7 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h +++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h @@ -279,7 +279,8 @@ class BreakpointLocation /// The line entry must have the same start address as the address for this /// location. bool SetPreferredLineEntry(const LineEntry &line_entry) { -if (m_address == line_entry.range.GetBaseAddress()) { +if (line_entry.HasValidRange() && +m_address == line_entry.GetRange().GetBaseAddress()) { m_preferred_line_entry = line_entry; return true; } diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index 85b2ab7bb3cfe..a16cb55680a68 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -30,7 +30,7 @@ class Stream; class Symbol; class SymbolContext; class Target; -struct LineEntry; +class LineEntry; /// \class Address Address.h "lldb/Core/Address.h" /// A section + offset based address class. diff --git a/lldb/include/lldb/Symbol/LineEntry.h b/lldb/include/lldb/Symbol/LineEntry.h index 8da59cf0bd24a..755729a2a1442 100644 --- a/lldb/include/lldb/Symbol/LineEntry.h +++ b/lldb/include/lldb/Symbol/LineEntry.h @@ -13,12 +13,14 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/SupportFile.h" #include "lldb/lldb-private.h" +#include namespace lldb_private { /// \class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h" /// A line table entry class. -struct LineEntry { +class LineEntry { +public: /// Default constructor. /// /// Initialize all member variables to invalid values. @@ -133,9 +135,21 @@ struct LineEntry { /// Helper to access the file. const FileSpec &GetFile() const { return file_sp->GetSpecOnly(); } - /// The section offset address range for this line entry. - AddressRange range; + /// Get the address range for this line entry. + /// \return The address range if valid, otherwise an invalid AddressRange. + const AddressRange &GetRange() const; + /// Check if this line entry has a valid address range. + bool HasValidRange() const; + + /// Set the address range for this line entry. + void SetRange(const AddressRange &range); + +private: + /// The section offset address range for this line entry (optional). + std::optional m_range; + +public: /// The source file, possibly mapped by the target.source-map setting. lldb::SupportFileSP file_sp; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index af5656b3dcad1..1dedfd0d644f7 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -306,7 +306,7 @@ class WatchpointResource; class WatchpointResourceCollection; class WatchpointSetOptions; struct CompilerContext; -struct LineEntry; +class LineEntry; struct PropertyDefinition; struct ScriptSummaryFormat; struct StatisticsOptions; diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntr
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Added unique builtins types for __bf16 and _Float16 (PR #157674)
tgs-sc wrote: @Michael137, Hi! Sorry for disturbing you. A week has passed, can you please look at this patch? https://github.com/llvm/llvm-project/pull/157674 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Disable more DAP tests on Windows (PR #158906)
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/158906 Flakey on Windows on Arm: https://lab.llvm.org/buildbot/#/builders/141/builds/11540 See #137660 >From 38b081dca6952783c1064527e227e3c6195fa552 Mon Sep 17 00:00:00 2001 From: David Spickett Date: Tue, 16 Sep 2025 10:57:10 +0100 Subject: [PATCH] [lldb][lldb-dap] Disable more DAP tests on Windows Flakey on Windows on Arm: https://lab.llvm.org/buildbot/#/builders/141/builds/11540 See #137660 --- lldb/test/API/tools/lldb-dap/io/TestDAP_io.py | 1 + lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py | 1 + 2 files changed, 2 insertions(+) diff --git a/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py b/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py index af5c62a8c4eb5..246ad3ae944cc 100644 --- a/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py +++ b/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py @@ -76,6 +76,7 @@ def test_incorrect_content_length(self): process.stdin.close() self.assertEqual(process.wait(timeout=5.0), EXIT_FAILURE) +@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660 def test_partial_content_length(self): """ lldb-dap returns a failure exit code when the input stream is closed diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index 22fcd42b3d36a..83392bcd2db73 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -143,6 +143,7 @@ def test_cwd(self): ) self.assertTrue(found, "verified program working directory") +@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660 def test_debuggerRoot(self): """ Tests the "debuggerRoot" will change the working directory of ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a0a82ee - [lldb][lldb-dap] Disable more DAP tests on Windows (#158906)
Author: David Spickett Date: 2025-09-16T10:58:49+01:00 New Revision: a0a82ee19d6f2ff1013407ba4c973bfe5428423f URL: https://github.com/llvm/llvm-project/commit/a0a82ee19d6f2ff1013407ba4c973bfe5428423f DIFF: https://github.com/llvm/llvm-project/commit/a0a82ee19d6f2ff1013407ba4c973bfe5428423f.diff LOG: [lldb][lldb-dap] Disable more DAP tests on Windows (#158906) Flakey on Windows on Arm: https://lab.llvm.org/buildbot/#/builders/141/builds/11540 See #137660 Added: Modified: lldb/test/API/tools/lldb-dap/io/TestDAP_io.py lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py Removed: diff --git a/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py b/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py index af5c62a8c4eb5..246ad3ae944cc 100644 --- a/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py +++ b/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py @@ -76,6 +76,7 @@ def test_incorrect_content_length(self): process.stdin.close() self.assertEqual(process.wait(timeout=5.0), EXIT_FAILURE) +@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660 def test_partial_content_length(self): """ lldb-dap returns a failure exit code when the input stream is closed diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index 22fcd42b3d36a..83392bcd2db73 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -143,6 +143,7 @@ def test_cwd(self): ) self.assertTrue(found, "verified program working directory") +@skipIfWindows # https://github.com/llvm/llvm-project/issues/137660 def test_debuggerRoot(self): """ Tests the "debuggerRoot" will change the working directory of ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][lldb-dap] Disable more DAP tests on Windows (PR #158906)
https://github.com/DavidSpickett closed https://github.com/llvm/llvm-project/pull/158906 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Added unique builtins types for __bf16 and _Float16 (PR #157674)
kefirRzevo wrote: @Michael137, Hi! Sorry for disturbing you. A week has passed, can you please look at this patch? https://github.com/llvm/llvm-project/pull/157674 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-mcp] Launch lldb on demand, if needed. (PR #158701)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/158701 >From 39b27ffc60fe30e88e42918f2c3382369f06f3df Mon Sep 17 00:00:00 2001 From: John Harrison Date: Mon, 15 Sep 2025 10:30:04 -0700 Subject: [PATCH 1/5] [lldb-mcp] Launch lldb on demand, if needed. Adding support for launching lldb with `-O protocol start MCP` if a valid ~/.lldb/lldb-mcp-*.json` file is not found. --- lldb/source/Host/common/Socket.cpp | 2 +- lldb/tools/lldb-mcp/lldb-mcp.cpp | 122 + 2 files changed, 92 insertions(+), 32 deletions(-) diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index 3511cde8bb36f..bc3d849c5c6c6 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -506,7 +506,7 @@ Socket::GetProtocolAndMode(llvm::StringRef scheme) { .Case("unix-abstract-accept", ProtocolModePair{SocketProtocol::ProtocolUnixAbstract, SocketMode::ModeAccept}) - .Cases("connect", "tcp-connect", + .Cases("connect", "tcp-connect", "connection", ProtocolModePair{SocketProtocol::ProtocolTcp, SocketMode::ModeConnect}) .Case("udp", ProtocolModePair{SocketProtocol::ProtocolTcp, diff --git a/lldb/tools/lldb-mcp/lldb-mcp.cpp b/lldb/tools/lldb-mcp/lldb-mcp.cpp index 12545dcf3a3cc..42e82709dd9df 100644 --- a/lldb/tools/lldb-mcp/lldb-mcp.cpp +++ b/lldb/tools/lldb-mcp/lldb-mcp.cpp @@ -8,12 +8,16 @@ #include "lldb/Host/Config.h" #include "lldb/Host/File.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/Host.h" #include "lldb/Host/MainLoop.h" #include "lldb/Host/MainLoopBase.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Host/Socket.h" #include "lldb/Initialization/SystemInitializerCommon.h" #include "lldb/Initialization/SystemLifetimeManager.h" #include "lldb/Protocol/MCP/Server.h" +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/UriParser.h" #include "lldb/lldb-forward.h" @@ -24,7 +28,9 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Signals.h" #include "llvm/Support/WithColor.h" +#include #include +#include #include #if defined(_WIN32) @@ -35,13 +41,19 @@ using namespace llvm; using namespace lldb; using namespace lldb_protocol::mcp; +using lldb_private::Environment; using lldb_private::File; +using lldb_private::FileSpec; +using lldb_private::FileSystem; +using lldb_private::Host; using lldb_private::MainLoop; using lldb_private::MainLoopBase; using lldb_private::NativeFile; namespace { +constexpr size_t kForwardIOBufferSize = 1024; + inline void exitWithError(llvm::Error Err, StringRef Prefix = "") { handleAllErrors(std::move(Err), [&](ErrorInfoBase &Info) { WithColor::error(errs(), Prefix) << Info.message() << '\n'; @@ -49,10 +61,68 @@ inline void exitWithError(llvm::Error Err, StringRef Prefix = "") { std::exit(EXIT_FAILURE); } -constexpr size_t kForwardIOBufferSize = 1024; +FileSpec driverPath() { + Environment host_env = Host::GetEnvironment(); + + // Check if an override for which lldb we're using exists, otherwise look next + // to the current binary. + std::string lldb_exe_path = host_env.lookup("LLDB_EXE_PATH"); + auto &fs = FileSystem::Instance(); + if (fs.Exists(lldb_exe_path)) { +return FileSpec(lldb_exe_path); + } + FileSpec lldb_exec_spec = lldb_private::HostInfo::GetProgramFileSpec(); + lldb_exec_spec.SetFilename("lldb"); + return lldb_exec_spec; +} + +llvm::Error launch() { + FileSpec lldb_exec = driverPath(); + lldb_private::ProcessLaunchInfo info; + info.SetExecutableFile(lldb_exec, + /*add_exe_file_as_first_arg=*/true); + info.GetArguments().AppendArgument("-O"); + info.GetArguments().AppendArgument("protocol start MCP"); + std::promise exit_status; + info.SetMonitorProcessCallback([&](lldb::pid_t pid, int signal, int status) { +exit_status.set_value(status); + }); + + return Host::LaunchProcess(info).takeError(); +} + +Expected loadOrStart( +lldb_private::Timeout timeout = std::chrono::seconds(30)) { + using namespace std::chrono; + bool started = false; + + auto deadline = steady_clock::now() + *timeout; + while (steady_clock::now() < deadline) { +auto servers = ServerInfo::Load(); +if (!servers) + return servers.takeError(); + +if (servers->empty()) { + if (!started) { +started = true; +if (llvm::Error err = launch()) + return std::move(err); + } + std::this_thread::sleep_for(std::chrono::microseconds(250)); + continue; +} + +if (servers->size() > 1) + return createStringError("To many MCP servers running, picking a " + "specific one is not yet implemented"); + +return servers->front(); + } + + return createStringError("timed out waiting for MCP server to start"); +} -void forwardIO(lld
[Lldb-commits] [lldb] [LLDB] Add boolean literals to DIL. (PR #157992)
https://github.com/JDevlieghere approved this pull request. This looks pretty straightforward. LGTM. https://github.com/llvm/llvm-project/pull/157992 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [cmake][lldb][test] Respect LIBCXX_LIBDIR_SUBDIR (PR #159106)
https://github.com/tambry created https://github.com/llvm/llvm-project/pull/159106 This code in principle needs to match the one in libc++ but hasn't been updated to account for LIBCXX_LIBDIR_SUBDIR so tests don't work if LLVM is built with it specified. Fixes: ed155f3f237a7e3a3e40a84d815225d27e83f0db >From 57517426e48fa2dff4f644c08aae9a9e37593f18 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Mon, 15 Sep 2025 14:50:21 +0300 Subject: [PATCH] [cmake][lldb][test] Respect LIBCXX_LIBDIR_SUBDIR This code in principle needs to match the one in libc++ but hasn't been updated to account for LIBCXX_LIBDIR_SUBDIR so tests don't work if LLVM is built with it specified. Fixes: ed155f3f237a7e3a3e40a84d815225d27e83f0db --- lldb/test/CMakeLists.txt | 9 +++-- lldb/utils/lldb-dotest/CMakeLists.txt | 9 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index 8116f4c3c823a..513d1ec493ee1 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -164,9 +164,14 @@ if(TARGET clang) if (TARGET libcxx OR ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)) set(LLDB_HAS_LIBCXX ON) if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) - set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) + set(LIBCXX_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE}) + if(LIBCXX_LIBDIR_SUBDIR) +string(APPEND LIBCXX_TARGET_SUBDIR /${LIBCXX_LIBDIR_SUBDIR}) + endif() + cmake_path(NORMAL_PATH LIBCXX_TARGET_SUBDIR) + set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBCXX_TARGET_SUBDIR}) set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") - set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1") + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1") else() set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") diff --git a/lldb/utils/lldb-dotest/CMakeLists.txt b/lldb/utils/lldb-dotest/CMakeLists.txt index 3b8c88b6dc78c..f3f75015637f4 100644 --- a/lldb/utils/lldb-dotest/CMakeLists.txt +++ b/lldb/utils/lldb-dotest/CMakeLists.txt @@ -15,9 +15,14 @@ llvm_canonicalize_cmake_booleans( if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES) set(LLDB_HAS_LIBCXX ON) if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) -set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) +set(LIBCXX_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE}) +if(LIBCXX_LIBDIR_SUBDIR) + string(APPEND LIBCXX_TARGET_SUBDIR /${LIBCXX_LIBDIR_SUBDIR}) +endif() +cmake_path(NORMAL_PATH LIBCXX_TARGET_SUBDIR) +set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBCXX_TARGET_SUBDIR}) set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") -set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1") +set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LIBCXX_TARGET_SUBDIR}/c++/v1") else() set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix 64 bit support for CIE and FDE handling in DWARFCallFrameInfo (PR #158350)
https://github.com/dmpots edited https://github.com/llvm/llvm-project/pull/158350 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix 64 bit support for CIE and FDE handling in DWARFCallFrameInfo (PR #158350)
@@ -147,6 +149,27 @@ GetGNUEHPointer(const DataExtractor &DE, lldb::offset_t *offset_ptr, return baseAddress + addressValue; } +// Check if the given cie_id value indicates a CIE (Common Information Entry) +// as opposed to an FDE (Frame Description Entry). +// +// For eh_frame sections: CIE is marked with cie_id == 0 +// For debug_frame sections: +// - DWARF32: CIE is marked with cie_id == +// std::numeric_limits::max() +// - DWARF64: CIE is marked with cie_id == +// std::numeric_limits::max() +static bool IsCIEMarker(uint64_t cie_id, bool is_64bit, +DWARFCallFrameInfo::Type type) { + if (type == DWARFCallFrameInfo::EH) +return cie_id == 0; + + // DWARF type + if (is_64bit) +return cie_id == std::numeric_limits::max(); + + return cie_id == std::numeric_limits::max(); dmpots wrote: We already have these constants in the llvm Dwarf.h header ``` const uint32_t DW_CIE_ID = UINT32_MAX; const uint64_t DW64_CIE_ID = UINT64_MAX; ``` We can use them from there https://github.com/dmpots/llvm-project/blob/main/llvm/include/llvm/BinaryFormat/Dwarf.h#L97 https://github.com/llvm/llvm-project/pull/158350 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix 64 bit support for CIE and FDE handling in DWARFCallFrameInfo (PR #158350)
@@ -283,7 +306,7 @@ DWARFCallFrameInfo::ParseCIE(const dw_offset_t cie_offset) { GetCFIData(); uint32_t length = m_cfi_data.GetU32(&offset); dw_offset_t cie_id, end_offset; - bool is_64bit = (length == UINT32_MAX); + bool is_64bit = (length == std::numeric_limits::max()); dmpots wrote: Can use ``` DW_LENGTH_DWARF64 from here https://github.com/dmpots/llvm-project/blob/5c17af419ec7e9c823a1ae9287baeed0d27336ce/llvm/include/llvm/BinaryFormat/Dwarf.h#L56C3-L56C20 https://github.com/llvm/llvm-project/pull/158350 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix 64 bit support for CIE and FDE handling in DWARFCallFrameInfo (PR #158350)
https://github.com/dmpots requested changes to this pull request. I think we should add a test for this. Can help you with the YAML if needed. https://github.com/llvm/llvm-project/pull/158350 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][LoongArch] Preserve temporary symbols starting with `.L` in lldb symbol table (PR #158551)
MaskRay wrote: > I assume this is fallout from > [discourse.llvm.org/t/rfc-should-we-omit-local-symbols-in-elf-files-from-the-lldb-symbol-table/87384](https://discourse.llvm.org/t/rfc-should-we-omit-local-symbols-in-elf-files-from-the-lldb-symbol-table/87384). > > Which I have no context for but I'll add some of those folks on review. I am not familiar with lldb. When RISC-V and LoongArch linker relaxation is enabled for assemblers, there are typically a lot of `.L0 ` symbols (#89693). These numerous symbols have an identical name. What does "preserve" in the context mean? https://github.com/llvm/llvm-project/pull/158551 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ba5ca37 - [lldb-mcp] Launch lldb on demand, if needed. (#158701)
Author: John Harrison Date: 2025-09-16T09:57:37-07:00 New Revision: ba5ca37f40b82e287a3e0469fb0f0ea48b651aca URL: https://github.com/llvm/llvm-project/commit/ba5ca37f40b82e287a3e0469fb0f0ea48b651aca DIFF: https://github.com/llvm/llvm-project/commit/ba5ca37f40b82e287a3e0469fb0f0ea48b651aca.diff LOG: [lldb-mcp] Launch lldb on demand, if needed. (#158701) Adding support for launching lldb with `-O protocol start MCP` if a valid ~/.lldb/lldb-mcp-*.json` file is not found. - Co-authored-by: Jonas Devlieghere Added: Modified: lldb/source/Host/common/Socket.cpp lldb/tools/lldb-mcp/lldb-mcp.cpp Removed: diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp index 3511cde8bb36f..bc3d849c5c6c6 100644 --- a/lldb/source/Host/common/Socket.cpp +++ b/lldb/source/Host/common/Socket.cpp @@ -506,7 +506,7 @@ Socket::GetProtocolAndMode(llvm::StringRef scheme) { .Case("unix-abstract-accept", ProtocolModePair{SocketProtocol::ProtocolUnixAbstract, SocketMode::ModeAccept}) - .Cases("connect", "tcp-connect", + .Cases("connect", "tcp-connect", "connection", ProtocolModePair{SocketProtocol::ProtocolTcp, SocketMode::ModeConnect}) .Case("udp", ProtocolModePair{SocketProtocol::ProtocolTcp, diff --git a/lldb/tools/lldb-mcp/lldb-mcp.cpp b/lldb/tools/lldb-mcp/lldb-mcp.cpp index 12545dcf3a3cc..68e987237cc69 100644 --- a/lldb/tools/lldb-mcp/lldb-mcp.cpp +++ b/lldb/tools/lldb-mcp/lldb-mcp.cpp @@ -8,12 +8,16 @@ #include "lldb/Host/Config.h" #include "lldb/Host/File.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/Host.h" #include "lldb/Host/MainLoop.h" #include "lldb/Host/MainLoopBase.h" +#include "lldb/Host/ProcessLaunchInfo.h" #include "lldb/Host/Socket.h" #include "lldb/Initialization/SystemInitializerCommon.h" #include "lldb/Initialization/SystemLifetimeManager.h" #include "lldb/Protocol/MCP/Server.h" +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/UriParser.h" #include "lldb/lldb-forward.h" @@ -24,8 +28,10 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Signals.h" #include "llvm/Support/WithColor.h" +#include #include #include +#include #if defined(_WIN32) #include @@ -35,13 +41,25 @@ using namespace llvm; using namespace lldb; using namespace lldb_protocol::mcp; +using lldb_private::Environment; using lldb_private::File; +using lldb_private::FileSpec; +using lldb_private::FileSystem; +using lldb_private::Host; using lldb_private::MainLoop; using lldb_private::MainLoopBase; using lldb_private::NativeFile; namespace { +#if defined(_WIN32) +constexpr StringLiteral kDriverName = "lldb.exe"; +#else +constexpr StringLiteral kDriverName = "lldb"; +#endif + +constexpr size_t kForwardIOBufferSize = 1024; + inline void exitWithError(llvm::Error Err, StringRef Prefix = "") { handleAllErrors(std::move(Err), [&](ErrorInfoBase &Info) { WithColor::error(errs(), Prefix) << Info.message() << '\n'; @@ -49,10 +67,67 @@ inline void exitWithError(llvm::Error Err, StringRef Prefix = "") { std::exit(EXIT_FAILURE); } -constexpr size_t kForwardIOBufferSize = 1024; +FileSpec driverPath() { + Environment host_env = Host::GetEnvironment(); + + // Check if an override for which lldb we're using exists, otherwise look next + // to the current binary. + std::string lldb_exe_path = host_env.lookup("LLDB_EXE_PATH"); + auto &fs = FileSystem::Instance(); + if (fs.Exists(lldb_exe_path)) +return FileSpec(lldb_exe_path); + + FileSpec lldb_exec_spec = lldb_private::HostInfo::GetProgramFileSpec(); + lldb_exec_spec.SetFilename(kDriverName); + return lldb_exec_spec; +} + +llvm::Error launch() { + FileSpec lldb_exec = driverPath(); + lldb_private::ProcessLaunchInfo info; + info.SetExecutableFile(lldb_exec, + /*add_exe_file_as_first_arg=*/true); + info.GetArguments().AppendArgument("-O"); + info.GetArguments().AppendArgument("protocol start MCP"); + return Host::LaunchProcess(info).takeError(); +} + +Expected loadOrStart( +// FIXME: This should become a CLI arg. +lldb_private::Timeout timeout = std::chrono::seconds(30)) { + using namespace std::chrono; + bool started = false; + + const auto deadline = steady_clock::now() + *timeout; + while (steady_clock::now() < deadline) { +Expected> servers = ServerInfo::Load(); +if (!servers) + return servers.takeError(); + +if (servers->empty()) { + if (!started) { +started = true; +if (llvm::Error err = launch()) + return std::move(err); + } + + // FIXME: Can we use MainLoop to watch the directory? + std::this_thread::sleep_for(microseconds(250)); + continue; +} + +// FIXME: Support selecting / multiplexing a specific l
[Lldb-commits] [lldb] [lldb] Adding A new Binding helper for JSONTransport. (PR #159160)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/159160 >From b91cad6dc7ea4c40c61a0cfe9bb45be03de32254 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 10 Sep 2025 10:42:56 -0700 Subject: [PATCH] [lldb] Adding A new Binding helper for JSONTransport. This adds a new Binding helper class to allow mapping of incoming and outgoing requests / events to specific handlers. This should make it easier to create new protocol implementations and allow us to create a relay in the lldb-mcp binary. --- lldb/include/lldb/Host/JSONTransport.h| 387 -- lldb/include/lldb/Protocol/MCP/Protocol.h | 8 + lldb/include/lldb/Protocol/MCP/Server.h | 73 ++-- lldb/include/lldb/Protocol/MCP/Transport.h| 77 +++- lldb/source/Host/common/JSONTransport.cpp | 10 + .../Protocol/MCP/ProtocolServerMCP.cpp| 42 +- .../Plugins/Protocol/MCP/ProtocolServerMCP.h | 20 +- lldb/source/Protocol/MCP/Server.cpp | 211 +++--- lldb/tools/lldb-dap/DAP.h | 6 +- lldb/tools/lldb-dap/Protocol/ProtocolBase.h | 6 +- lldb/tools/lldb-dap/Transport.h | 6 +- lldb/unittests/DAP/DAPTest.cpp| 20 +- lldb/unittests/DAP/Handler/DisconnectTest.cpp | 4 +- lldb/unittests/DAP/TestBase.cpp | 42 +- lldb/unittests/DAP/TestBase.h | 122 +++--- lldb/unittests/Host/JSONTransportTest.cpp | 338 +++ .../Protocol/ProtocolMCPServerTest.cpp| 280 +++-- .../Host/JSONTransportTestUtilities.h | 96 - 18 files changed, 1170 insertions(+), 578 deletions(-) diff --git a/lldb/include/lldb/Host/JSONTransport.h b/lldb/include/lldb/Host/JSONTransport.h index 210f33edace6e..da1ae43118538 100644 --- a/lldb/include/lldb/Host/JSONTransport.h +++ b/lldb/include/lldb/Host/JSONTransport.h @@ -18,6 +18,7 @@ #include "lldb/Utility/IOObject.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-forward.h" +#include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" @@ -25,8 +26,13 @@ #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/JSON.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include #include #include +#include +#include #include #include @@ -50,17 +56,70 @@ class TransportUnhandledContentsError std::string m_unhandled_contents; }; +class InvalidParams : public llvm::ErrorInfo { +public: + static char ID; + + explicit InvalidParams(std::string method, std::string context) + : m_method(std::move(method)), m_context(std::move(context)) {} + + void log(llvm::raw_ostream &OS) const override; + std::error_code convertToErrorCode() const override; + +private: + std::string m_method; + std::string m_context; +}; + +// Value for tracking functions that have a void param or result. +using VoidT = std::monostate; + +template using Callback = llvm::unique_function; + +template +using Reply = typename std::conditional< +std::is_same_v == true, llvm::unique_function, +llvm::unique_function)>>::type; + +template +using OutgoingRequest = typename std::conditional< +std::is_same_v == true, +llvm::unique_function)>, +llvm::unique_function)>>::type; + +template +using OutgoingEvent = typename std::conditional< +std::is_same_v == true, llvm::unique_function, +llvm::unique_function>::type; + +template +Req make_request(Id id, llvm::StringRef method, + std::optional params = std::nullopt); +template +Resp make_response(const Req &req, llvm::Error error); +template +Resp make_response(const Req &req, llvm::json::Value result); +template +Evt make_event(llvm::StringRef method, + std::optional params = std::nullopt); +template +llvm::Expected get_result(const Resp &resp); +template Id get_id(const T &); +template llvm::StringRef get_method(const T &); +template llvm::json::Value get_params(const T &); + /// A transport is responsible for maintaining the connection to a client /// application, and reading/writing structured messages to it. /// /// Transports have limited thread safety requirements: /// - Messages will not be sent concurrently. /// - Messages MAY be sent while Run() is reading, or its callback is active. -template class Transport { +template +class JSONTransport { public: using Message = std::variant; - virtual ~Transport() = default; + virtual ~JSONTransport() = default; /// Sends an event, a message that does not require a response. virtual llvm::Error Send(const Evt &) = 0; @@ -90,8 +149,6 @@ template class Transport { virtual void OnClosed() = 0; }; - using MessageHandlerSP = std::shared_ptr; - /// RegisterMessageHandler registers the Transport with the given MainLoop and /// handles any incoming messages using the given MessageHandler. /// @@ -100,22 +157,302 @@ template class T