[Lldb-commits] [lldb] [lldb-dap] Add stdio redirection (PR #158609)
https://github.com/walter-erquinigo edited 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)
@@ -624,3 +625,23 @@ 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. +""" +temp_file = tempfile.NamedTemporaryFile().name walter-erquinigo wrote: Use this pattern ``` with tempfile.TemporaryFile() as fp: ... ``` that way you don't need to unlink the file manually 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] ec8819f - [lldb-mcp] Adding a tool to list debuggers again. (#158340)
Author: John Harrison Date: 2025-09-15T09:43:10-07:00 New Revision: ec8819f1858a67cff20ca47e0cbfa11e292c989f URL: https://github.com/llvm/llvm-project/commit/ec8819f1858a67cff20ca47e0cbfa11e292c989f DIFF: https://github.com/llvm/llvm-project/commit/ec8819f1858a67cff20ca47e0cbfa11e292c989f.diff LOG: [lldb-mcp] Adding a tool to list debuggers again. (#158340) This brings back the tool for listing debuggers. This is helpful when an LLM doesn't support resources, like gemini-cli. I also fixed an issue with `ServerInfoHandle` not always cleaning up the `~/lldb/lldb-mcp-.json` file correctly. Added: Modified: lldb/include/lldb/Protocol/MCP/Server.h lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp lldb/source/Plugins/Protocol/MCP/Tool.cpp lldb/source/Plugins/Protocol/MCP/Tool.h lldb/source/Protocol/MCP/Server.cpp Removed: diff --git a/lldb/include/lldb/Protocol/MCP/Server.h b/lldb/include/lldb/Protocol/MCP/Server.h index b674d58159550..1f916ae525b5c 100644 --- a/lldb/include/lldb/Protocol/MCP/Server.h +++ b/lldb/include/lldb/Protocol/MCP/Server.h @@ -108,8 +108,7 @@ bool fromJSON(const llvm::json::Value &, ServerInfo &, llvm::json::Path); /// once it is no longer referenced. class ServerInfoHandle { public: - ServerInfoHandle(); - explicit ServerInfoHandle(llvm::StringRef filename); + explicit ServerInfoHandle(llvm::StringRef filename = ""); ~ServerInfoHandle(); ServerInfoHandle(ServerInfoHandle &&other); @@ -121,6 +120,9 @@ class ServerInfoHandle { ServerInfoHandle &operator=(const ServerInfoHandle &) = delete; /// @} + /// Remove the file. + void Remove(); + private: llvm::SmallString<128> m_filename; }; diff --git a/lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp b/lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp index dc18c8e06803a..d3af3cf25c4a1 100644 --- a/lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp +++ b/lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp @@ -10,8 +10,6 @@ #include "Resource.h" #include "Tool.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Host/FileSystem.h" -#include "lldb/Host/HostInfo.h" #include "lldb/Protocol/MCP/Server.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" @@ -60,7 +58,9 @@ void ProtocolServerMCP::Extend(lldb_protocol::mcp::Server &server) const { "MCP initialization complete"); }); server.AddTool( - std::make_unique("lldb_command", "Run an lldb command.")); + std::make_unique("command", "Run an lldb command.")); + server.AddTool(std::make_unique( + "debugger_list", "List debugger instances with their debugger_id.")); server.AddResourceProvider(std::make_unique()); } @@ -145,8 +145,8 @@ llvm::Error ProtocolServerMCP::Stop() { if (m_loop_thread.joinable()) m_loop_thread.join(); + m_server_info_handle.Remove(); m_listen_handlers.clear(); - m_server_info_handle = ServerInfoHandle(); m_instances.clear(); return llvm::Error::success(); diff --git a/lldb/source/Plugins/Protocol/MCP/Tool.cpp b/lldb/source/Plugins/Protocol/MCP/Tool.cpp index 2f451bf76e81d..cb134b965c2e2 100644 --- a/lldb/source/Plugins/Protocol/MCP/Tool.cpp +++ b/lldb/source/Plugins/Protocol/MCP/Tool.cpp @@ -7,26 +7,36 @@ //===--===// #include "Tool.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Protocol/MCP/Protocol.h" +#include "lldb/Utility/UriParser.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Error.h" +#include +#include using namespace lldb_private; using namespace lldb_protocol; using namespace lldb_private::mcp; +using namespace lldb; using namespace llvm; namespace { + +static constexpr StringLiteral kSchemeAndHost = "lldb-mcp://debugger/"; + struct CommandToolArguments { - uint64_t debugger_id; - std::string arguments; + /// Either an id like '1' or a uri like 'lldb-mcp://debugger/1'. + std::string debugger; + std::string command; }; -bool fromJSON(const llvm::json::Value &V, CommandToolArguments &A, - llvm::json::Path P) { - llvm::json::ObjectMapper O(V, P); - return O && O.map("debugger_id", A.debugger_id) && - O.mapOptional("arguments", A.arguments); +bool fromJSON(const json::Value &V, CommandToolArguments &A, json::Path P) { + json::ObjectMapper O(V, P); + return O && O.mapOptional("debugger", A.debugger) && + O.mapOptional("command", A.command); } /// Helper function to create a CallToolResult from a string output. @@ -39,9 +49,13 @@ createTextResult(std::string output, bool is_error = false) { return text_result; } +std::string to_uri(DebuggerSP debugger) { + return (kSchemeAndHost + std::to_st
[Lldb-commits] [lldb] [lldb-mcp] Adding a tool to list debuggers again. (PR #158340)
https://github.com/ashgti closed https://github.com/llvm/llvm-project/pull/158340 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [Clang][PowerPC] Add __dmr2048 type and DMF crypto builtins (PR #157152)
https://github.com/lei137 edited https://github.com/llvm/llvm-project/pull/157152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [Clang][PowerPC] Add __dmr2048 type and DMF crypto builtins (PR #157152)
@@ -17,6 +17,8 @@ // are correctly defined. We also added checks on a couple of other targets to // ensure the types are target-dependent. +// CHECK: TypedefDecl {{.*}} implicit __dmr2048 '__dmr2048' +// CHECK: `-BuiltinType {{.*}} '__dmr2048' lei137 wrote: nit: indent is off. https://github.com/llvm/llvm-project/pull/157152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [Clang][PowerPC] Add __dmr2048 type and DMF crypto builtins (PR #157152)
@@ -1123,6 +1123,13 @@ UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvbf16ger2, "vW512*VV", UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3", "mma,paired-vector-memops") +UNALIASED_CUSTOM_BUILTIN(mma_dmsha2hash, "vW1024*W1024*Ii", true, + "mma,isa-future-instructions") +UNALIASED_CUSTOM_BUILTIN(mma_dmsha3hash, "vW2048*Ii", true, + "mma,isa-future-instructions") +UNALIASED_CUSTOM_BUILTIN(mma_dmxxshapad, "vW1024*VIiIiIi", true, lei137 wrote: It would be good to keep these with the other "CUSTOM_BUILTIN(mma*" are defined. After 1106. https://github.com/llvm/llvm-project/pull/157152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [Clang][PowerPC] Add __dmr2048 type and DMF crypto builtins (PR #157152)
https://github.com/lei137 commented: I see a lot of tests to identify when this type is not valid I think it would be good to add to the PR description where/how this new type can be used. https://github.com/llvm/llvm-project/pull/157152 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [Clang] [Sema] Make `-Wincompatible-pointer-types` an error by default (PR #157364)
asb wrote: > Looks like this is causing errors in llvm-testsuite, but I’m candidly not > sure how this is usually handled: > https://lab.llvm.org/buildbot/#/builders/210/builds/2746 I think we'll want to add `-Wno-incompatible-pointer-types` to the relevant CMakeLists.txt. As an example, we can see @AaronBallman making such changes around https://github.com/llvm/llvm-test-suite/commits/099fc20d7e352f51d7c76a5d89fecbd15d7fae5e for the `-Wimplicit-int` change. https://github.com/llvm/llvm-project/pull/157364 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [Clang] [Sema] Make `-Wincompatible-pointer-types` an error by default (PR #157364)
Sirraide wrote: > I think we'll want to add `-Wno-incompatible-pointer-types` to the relevant > CMakeLists.txt. Thanks; I’ll look into it. https://github.com/llvm/llvm-project/pull/157364 ___ 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/2] [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] 9b95e10 - [LLDB] [Tests] Downgrade -Wincompatible-pointer-types to a warning in some tests (#158756)
Author: Sirraide Date: 2025-09-16T02:02:01+02:00 New Revision: 9b95e10d5ea6b61e0d9af0a800d63566ae32a2d0 URL: https://github.com/llvm/llvm-project/commit/9b95e10d5ea6b61e0d9af0a800d63566ae32a2d0 DIFF: https://github.com/llvm/llvm-project/commit/9b95e10d5ea6b61e0d9af0a800d63566ae32a2d0.diff LOG: [LLDB] [Tests] Downgrade -Wincompatible-pointer-types to a warning in some tests (#158756) These no longer compile because the warning now defaults to an error after #157364, so downgrade the error to a warning for now; I’m not familiar enough with either LLDB or MacOS to fix these warnings properly (assuming they’re unintended). Added: Modified: lldb/test/API/functionalities/data-formatter/data-formatter-objc/Makefile lldb/test/API/macosx/ignore_exceptions/Makefile Removed: diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/Makefile index 8b322ff320bb0..5ef65e0c08451 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/Makefile @@ -1,6 +1,6 @@ OBJC_SOURCES := main.m -CFLAGS_EXTRAS := -w +CFLAGS_EXTRAS := -w -Wno-error=incompatible-pointer-types diff --git a/lldb/test/API/macosx/ignore_exceptions/Makefile b/lldb/test/API/macosx/ignore_exceptions/Makefile index 695335e068c0c..14ed92da5296b 100644 --- a/lldb/test/API/macosx/ignore_exceptions/Makefile +++ b/lldb/test/API/macosx/ignore_exceptions/Makefile @@ -1,4 +1,4 @@ C_SOURCES := main.c -CFLAGS_EXTRAS := -std=c99 +CFLAGS_EXTRAS := -std=c99 -Wno-error=incompatible-pointer-types include Makefile.rules ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] [Tests] Downgrade -Wincompatible-pointer-types to a warning in some tests (PR #158756)
https://github.com/medismailben approved this pull request. https://github.com/llvm/llvm-project/pull/158756 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/API] Mark SBValue with error as invalid (PR #158759)
https://github.com/medismailben updated https://github.com/llvm/llvm-project/pull/158759 >From b204ad16b8584a796585fb376b5258e3240fa71b Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Mon, 15 Sep 2025 18:09:34 -0700 Subject: [PATCH] [lldb/API] Mark SBValue with error as invalid This patch fixes the return value of `SBValue::IsValid` if `GetError` returns a failing `SBError`. That alignes better the expectation that an `SBValue` is invalid if it has an error. Signed-off-by: Med Ismail Bennani --- lldb/source/API/SBValue.cpp | 3 ++- .../expression/call-throws/TestCallThatThrows.py | 11 +++ .../expression/context-object/TestContextObject.py| 10 +- .../test/API/commands/expression/fixits/TestFixIts.py | 2 +- .../commands/expression/options/TestExprOptions.py| 4 ++-- .../expression/scoped_enums/TestScopedEnumType.py | 4 ++-- .../expression/timeout/TestCallWithTimeout.py | 2 +- .../python_api/sbvalue_is_valid/TestSBValueIsValid.py | 3 +++ lldb/test/API/python_api/sbvalue_is_valid/main.cpp| 7 +++ 9 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 lldb/test/API/python_api/sbvalue_is_valid/TestSBValueIsValid.py create mode 100644 lldb/test/API/python_api/sbvalue_is_valid/main.cpp diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index e300ecee3f8ac..77cc7d1681829 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -97,7 +97,8 @@ class ValueImpl { // they depend on. So I have no good way to make that check without // tracking that in all the ValueObject subclasses. TargetSP target_sp = m_valobj_sp->GetTargetSP(); - return target_sp && target_sp->IsValid(); + return target_sp && target_sp->IsValid() && + m_valobj_sp->GetError().Success(); } } diff --git a/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py b/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py index 0090513864cd7..4d5e5a36eb72a 100644 --- a/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py +++ b/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py @@ -45,7 +45,7 @@ def call_function(self): self.orig_frame_pc = frame.GetPC() value = frame.EvaluateExpression("[my_class callMeIThrow]", options) -self.assertTrue(value.IsValid()) +self.assertFalse(value.IsValid()) self.assertFalse(value.GetError().Success()) self.check_after_call() @@ -61,7 +61,8 @@ def call_function(self): value = frame.EvaluateExpression("[my_class callMeIThrow]", options) -self.assertTrue(value.IsValid() and not value.GetError().Success()) +self.assertFalse(value.IsValid()) +self.assertFalse(value.GetError().Success()) self.check_after_call() # Now set the ObjC language breakpoint and make sure that doesn't @@ -76,7 +77,8 @@ def call_function(self): value = frame.EvaluateExpression("[my_class callMeIThrow]", options) -self.assertTrue(value.IsValid() and not value.GetError().Success()) +self.assertFalse(value.IsValid()) +self.assertFalse(value.GetError().Success()) self.check_after_call() # Now turn off exception trapping, and call a function that catches the exceptions, @@ -95,5 +97,6 @@ def call_function(self): options.SetUnwindOnError(False) value = frame.EvaluateExpression("[my_class callMeIThrow]", options) -self.assertTrue(value.IsValid() and not value.GetError().Success()) +self.assertFalse(value.IsValid()) +self.assertFalse(value.GetError().Success()) self.check_after_call() diff --git a/lldb/test/API/commands/expression/context-object/TestContextObject.py b/lldb/test/API/commands/expression/context-object/TestContextObject.py index 1ed629a42c1ee..f3b2c3a503592 100644 --- a/lldb/test/API/commands/expression/context-object/TestContextObject.py +++ b/lldb/test/API/commands/expression/context-object/TestContextObject.py @@ -69,7 +69,7 @@ def test_context_object(self): # Test an expression evaluation value = obj_val.EvaluateExpression("1") -self.assertTrue(value.IsValid()) +self.assertFalse(value.IsValid()) self.assertFalse(value.GetError().Success()) # @@ -81,7 +81,7 @@ def test_context_object(self): # Test an expression evaluation value = obj_val.EvaluateExpression("1") -self.assertTrue(value.IsValid()) +self.assertFalse(value.IsValid()) self.assertFalse(value.GetError().Success()) # Test retrieveing of an element's field @@ -99,7 +99,7 @@ def test_context_object(self): # Test an expression evaluation value = obj_val.EvaluateExpression("1") -self.assertTrue(value.IsValid()) +self.assertFalse(value.IsValid()) self
[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(); clayborg wrote: Do we want to make a `constexpr` with variable names for this instead of using magic numbers? I was thinking something like: ``` static constexpr uint32_t kCIEMarker32 = std::numeric_limits::max(); static constexpr uint64_t kCIEMarker64 = std::numeric_limits::max(); ``` And then use these everywhere that we were using magic numbers? 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][test] Fix unordered-map test. (PR #158286)
https://github.com/da-viper closed https://github.com/llvm/llvm-project/pull/158286 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5e118ec - [lldb][test] Fix unordered-map test. (#158286)
Author: Ebuka Ezike Date: 2025-09-15T15:21:56+01:00 New Revision: 5e118eca93ad7591c7b904a160d4d42cd37903c5 URL: https://github.com/llvm/llvm-project/commit/5e118eca93ad7591c7b904a160d4d42cd37903c5 DIFF: https://github.com/llvm/llvm-project/commit/5e118eca93ad7591c7b904a160d4d42cd37903c5.diff LOG: [lldb][test] Fix unordered-map test. (#158286) The build step is overidden so it uses `libstdc++` instead of `libc++` on linux Added: Modified: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py Removed: 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] [lldb] Fix unordered-map data formatter for const types (PR #156033)
https://github.com/da-viper closed https://github.com/llvm/llvm-project/pull/156033 ___ 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)
@@ -177,6 +177,31 @@ llvm::Error BaseRequestHandler::LaunchProcess( launch_info.SetEnvironment(env, true); } + if (!arguments.stdio.empty() && !arguments.disableSTDIO) { walter-erquinigo wrote: Move this to a helper function because this function is already very big 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)
@@ -615,6 +615,14 @@ "description": "Specify where to launch the program: internal console, integrated terminal or external terminal.", "default": "internalConsole" }, + "stdio": { +"type": "array", +"items": { + "type": "string" +}, +"description": "Destination for program stdio streams (0 - stdin, 1 - stdout, 2 - stderr, ...). Using null value means no redirection.", walter-erquinigo wrote: Same here about ``` The stdio property is a list of redirection targets for each of the debuggee's stdio streams: null value will cause redirect to the default debug session terminal (as specified by the terminal launch property), "/some/path" will cause the stream to be redirected to the specified file, pipe or a TTY device*, if you provide less than 3 values, the list will be padded to 3 entries using the last provided value, you may specify more than three values, in which case additional file descriptors will be created (4, 5, etc.) Examples: "stdio": [null, "log.txt", null] - connect stdin and stderr to the default terminal, while sending stdout to "log.txt", "stdio": ["input.txt", "log.txt"] - connect stdin to "input.txt", while sending both stdout and stderr to "log.txt", "stdio": null - connect all three streams to the default terminal. ``` 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/walter-erquinigo requested changes to this pull request. Thanks for working on this! 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][TypeSystem] Enable colored AST dump (PR #86159)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/86159 ___ 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-dap] Add stdio redirection (PR #158609)
https://github.com/DrSergei created https://github.com/llvm/llvm-project/pull/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). >From 4c3e0090328b35fb8d0d92df3bd5378d9d811047 Mon Sep 17 00:00:00 2001 From: Druzhkov Sergei Date: Mon, 15 Sep 2025 10:49:44 +0300 Subject: [PATCH] [lldb-dap] Add stdio redirection --- .../test/tools/lldb-dap/dap_server.py | 3 +++ .../tools/lldb-dap/launch/TestDAP_launch.py | 21 .../tools/lldb-dap/Handler/RequestHandler.cpp | 25 +++ .../lldb-dap/Protocol/ProtocolRequests.cpp| 3 ++- .../lldb-dap/Protocol/ProtocolRequests.h | 2 ++ lldb/tools/lldb-dap/README.md | 1 + lldb/tools/lldb-dap/package.json | 8 ++ 7 files changed, 62 insertions(+), 1 deletion(-) 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 22fcd42b3d36a..a301e00f6755f 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 @@ -624,3 +625,23 @@ 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. +""" +temp_file = tempfile.NamedTemporaryFile().name +self.build_and_create_debug_adapter() +program = self.getBuildArtifact("a.out") + +self.launch(program, stdio=[None, temp_file, None]) +self.continue_to_exit() + +try: +with open(temp_file, "r") as f: +lines = f.readlines() +self.assertIn( +program, lines[0], "make sure program path is in first argument" +) +finally: +pathlib.Path(temp_file).unlink(missing_ok=True) diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp index 4fadf1c22e0e3..4b727e1e33a64 100644 --- a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp @@ -177,6 +177,31 @@ llvm::Error BaseRequestHandler::LaunchProcess( launch_info.SetEnvironment(env, true); } + if (!arguments.stdio.empty() && !arguments.disableSTDIO) { +size_t n = std::max(arguments.stdio.size(), static_cast(3)); +for (size_t i = 0; i < n; i++) { + std::optional path; + if (arguments.stdio.size() < i) +path = arguments.stdio.back(); + else +path = arguments.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; + } +} + } + 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.cpp +++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp @@ -303,7 +303,8 @@ bool fromJSON(const json::Value &Params, LaunchRequestArguments &LRA, O.mapOptional("disableSTDIO", LRA.disableSTDIO) && O.mapOptional("shellExpandAr
[Lldb-commits] [lldb] [lldb][TypeSystemClang] Added unique builtins types for __bf16 and _Float16 (PR #157674)
tgs-sc wrote: @Michael137, take a look please! 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] Change directory creation logic in framework-header-fix (PR #158355)
https://github.com/bulbazord closed https://github.com/llvm/llvm-project/pull/158355 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [Clang] [Sema] Make `-Wincompatible-pointer-types` an error by default (PR #157364)
Sirraide wrote: > > This seems to have broken several tests several tests in the LLDB test > > suite: > > https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/33215/ > > Weird, I’m pretty sure I ran the LLDB tests locally and didn’t observe any > errors; I’m looking into it. Should be fixed by #158756. https://github.com/llvm/llvm-project/pull/157364 ___ 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)
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/Plugins/ObjectFile/ELF/ObjectFileELF.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/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 45c8f0ac2..406d7d0df 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2122,7 +2122,7 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, // LoongArch64 always uses symbols for relocations, so temporary symbols // starting with ".L" should be preserved. if (llvm::StringRef(symbol_name).starts_with(".L") && - arch.GetMachine() != llvm::Triple::loongarch64) +arch.GetMachine() != llvm::Triple::loongarch64) continue; // No need to add non-section symbols that have no names if (symbol.getType() != STT_SECTION && `` 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] [LLDB][PDB] Require Windows for for testing PDB plugin-selection again (PR #158559)
https://github.com/Nerixyz created https://github.com/llvm/llvm-project/pull/158559 Amends #158284 and fixes the failure on `lldb-remote-linux-win` from https://github.com/llvm/llvm-project/pull/158284#issuecomment-3290154510. That builder is configured with the DIA SDK but builds for Linux, so the debug information will be DWARF, not PDB. >From a2ac9c95e60f3e1a1838b773128cd184dd05a119 Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Mon, 15 Sep 2025 09:19:36 +0200 Subject: [PATCH] [LLDB][PDB] Require Windows for for testing PDB plugin-selection again --- lldb/test/Shell/SymbolFile/PDB/native-setting.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp index edf7508b88f17..a3077252f08f1 100644 --- a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp +++ b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp @@ -1,4 +1,4 @@ -// REQUIRES: diasdk +// REQUIRES: diasdk, target-windows // Test plugin.symbol-file.pdb.reader setting // RUN: %build -o %t.exe -- %s ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][PDB] Require Windows for for testing PDB plugin-selection again (PR #158559)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: nerix (Nerixyz) Changes Amends #158284 and fixes the failure on `lldb-remote-linux-win` from https://github.com/llvm/llvm-project/pull/158284#issuecomment-3290154510. That builder is configured with the DIA SDK but builds for Linux, so the debug information will be DWARF, not PDB. --- Full diff: https://github.com/llvm/llvm-project/pull/158559.diff 1 Files Affected: - (modified) lldb/test/Shell/SymbolFile/PDB/native-setting.cpp (+1-1) ``diff diff --git a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp index edf7508b88f17..a3077252f08f1 100644 --- a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp +++ b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp @@ -1,4 +1,4 @@ -// REQUIRES: diasdk +// REQUIRES: diasdk, target-windows // Test plugin.symbol-file.pdb.reader setting // RUN: %build -o %t.exe -- %s `` https://github.com/llvm/llvm-project/pull/158559 ___ 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)
@@ -2119,8 +2119,12 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, // generated local labels used for internal purposes (e.g. debugging, // optimization) and are not relevant for symbol resolution or external // linkage. -if (llvm::StringRef(symbol_name).starts_with(".L")) - continue; +// LoongArch64 always uses symbols for relocations, so temporary symbols +// starting with ".L" should be preserved. +if (arch.GetMachine() != llvm::Triple::loongarch64) { + if (llvm::StringRef(symbol_name).starts_with(".L")) +continue; +} SixWeining wrote: ```suggestion // LoongArch64 always uses symbols for relocations, so temporary symbols // starting with ".L" should be preserved. if (llvm::StringRef(symbol_name).starts_with(".L") && arch.GetMachine() != llvm::Triple::loongarch64) continue; ``` 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] [LLDB][PDB] Require Windows for for testing PDB plugin-selection again (PR #158559)
https://github.com/Nerixyz closed https://github.com/llvm/llvm-project/pull/158559 ___ 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)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Druzhkov Sergei (DrSergei) Changes 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). --- Full diff: https://github.com/llvm/llvm-project/pull/158609.diff 7 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py (+3) - (modified) lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py (+21) - (modified) lldb/tools/lldb-dap/Handler/RequestHandler.cpp (+25) - (modified) lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp (+2-1) - (modified) lldb/tools/lldb-dap/Protocol/ProtocolRequests.h (+2) - (modified) lldb/tools/lldb-dap/README.md (+1) - (modified) lldb/tools/lldb-dap/package.json (+8) ``diff 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 22fcd42b3d36a..a301e00f6755f 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 @@ -624,3 +625,23 @@ 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. +""" +temp_file = tempfile.NamedTemporaryFile().name +self.build_and_create_debug_adapter() +program = self.getBuildArtifact("a.out") + +self.launch(program, stdio=[None, temp_file, None]) +self.continue_to_exit() + +try: +with open(temp_file, "r") as f: +lines = f.readlines() +self.assertIn( +program, lines[0], "make sure program path is in first argument" +) +finally: +pathlib.Path(temp_file).unlink(missing_ok=True) diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp index 4fadf1c22e0e3..4b727e1e33a64 100644 --- a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp +++ b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp @@ -177,6 +177,31 @@ llvm::Error BaseRequestHandler::LaunchProcess( launch_info.SetEnvironment(env, true); } + if (!arguments.stdio.empty() && !arguments.disableSTDIO) { +size_t n = std::max(arguments.stdio.size(), static_cast(3)); +for (size_t i = 0; i < n; i++) { + std::optional path; + if (arguments.stdio.size() < i) +path = arguments.stdio.back(); + else +path = arguments.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; + } +} + } + 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.cpp +++ b/lldb/tools/lldb-dap/Protocol/ProtocolRequests.cpp @@ -303,7 +303,8 @@ bool fromJSON(const json::Value &Params, LaunchRequestArguments &LRA, O.mapOptional("disableSTDIO", LRA.disableSTDIO) && O.mapOptional("shellExpandArguments", LRA.shellExpandArguments) && O.mapOptional("runInTerminal", LRA
[Lldb-commits] [lldb] [lldb][LoongArch] Preserve temporary symbols starting with `.L` in lldb symbol table (PR #158551)
SixWeining wrote: cc @barsolo2000 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] [LLDB][PDB] Require Windows for for testing PDB plugin-selection again (PR #158559)
https://github.com/DavidSpickett approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/158559 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [Clang] [Sema] Make `-Wincompatible-pointer-types` an error by default (PR #157364)
medismailben wrote: Thanks, feel free to merge whenever https://github.com/llvm/llvm-project/pull/157364 ___ 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/walter-erquinigo 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] 4de9bee - [LLDB][PDB] Require Windows for for testing PDB plugin-selection again (#158559)
Author: nerix Date: 2025-09-15T11:07:42+02:00 New Revision: 4de9bee7e53eb84a22511317e26dfd656b66df8b URL: https://github.com/llvm/llvm-project/commit/4de9bee7e53eb84a22511317e26dfd656b66df8b DIFF: https://github.com/llvm/llvm-project/commit/4de9bee7e53eb84a22511317e26dfd656b66df8b.diff LOG: [LLDB][PDB] Require Windows for for testing PDB plugin-selection again (#158559) Amends #158284 and fixes the failure on `lldb-remote-linux-win` from https://github.com/llvm/llvm-project/pull/158284#issuecomment-3290154510. That builder is configured with the DIA SDK but builds for Linux, so the debug information will be DWARF, not PDB. Added: Modified: lldb/test/Shell/SymbolFile/PDB/native-setting.cpp Removed: diff --git a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp index edf7508b88f17..a3077252f08f1 100644 --- a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp +++ b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp @@ -1,4 +1,4 @@ -// REQUIRES: diasdk +// REQUIRES: diasdk, target-windows // Test plugin.symbol-file.pdb.reader setting // RUN: %build -o %t.exe -- %s ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [Clang] [Sema] Make `-Wincompatible-pointer-types` an error by default (PR #157364)
Sirraide wrote: Looks like this is causing errors in llvm-testsuite, but I’m candidly not sure how this is usually handled: https://lab.llvm.org/buildbot/#/builders/210/builds/2746 https://github.com/llvm/llvm-project/pull/157364 ___ 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/clayborg approved this pull request. Looks good! 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][TypeSystem] Enable colored AST dump (PR #86159)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `lldb-x86_64-debian` running on `lldb-x86_64-debian` while building `lldb` at step 6 "test". Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/31135 Here is the relevant piece of the build log for the reference ``` Step 6 (test) failure: build (failure) ... UNSUPPORTED: lldb-shell :: RPC/Generator/Tests/Server/CheckConstCharPointer.test (3183 of 3192) UNSUPPORTED: lldb-shell :: ScriptInterpreter/Lua/independent_state.test (3184 of 3192) UNSUPPORTED: lldb-shell :: ScriptInterpreter/Python/Crashlog/json.test (3185 of 3192) UNSUPPORTED: lldb-shell :: SymbolFile/NativePDB/typedefs.cpp (3186 of 3192) UNSUPPORTED: lldb-shell :: ScriptInterpreter/Python/Crashlog/interactive_crashlog_json.test (3187 of 3192) PASS: lldb-shell :: Commands/command-image-dump-ast-colored.test (3188 of 3192) PASS: lldb-api :: terminal/TestEditlineCompletions.py (3189 of 3192) PASS: lldb-api :: commands/process/attach/TestProcessAttach.py (3190 of 3192) PASS: lldb-api :: repl/clang/TestClangREPL.py (3191 of 3192) TIMEOUT: lldb-api :: tools/lldb-dap/module/TestDAP_module.py (3192 of 3192) TEST 'lldb-api :: tools/lldb-dap/module/TestDAP_module.py' FAILED Script: -- /usr/bin/python3 /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --env LLVM_INCLUDE_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/include --env LLVM_TOOLS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --arch x86_64 --build-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex --lldb-module-cache-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/lldb --compiler /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/clang --dsymutil /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/worker/2.0.1/lldb-x86_64-debian/build/./bin --lldb-obj-root /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb --lldb-libs-dir /home/worker/2.0.1/lldb-x86_64-debian/build/./lib --cmake-build-type Release -t /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/module -p TestDAP_module.py -- Exit Code: -9 Timeout: Reached timeout of 600 seconds Command Output (stdout): -- lldb version 22.0.0git (https://github.com/llvm/llvm-project.git revision 95d5d984db4092136ad4b178b765516168c31b9e) clang revision 95d5d984db4092136ad4b178b765516168c31b9e llvm revision 95d5d984db4092136ad4b178b765516168c31b9e -- Command Output (stderr): -- Change dir to: /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/tools/lldb-dap/module runCmd: settings clear --all output: runCmd: settings set symbols.enable-external-lookup false output: runCmd: settings set target.inherit-tcc true output: runCmd: settings set target.disable-aslr false output: runCmd: settings set target.detach-on-error false output: runCmd: settings set target.auto-apply-fixits false ``` https://github.com/llvm/llvm-project/pull/86159 ___ 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 created https://github.com/llvm/llvm-project/pull/158701 Adding support for launching lldb with `-O protocol start MCP` if a valid ~/.lldb/lldb-mcp-*.json` file is not found. >From 39b27ffc60fe30e88e42918f2c3382369f06f3df Mon Sep 17 00:00:00 2001 From: John Harrison Date: Mon, 15 Sep 2025 10:30:04 -0700 Subject: [PATCH] [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
[Lldb-commits] [lldb] [lldb-mcp] Launch lldb on demand, if needed. (PR #158701)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: John Harrison (ashgti) Changes Adding support for launching lldb with `-O protocol start MCP` if a valid ~/.lldb/lldb-mcp-*.json` file is not found. --- Full diff: https://github.com/llvm/llvm-project/pull/158701.diff 2 Files Affected: - (modified) lldb/source/Host/common/Socket.cpp (+1-1) - (modified) lldb/tools/lldb-mcp/lldb-mcp.cpp (+91-31) ``diff 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(lldb_private::MainLoopBase &loop, lldb::IOObjectSP &from, - lldb::IOObjectSP &to) { +void forwardIO(MainLoopBase &loop, IOObjectSP &from,
[Lldb-commits] [lldb] [lldb-mcp] Adding a tool to list debuggers again. (PR #158340)
ashgti wrote: I filed #158676 for the index issue so we don't loose track of it. https://github.com/llvm/llvm-project/pull/158340 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-mcp] Adding a tool to list debuggers again. (PR #158340)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/158340 >From aab75bdd91f15a3dde3a6ac9fbf7804461fa8951 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Fri, 12 Sep 2025 11:10:31 -0700 Subject: [PATCH 1/2] [lldb-mcp] Adding a tool to list debuggers again. This brings back the tool for listing debuggers. This is helpful when an LLM doesn't support resources, like gemini-cli. --- lldb/include/lldb/Protocol/MCP/Server.h | 6 +- .../Protocol/MCP/ProtocolServerMCP.cpp| 8 +- lldb/source/Plugins/Protocol/MCP/Tool.cpp | 106 ++ lldb/source/Plugins/Protocol/MCP/Tool.h | 9 ++ lldb/source/Protocol/MCP/Server.cpp | 26 ++--- 5 files changed, 111 insertions(+), 44 deletions(-) diff --git a/lldb/include/lldb/Protocol/MCP/Server.h b/lldb/include/lldb/Protocol/MCP/Server.h index b674d58159550..1f916ae525b5c 100644 --- a/lldb/include/lldb/Protocol/MCP/Server.h +++ b/lldb/include/lldb/Protocol/MCP/Server.h @@ -108,8 +108,7 @@ bool fromJSON(const llvm::json::Value &, ServerInfo &, llvm::json::Path); /// once it is no longer referenced. class ServerInfoHandle { public: - ServerInfoHandle(); - explicit ServerInfoHandle(llvm::StringRef filename); + explicit ServerInfoHandle(llvm::StringRef filename = ""); ~ServerInfoHandle(); ServerInfoHandle(ServerInfoHandle &&other); @@ -121,6 +120,9 @@ class ServerInfoHandle { ServerInfoHandle &operator=(const ServerInfoHandle &) = delete; /// @} + /// Remove the file. + void Remove(); + private: llvm::SmallString<128> m_filename; }; diff --git a/lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp b/lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp index dc18c8e06803a..d3af3cf25c4a1 100644 --- a/lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp +++ b/lldb/source/Plugins/Protocol/MCP/ProtocolServerMCP.cpp @@ -10,8 +10,6 @@ #include "Resource.h" #include "Tool.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Host/FileSystem.h" -#include "lldb/Host/HostInfo.h" #include "lldb/Protocol/MCP/Server.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" @@ -60,7 +58,9 @@ void ProtocolServerMCP::Extend(lldb_protocol::mcp::Server &server) const { "MCP initialization complete"); }); server.AddTool( - std::make_unique("lldb_command", "Run an lldb command.")); + std::make_unique("command", "Run an lldb command.")); + server.AddTool(std::make_unique( + "debugger_list", "List debugger instances with their debugger_id.")); server.AddResourceProvider(std::make_unique()); } @@ -145,8 +145,8 @@ llvm::Error ProtocolServerMCP::Stop() { if (m_loop_thread.joinable()) m_loop_thread.join(); + m_server_info_handle.Remove(); m_listen_handlers.clear(); - m_server_info_handle = ServerInfoHandle(); m_instances.clear(); return llvm::Error::success(); diff --git a/lldb/source/Plugins/Protocol/MCP/Tool.cpp b/lldb/source/Plugins/Protocol/MCP/Tool.cpp index 2f451bf76e81d..7250ed3a5518d 100644 --- a/lldb/source/Plugins/Protocol/MCP/Tool.cpp +++ b/lldb/source/Plugins/Protocol/MCP/Tool.cpp @@ -7,26 +7,34 @@ //===--===// #include "Tool.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Protocol/MCP/Protocol.h" +#include "lldb/Utility/UriParser.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Error.h" +#include +#include using namespace lldb_private; using namespace lldb_protocol; using namespace lldb_private::mcp; +using namespace lldb; using namespace llvm; namespace { + struct CommandToolArguments { - uint64_t debugger_id; - std::string arguments; + /// Either an id like '1' or a uri like 'lldb://sessions/1'. + std::string debugger; + std::string command; }; -bool fromJSON(const llvm::json::Value &V, CommandToolArguments &A, - llvm::json::Path P) { - llvm::json::ObjectMapper O(V, P); - return O && O.map("debugger_id", A.debugger_id) && - O.mapOptional("arguments", A.arguments); +bool fromJSON(const json::Value &V, CommandToolArguments &A, json::Path P) { + json::ObjectMapper O(V, P); + return O && O.mapOptional("debugger", A.debugger) && + O.mapOptional("command", A.command); } /// Helper function to create a CallToolResult from a string output. @@ -39,9 +47,15 @@ createTextResult(std::string output, bool is_error = false) { return text_result; } +static constexpr StringLiteral kSchemeAndHost = "lldb-mcp://debugger/"; + +std::string to_uri(DebuggerSP debugger) { + return (kSchemeAndHost + std::to_string(debugger->GetID())).str(); +} + } // namespace -llvm::Expected +Expected CommandTool::Call(const lldb_protocol::mcp::ToolArguments &args) { if (!std::holds_alternative(args)) return cr
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [Clang] [Sema] Make `-Wincompatible-pointer-types` an error by default (PR #157364)
https://github.com/Sirraide closed https://github.com/llvm/llvm-project/pull/157364 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 95d5d98 - [lldb][TypeSystem] Enable colored AST dump (#86159)
Author: Michael Buch Date: 2025-09-15T18:03:55+01:00 New Revision: 95d5d984db4092136ad4b178b765516168c31b9e URL: https://github.com/llvm/llvm-project/commit/95d5d984db4092136ad4b178b765516168c31b9e DIFF: https://github.com/llvm/llvm-project/commit/95d5d984db4092136ad4b178b765516168c31b9e.diff LOG: [lldb][TypeSystem] Enable colored AST dump (#86159) This patch causes the various AST dump commands (`target modules dump ast`/`target dump typesystem`) to be color-highlighted. I added a `bool show_color` parameter to `SymbolFile::DumpClangAST` and `TypeSystem::Dump`. In `TypeSystemClang` I temporarily sets the `getShowColors` flag on the owned Clang AST (using an RAII helper) for the duration of the AST dump. We use `Debugger::GetUseColors` to decide whether to color the AST dump. Added: lldb/test/Shell/Commands/command-image-dump-ast-colored.test Modified: lldb/include/lldb/Symbol/SymbolFile.h lldb/include/lldb/Symbol/SymbolFileOnDemand.h lldb/include/lldb/Symbol/TypeSystem.h lldb/source/Commands/CommandObjectTarget.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h lldb/source/Symbol/SymbolFileOnDemand.cpp Removed: diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index ff67e002e5b02..3b4d7bc01d132 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -297,7 +297,8 @@ class SymbolFile : public PluginInterface { lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); - virtual void DumpClangAST(Stream &s, llvm::StringRef filter) {} + virtual void DumpClangAST(Stream &s, llvm::StringRef filter, +bool show_colors) {} virtual void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, diff --git a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h index 6e3c2477d1769..b376de73419d4 100644 --- a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h +++ b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h @@ -127,7 +127,8 @@ class SymbolFileOnDemand : public lldb_private::SymbolFile { lldb_private::SymbolContextList &sc_list) override; void Dump(lldb_private::Stream &s) override; - void DumpClangAST(lldb_private::Stream &s, llvm::StringRef filter) override; + void DumpClangAST(lldb_private::Stream &s, llvm::StringRef filter, +bool show_color) override; void FindGlobalVariables(lldb_private::ConstString name, diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index 16a2e0b5a52fb..0ec3a28898329 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -448,7 +448,9 @@ class TypeSystem : public PluginInterface, /// \param[out] output Stream to dup the AST into. /// \param[in] filter If empty, dump whole AST. If non-empty, will only /// dump decls whose names contain \c filter. - virtual void Dump(llvm::raw_ostream &output, llvm::StringRef filter) = 0; + /// \param[in] show_color If true, prints the AST color-highlighted. + virtual void Dump(llvm::raw_ostream &output, llvm::StringRef filter, +bool show_color) = 0; /// This is used by swift. virtual bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) = 0; diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 004542e3e6aed..0f96fa92a731d 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -2275,7 +2275,8 @@ class CommandObjectTargetModulesDumpClangAST if (INTERRUPT_REQUESTED(GetDebugger(), "Interrupted dumping clang ast")) break; if (SymbolFile *sf = module_sp->GetSymbolFile()) - sf->DumpClangAST(result.GetOutputStream(), filter); + sf->DumpClangAST(result.GetOutputStream(), filter, + GetCommandInterpreter().GetDebugger().GetUseColor()); } result.SetStatu
[Lldb-commits] [lldb] [lldb][TypeSystem] Enable colored AST dump (PR #86159)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/86159 ___ 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)
https://github.com/zhaoqi5 updated https://github.com/llvm/llvm-project/pull/158551 >From c6679a64e9eebaf0c7a5bf96689c9a53dbe33b81 Mon Sep 17 00:00:00 2001 From: Qi Zhao Date: Mon, 15 Sep 2025 14:11:17 +0800 Subject: [PATCH 1/2] [lldb][LoongArch] Preserve temporary symbols starting with `.L` in lldb symbol table LoongArch64 always uses symbols for relocations, so temporary symbols starting with ".L" should be preserved so that relocations in `.debug_info` can be fixed correctly. After this commit, three tests passed: ``` lldb-shell :: SymbolFile/DWARF/anon_class_w_and_wo_export_symbols.ll lldb-shell :: SymbolFile/DWARF/clang-ast-from-dwarf-unamed-and-anon-structs.cpp lldb-shell :: SymbolFile/DWARF/clang-gmodules-type-lookup.c ``` --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 931baf5927a04..0f8bc5fc93e07 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2119,8 +2119,12 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, // generated local labels used for internal purposes (e.g. debugging, // optimization) and are not relevant for symbol resolution or external // linkage. -if (llvm::StringRef(symbol_name).starts_with(".L")) - continue; +// LoongArch64 always uses symbols for relocations, so temporary symbols +// starting with ".L" should be preserved. +if (arch.GetMachine() != llvm::Triple::loongarch64) { + if (llvm::StringRef(symbol_name).starts_with(".L")) +continue; +} // No need to add non-section symbols that have no names if (symbol.getType() != STT_SECTION && (symbol_name == nullptr || symbol_name[0] == '\0')) >From a091f3635bffa3ab37f37232a30fd8563130eb7b Mon Sep 17 00:00:00 2001 From: ZhaoQi Date: Mon, 15 Sep 2025 16:14:44 +0800 Subject: [PATCH 2/2] address comment Co-authored-by: Lu Weining --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 0f8bc5fc93e07..45c8f0ac23e58 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2121,10 +2121,9 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, // linkage. // LoongArch64 always uses symbols for relocations, so temporary symbols // starting with ".L" should be preserved. -if (arch.GetMachine() != llvm::Triple::loongarch64) { - if (llvm::StringRef(symbol_name).starts_with(".L")) -continue; -} +if (llvm::StringRef(symbol_name).starts_with(".L") && + arch.GetMachine() != llvm::Triple::loongarch64) + continue; // No need to add non-section symbols that have no names if (symbol.getType() != STT_SECTION && (symbol_name == nullptr || symbol_name[0] == '\0')) ___ 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 #158286)
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/158286 >From 1cd5ecd349d9b9d8054d409314862b2c0fbb694e Mon Sep 17 00:00:00 2001 From: Ebuka Ezike Date: Fri, 12 Sep 2025 13:23:47 +0100 Subject: [PATCH] [lldb][test] Fix unordered-map test. The build step is overidden so it uses `libstdc++` instead of `libc++` --- .../unordered_map-iterator/TestDataFormatterStdUnorderedMap.py | 1 - 1 file changed, 1 deletion(-) 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] [lldb][LoongArch] Preserve temporary symbols starting with `.L` in lldb symbol table (PR #158551)
https://github.com/zhaoqi5 updated https://github.com/llvm/llvm-project/pull/158551 >From c6679a64e9eebaf0c7a5bf96689c9a53dbe33b81 Mon Sep 17 00:00:00 2001 From: Qi Zhao Date: Mon, 15 Sep 2025 14:11:17 +0800 Subject: [PATCH 1/3] [lldb][LoongArch] Preserve temporary symbols starting with `.L` in lldb symbol table LoongArch64 always uses symbols for relocations, so temporary symbols starting with ".L" should be preserved so that relocations in `.debug_info` can be fixed correctly. After this commit, three tests passed: ``` lldb-shell :: SymbolFile/DWARF/anon_class_w_and_wo_export_symbols.ll lldb-shell :: SymbolFile/DWARF/clang-ast-from-dwarf-unamed-and-anon-structs.cpp lldb-shell :: SymbolFile/DWARF/clang-gmodules-type-lookup.c ``` --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 931baf5927a04..0f8bc5fc93e07 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2119,8 +2119,12 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, // generated local labels used for internal purposes (e.g. debugging, // optimization) and are not relevant for symbol resolution or external // linkage. -if (llvm::StringRef(symbol_name).starts_with(".L")) - continue; +// LoongArch64 always uses symbols for relocations, so temporary symbols +// starting with ".L" should be preserved. +if (arch.GetMachine() != llvm::Triple::loongarch64) { + if (llvm::StringRef(symbol_name).starts_with(".L")) +continue; +} // No need to add non-section symbols that have no names if (symbol.getType() != STT_SECTION && (symbol_name == nullptr || symbol_name[0] == '\0')) >From a091f3635bffa3ab37f37232a30fd8563130eb7b Mon Sep 17 00:00:00 2001 From: ZhaoQi Date: Mon, 15 Sep 2025 16:14:44 +0800 Subject: [PATCH 2/3] address comment Co-authored-by: Lu Weining --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 0f8bc5fc93e07..45c8f0ac23e58 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2121,10 +2121,9 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, // linkage. // LoongArch64 always uses symbols for relocations, so temporary symbols // starting with ".L" should be preserved. -if (arch.GetMachine() != llvm::Triple::loongarch64) { - if (llvm::StringRef(symbol_name).starts_with(".L")) -continue; -} +if (llvm::StringRef(symbol_name).starts_with(".L") && + arch.GetMachine() != llvm::Triple::loongarch64) + continue; // No need to add non-section symbols that have no names if (symbol.getType() != STT_SECTION && (symbol_name == nullptr || symbol_name[0] == '\0')) >From 5548303e0f7c67f4b4f02dceae1c07c8be4fde2b Mon Sep 17 00:00:00 2001 From: Qi Zhao Date: Mon, 15 Sep 2025 16:31:25 +0800 Subject: [PATCH 3/3] clang format --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 45c8f0ac23e58..406d7d0df5ac8 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2122,7 +2122,7 @@ ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id, // LoongArch64 always uses symbols for relocations, so temporary symbols // starting with ".L" should be preserved. if (llvm::StringRef(symbol_name).starts_with(".L") && - arch.GetMachine() != llvm::Triple::loongarch64) +arch.GetMachine() != llvm::Triple::loongarch64) continue; // No need to add non-section symbols that have no names if (symbol.getType() != STT_SECTION && ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Initialize the file system explicitly (PR #158381)
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/158381 >From a9a1c7df3a529bcae6c6d33fdf93adab8d572cff Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Fri, 12 Sep 2025 14:44:02 -0700 Subject: [PATCH 1/4] [clang] Initialize the file system explicitly --- .../include/clang/Frontend/CompilerInstance.h | 47 ++ clang/lib/Frontend/ASTUnit.cpp| 8 ++- clang/lib/Frontend/ChainedIncludesSource.cpp | 1 + clang/lib/Frontend/CompilerInstance.cpp | 63 +-- clang/lib/Frontend/FrontendAction.cpp | 5 +- .../lib/Frontend/Rewrite/FrontendActions.cpp | 2 +- clang/lib/Interpreter/Interpreter.cpp | 7 ++- .../StaticAnalyzer/Frontend/ModelInjector.cpp | 2 +- clang/lib/Testing/TestAST.cpp | 10 ++- .../DependencyScanningWorker.cpp | 12 ++-- clang/lib/Tooling/Tooling.cpp | 3 +- .../clang-import-test/clang-import-test.cpp | 4 +- .../clang-installapi/ClangInstallAPI.cpp | 2 +- clang/tools/driver/cc1_main.cpp | 8 ++- clang/unittests/AST/ExternalASTSourceTest.cpp | 3 +- clang/unittests/CodeGen/TestCompiler.h| 3 +- clang/unittests/Driver/ToolChainTest.cpp | 3 +- .../unittests/Frontend/CodeGenActionTest.cpp | 6 +- .../Frontend/CompilerInstanceTest.cpp | 4 +- .../unittests/Frontend/FrontendActionTest.cpp | 19 +++--- clang/unittests/Frontend/OutputStreamTest.cpp | 9 +-- .../Serialization/ForceCheckFileInputTest.cpp | 9 ++- .../Serialization/ModuleCacheTest.cpp | 4 ++ .../Serialization/NoCommentsTest.cpp | 1 + .../PreambleInNamedModulesTest.cpp| 8 +-- clang/unittests/Support/TimeProfilerTest.cpp | 6 +- .../DependencyScannerTest.cpp | 3 +- 27 files changed, 148 insertions(+), 104 deletions(-) diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index 9f3d5f97cdff4..a6b6993b708d0 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -83,6 +83,9 @@ class CompilerInstance : public ModuleLoader { /// The options used in this compiler instance. std::shared_ptr Invocation; + /// The virtual file system instance. + IntrusiveRefCntPtr VFS; + /// The diagnostics engine instance. IntrusiveRefCntPtr Diagnostics; @@ -409,9 +412,31 @@ class CompilerInstance : public ModuleLoader { /// @name Virtual File System /// @{ - llvm::vfs::FileSystem &getVirtualFileSystem() const; - llvm::IntrusiveRefCntPtr - getVirtualFileSystemPtr() const; + bool hasVirtualFileSystem() const { return VFS != nullptr; } + + /// Create a virtual file system instance based on the invocation. + /// + /// @param BaseFS The file system that may be used when configuring the final + /// file system, and act as the underlying file system. Must not + /// be NULL. + /// @param DC If non-NULL, the diagnostic consumer to be used in case + /// configuring the file system emits diagnostics. Note that the + /// DiagnosticsEngine using the consumer won't obey the + /// --warning-suppression-mappings= flag. + void createVirtualFileSystem(IntrusiveRefCntPtr + BaseFS = llvm::vfs::getRealFileSystem(), + DiagnosticConsumer *DC = nullptr); + + /// Use the given file system. + void setVirtualFileSystem(IntrusiveRefCntPtr FS) { +VFS = std::move(FS); + } + + llvm::vfs::FileSystem &getVirtualFileSystem() const { return *VFS; } + + IntrusiveRefCntPtr getVirtualFileSystemPtr() const { +return VFS; + } /// @} /// @name File Manager @@ -650,32 +675,31 @@ class CompilerInstance : public ModuleLoader { /// Note that this routine also replaces the diagnostic client, /// allocating one if one is not provided. /// - /// \param VFS is used for any IO needed when creating DiagnosticsEngine. It - /// doesn't replace VFS in the CompilerInstance (if any). - /// /// \param Client If non-NULL, a diagnostic client that will be /// attached to (and, then, owned by) the DiagnosticsEngine inside this AST /// unit. /// /// \param ShouldOwnClient If Client is non-NULL, specifies whether /// the diagnostic object should take ownership of the client. - void createDiagnostics(llvm::vfs::FileSystem &VFS, - DiagnosticConsumer *Client = nullptr, + void createDiagnostics(DiagnosticConsumer *Client = nullptr, bool ShouldOwnClient = true); - /// Create a DiagnosticsEngine object with a the TextDiagnosticPrinter. + /// Create a DiagnosticsEngine object. /// /// If no diagnostic client is provided, this creates a /// DiagnosticConsumer that is owned by the returned diagnostic /// object, if using directly the caller is responsible for /// releasing the
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Initialize the file system explicitly (PR #158381)
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/158381 >From a9a1c7df3a529bcae6c6d33fdf93adab8d572cff Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Fri, 12 Sep 2025 14:44:02 -0700 Subject: [PATCH 1/5] [clang] Initialize the file system explicitly --- .../include/clang/Frontend/CompilerInstance.h | 47 ++ clang/lib/Frontend/ASTUnit.cpp| 8 ++- clang/lib/Frontend/ChainedIncludesSource.cpp | 1 + clang/lib/Frontend/CompilerInstance.cpp | 63 +-- clang/lib/Frontend/FrontendAction.cpp | 5 +- .../lib/Frontend/Rewrite/FrontendActions.cpp | 2 +- clang/lib/Interpreter/Interpreter.cpp | 7 ++- .../StaticAnalyzer/Frontend/ModelInjector.cpp | 2 +- clang/lib/Testing/TestAST.cpp | 10 ++- .../DependencyScanningWorker.cpp | 12 ++-- clang/lib/Tooling/Tooling.cpp | 3 +- .../clang-import-test/clang-import-test.cpp | 4 +- .../clang-installapi/ClangInstallAPI.cpp | 2 +- clang/tools/driver/cc1_main.cpp | 8 ++- clang/unittests/AST/ExternalASTSourceTest.cpp | 3 +- clang/unittests/CodeGen/TestCompiler.h| 3 +- clang/unittests/Driver/ToolChainTest.cpp | 3 +- .../unittests/Frontend/CodeGenActionTest.cpp | 6 +- .../Frontend/CompilerInstanceTest.cpp | 4 +- .../unittests/Frontend/FrontendActionTest.cpp | 19 +++--- clang/unittests/Frontend/OutputStreamTest.cpp | 9 +-- .../Serialization/ForceCheckFileInputTest.cpp | 9 ++- .../Serialization/ModuleCacheTest.cpp | 4 ++ .../Serialization/NoCommentsTest.cpp | 1 + .../PreambleInNamedModulesTest.cpp| 8 +-- clang/unittests/Support/TimeProfilerTest.cpp | 6 +- .../DependencyScannerTest.cpp | 3 +- 27 files changed, 148 insertions(+), 104 deletions(-) diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index 9f3d5f97cdff4..a6b6993b708d0 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -83,6 +83,9 @@ class CompilerInstance : public ModuleLoader { /// The options used in this compiler instance. std::shared_ptr Invocation; + /// The virtual file system instance. + IntrusiveRefCntPtr VFS; + /// The diagnostics engine instance. IntrusiveRefCntPtr Diagnostics; @@ -409,9 +412,31 @@ class CompilerInstance : public ModuleLoader { /// @name Virtual File System /// @{ - llvm::vfs::FileSystem &getVirtualFileSystem() const; - llvm::IntrusiveRefCntPtr - getVirtualFileSystemPtr() const; + bool hasVirtualFileSystem() const { return VFS != nullptr; } + + /// Create a virtual file system instance based on the invocation. + /// + /// @param BaseFS The file system that may be used when configuring the final + /// file system, and act as the underlying file system. Must not + /// be NULL. + /// @param DC If non-NULL, the diagnostic consumer to be used in case + /// configuring the file system emits diagnostics. Note that the + /// DiagnosticsEngine using the consumer won't obey the + /// --warning-suppression-mappings= flag. + void createVirtualFileSystem(IntrusiveRefCntPtr + BaseFS = llvm::vfs::getRealFileSystem(), + DiagnosticConsumer *DC = nullptr); + + /// Use the given file system. + void setVirtualFileSystem(IntrusiveRefCntPtr FS) { +VFS = std::move(FS); + } + + llvm::vfs::FileSystem &getVirtualFileSystem() const { return *VFS; } + + IntrusiveRefCntPtr getVirtualFileSystemPtr() const { +return VFS; + } /// @} /// @name File Manager @@ -650,32 +675,31 @@ class CompilerInstance : public ModuleLoader { /// Note that this routine also replaces the diagnostic client, /// allocating one if one is not provided. /// - /// \param VFS is used for any IO needed when creating DiagnosticsEngine. It - /// doesn't replace VFS in the CompilerInstance (if any). - /// /// \param Client If non-NULL, a diagnostic client that will be /// attached to (and, then, owned by) the DiagnosticsEngine inside this AST /// unit. /// /// \param ShouldOwnClient If Client is non-NULL, specifies whether /// the diagnostic object should take ownership of the client. - void createDiagnostics(llvm::vfs::FileSystem &VFS, - DiagnosticConsumer *Client = nullptr, + void createDiagnostics(DiagnosticConsumer *Client = nullptr, bool ShouldOwnClient = true); - /// Create a DiagnosticsEngine object with a the TextDiagnosticPrinter. + /// Create a DiagnosticsEngine object. /// /// If no diagnostic client is provided, this creates a /// DiagnosticConsumer that is owned by the returned diagnostic /// object, if using directly the caller is responsible for /// releasing the
[Lldb-commits] [lldb] [lldb-dap] Add memory event (PR #158437)
https://github.com/ashgti approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/158437 ___ 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 memory event (PR #158437)
https://github.com/ashgti edited https://github.com/llvm/llvm-project/pull/158437 ___ 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 memory event (PR #158437)
@@ -88,6 +88,34 @@ struct InvalidatedEventBody { llvm::json::Value toJSON(const InvalidatedEventBody::Area &); llvm::json::Value toJSON(const InvalidatedEventBody &); +/// This event indicates that some memory range has been updated. It should only +/// be sent if the corresponding capability supportsMemoryEvent is true. +/// +/// Clients typically react to the event by re-issuing a readMemory request if +/// they show the memory identified by the memoryReference and if the updated +/// memory range overlaps the displayed range. Clients should not make +/// assumptions how individual memory references relate to each other, so they +/// should not assume that they are part of a single continuous address range +/// and might overlap. +/// +/// Debug adapters can use this event to indicate that the contents of a memory +/// range has changed due to some other request like setVariable or +/// setExpression. Debug adapters are not expected to emit this event for each +/// and every memory change of a running program, because that information is +/// typically not available from debuggers and it would flood clients with too +/// many events. +struct MemoryEventBody { + /// Memory reference of a memory range that has been updated. + lldb::addr_t memoryReference; + + /// Starting offset in bytes where memory has been updated. Can be negative. + int64_t offset; + + /// Number of bytes updated. + uint64_t count; ashgti wrote: Can we have a default of 0 or a some define/const value for these? In case we don't need to set a value. https://github.com/llvm/llvm-project/pull/158437 ___ 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/walter-erquinigo auto_merge_enabled 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] [clang] [clang-tools-extra] [compiler-rt] [lldb] [Clang] [Sema] Make `-Wincompatible-pointer-types` an error by default (PR #157364)
Sirraide wrote: Should be fixed by https://github.com/llvm/llvm-test-suite/commit/8a20f8caaf6eb1a2a9b83363c3ab0cf8bb978b74 unless more tests start failing. https://github.com/llvm/llvm-project/pull/157364 ___ 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 memory event (PR #158437)
https://github.com/DrSergei updated https://github.com/llvm/llvm-project/pull/158437 >From 181075379693af77cfde778102b62e72a789ba2a Mon Sep 17 00:00:00 2001 From: Druzhkov Sergei Date: Sat, 13 Sep 2025 23:33:49 +0300 Subject: [PATCH 1/2] [lldb-dap] Add memory event --- .../test/tools/lldb-dap/dap_server.py | 4 +++ .../test/tools/lldb-dap/lldbdap_testcase.py | 9 ++ lldb/tools/lldb-dap/EventHelper.cpp | 13 + lldb/tools/lldb-dap/EventHelper.h | 2 ++ .../Handler/SetVariableRequestHandler.cpp | 3 ++ .../lldb-dap/Protocol/ProtocolEvents.cpp | 8 ++ lldb/tools/lldb-dap/Protocol/ProtocolEvents.h | 28 +++ lldb/unittests/DAP/ProtocolTypesTest.cpp | 13 + 8 files changed, 80 insertions(+) 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..3a9e076eff9f0 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 @@ -216,6 +216,7 @@ def __init__( self.events: List[Event] = [] self.progress_events: List[Event] = [] self.invalidated_event: Optional[Event] = None +self.memory_event: Optional[Event] = None self.reverse_requests: List[Request] = [] self.module_events: List[Dict] = [] self.sequence: int = 1 @@ -443,6 +444,8 @@ def _handle_event(self, packet: Event) -> None: self.capabilities.update(body["capabilities"]) elif event == "invalidated": self.invalidated_event = packet +elif event == "memory": +self.memory_event = packet def _handle_reverse_request(self, request: Request) -> None: if request in self.reverse_requests: @@ -1018,6 +1021,7 @@ def request_initialize(self, sourceInitFile=False): "supportsStartDebuggingRequest": True, "supportsProgressReporting": True, "supportsInvalidatedEvent": True, +"supportsMemoryEvent": True, "$__lldb_sourceInitFile": sourceInitFile, }, } diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index a0a009ae6cc9a..882eec9971a73 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -248,6 +248,14 @@ def verify_invalidated_event(self, expected_areas): areas = event["body"].get("areas", []) self.assertEqual(set(expected_areas), set(areas)) +def verify_memory_event(self, memoryReference): +if memoryReference is None: +self.assertIsNone(self.dap_server.memory_event) +event = self.dap_server.memory_event +self.dap_server.memory_event = None +self.assertIsNotNone(event) +self.assertEqual(memoryReference, event["body"].get("memoryReference")) + def get_dict_value(self, d: dict, key_path: list[str]) -> Any: """Verify each key in the key_path array is in contained in each dictionary within "d". Assert if any key isn't in the @@ -364,6 +372,7 @@ def set_variable(self, varRef, name, value, id=None): response = self.dap_server.request_setVariable(varRef, name, str(value), id=id) if response["success"]: self.verify_invalidated_event(["variables"]) +self.verify_memory_event(response["body"].get("memoryReference")) return response def set_local(self, name, value, id=None): diff --git a/lldb/tools/lldb-dap/EventHelper.cpp b/lldb/tools/lldb-dap/EventHelper.cpp index 6eb468e76b16c..9c2c1f846d11e 100644 --- a/lldb/tools/lldb-dap/EventHelper.cpp +++ b/lldb/tools/lldb-dap/EventHelper.cpp @@ -284,4 +284,17 @@ void SendInvalidatedEvent( dap.Send(protocol::Event{"invalidated", std::move(body)}); } +void SendMemoryEvent(DAP &dap, lldb::SBValue variable) { + if (!dap.clientFeatures.contains(protocol::eClientFeatureMemoryEvent)) +return; + const lldb::addr_t addr = variable.GetLoadAddress(); + if (addr == LLDB_INVALID_ADDRESS) +return; + protocol::MemoryEventBody body; + body.memoryReference = addr; + body.offset = 0; + body.count = variable.GetByteSize(); + dap.Send(protocol::Event{"memory", std::move(body)}); +} + } // namespace lldb_dap diff --git a/lldb/tools/lldb-dap/EventHelper.h b/lldb/tools/lldb-dap/EventHelper.h index 0c57afbaf1f33..48eb5af6bd0b9 100644 --- a/lldb/tools/lldb-dap/EventHelper.h +++ b/lldb/tools/lldb-dap/EventHelper.h @@ -37,6 +37,8 @@ void SendProcessExitedEvent(DAP &dap, lldb::SBProcess &process); void SendInvalidatedEvent( DAP &dap, llvm::ArrayRef areas); +void SendMemoryEvent(DAP &dap, lldb::SBValue variable); + } // namespace lldb_dap #endif
[Lldb-commits] [lldb] [lldb/API] Mark SBValue with error as invalid (PR #158759)
medismailben wrote: I fixed the formatting most of the failures. I only need to find the right way to return the errors through DAP: prior to this change, errors were returned as part of the value object string, since the object was still considered valid but now that it's marked invalid, the return string is empty. @JDevlieghere what would be the right approach here ? https://github.com/llvm/llvm-project/pull/158759 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/API] Mark SBValue with error as invalid (PR #158759)
https://github.com/medismailben updated https://github.com/llvm/llvm-project/pull/158759 >From 9744d606c8ddc03aeba105c89647af4c009dac28 Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Mon, 15 Sep 2025 18:04:48 -0700 Subject: [PATCH] [lldb/API] Mark SBValue with error as invalid This patch fixes the return value of `SBValue::IsValid` if `GetError` returns a failing `SBError`. That alignes better the expectation that an `SBValue` is invalid if it has an error. Signed-off-by: Med Ismail Bennani --- lldb/source/API/SBValue.cpp | 3 ++- .../expression/call-throws/TestCallThatThrows.py | 11 +++ .../expression/context-object/TestContextObject.py| 10 +- .../test/API/commands/expression/fixits/TestFixIts.py | 2 +- .../commands/expression/options/TestExprOptions.py| 4 ++-- .../expression/scoped_enums/TestScopedEnumType.py | 4 ++-- .../expression/timeout/TestCallWithTimeout.py | 2 +- .../python_api/sbvalue_is_valid/TestSBValueIsValid.py | 3 +++ lldb/test/API/python_api/sbvalue_is_valid/main.cpp| 7 +++ 9 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 lldb/test/API/python_api/sbvalue_is_valid/TestSBValueIsValid.py create mode 100644 lldb/test/API/python_api/sbvalue_is_valid/main.cpp diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index e300ecee3f8ac..77cc7d1681829 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -97,7 +97,8 @@ class ValueImpl { // they depend on. So I have no good way to make that check without // tracking that in all the ValueObject subclasses. TargetSP target_sp = m_valobj_sp->GetTargetSP(); - return target_sp && target_sp->IsValid(); + return target_sp && target_sp->IsValid() && + m_valobj_sp->GetError().Success(); } } diff --git a/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py b/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py index 0090513864cd7..4d5e5a36eb72a 100644 --- a/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py +++ b/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py @@ -45,7 +45,7 @@ def call_function(self): self.orig_frame_pc = frame.GetPC() value = frame.EvaluateExpression("[my_class callMeIThrow]", options) -self.assertTrue(value.IsValid()) +self.assertFalse(value.IsValid()) self.assertFalse(value.GetError().Success()) self.check_after_call() @@ -61,7 +61,8 @@ def call_function(self): value = frame.EvaluateExpression("[my_class callMeIThrow]", options) -self.assertTrue(value.IsValid() and not value.GetError().Success()) +self.assertFalse(value.IsValid()) +self.assertFalse(value.GetError().Success()) self.check_after_call() # Now set the ObjC language breakpoint and make sure that doesn't @@ -76,7 +77,8 @@ def call_function(self): value = frame.EvaluateExpression("[my_class callMeIThrow]", options) -self.assertTrue(value.IsValid() and not value.GetError().Success()) +self.assertFalse(value.IsValid()) +self.assertFalse(value.GetError().Success()) self.check_after_call() # Now turn off exception trapping, and call a function that catches the exceptions, @@ -95,5 +97,6 @@ def call_function(self): options.SetUnwindOnError(False) value = frame.EvaluateExpression("[my_class callMeIThrow]", options) -self.assertTrue(value.IsValid() and not value.GetError().Success()) +self.assertFalse(value.IsValid()) +self.assertFalse(value.GetError().Success()) self.check_after_call() diff --git a/lldb/test/API/commands/expression/context-object/TestContextObject.py b/lldb/test/API/commands/expression/context-object/TestContextObject.py index 1ed629a42c1ee..f3b2c3a503592 100644 --- a/lldb/test/API/commands/expression/context-object/TestContextObject.py +++ b/lldb/test/API/commands/expression/context-object/TestContextObject.py @@ -69,7 +69,7 @@ def test_context_object(self): # Test an expression evaluation value = obj_val.EvaluateExpression("1") -self.assertTrue(value.IsValid()) +self.assertFalse(value.IsValid()) self.assertFalse(value.GetError().Success()) # @@ -81,7 +81,7 @@ def test_context_object(self): # Test an expression evaluation value = obj_val.EvaluateExpression("1") -self.assertTrue(value.IsValid()) +self.assertFalse(value.IsValid()) self.assertFalse(value.GetError().Success()) # Test retrieveing of an element's field @@ -99,7 +99,7 @@ def test_context_object(self): # Test an expression evaluation value = obj_val.EvaluateExpression("1") -self.assertTrue(value.IsValid()) +self.assertFalse(value.IsValid()) self