Skip to content

Conversation

JDevlieghere
Copy link
Member

Add the scaffolding for a new tool lldb-mcp. This utility is meant to replace netcat and acts a proxy between the LLM and one or more LLDB instances. In its current form, the utility is a trivial MCP server without any tools or resources.

Add the scaffolding for a new tool lldb-mcp. This utility is meant to
replace netcat and acts a proxy between the LLM and one or more LLDB
instances. In its current form, the utility is a trivial MCP server
without any tools or resources.
@JDevlieghere JDevlieghere requested a review from ashgti August 27, 2025 22:19
@llvmbot llvmbot added the lldb label Aug 27, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 27, 2025

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

Add the scaffolding for a new tool lldb-mcp. This utility is meant to replace netcat and acts a proxy between the LLM and one or more LLDB instances. In its current form, the utility is a trivial MCP server without any tools or resources.


Full diff: https://github.com/llvm/llvm-project/pull/155708.diff

4 Files Affected:

  • (modified) lldb/tools/CMakeLists.txt (+1)
  • (added) lldb/tools/lldb-mcp/CMakeLists.txt (+33)
  • (added) lldb/tools/lldb-mcp/lldb-mcp-Info.plist.in (+21)
  • (added) lldb/tools/lldb-mcp/lldb-mcp.cpp (+80)
diff --git a/lldb/tools/CMakeLists.txt b/lldb/tools/CMakeLists.txt
index e2f039527ad75..4a0d2f695481d 100644
--- a/lldb/tools/CMakeLists.txt
+++ b/lldb/tools/CMakeLists.txt
@@ -10,6 +10,7 @@ add_subdirectory(lldb-fuzzer EXCLUDE_FROM_ALL)
 
 add_lldb_tool_subdirectory(lldb-instr)
 add_lldb_tool_subdirectory(lldb-dap)
+add_lldb_tool_subdirectory(lldb-mcp)
 if (LLDB_BUILD_LLDBRPC)
   add_lldb_tool_subdirectory(lldb-rpc-gen)
 endif()
diff --git a/lldb/tools/lldb-mcp/CMakeLists.txt b/lldb/tools/lldb-mcp/CMakeLists.txt
new file mode 100644
index 0000000000000..7fe3301ab3081
--- /dev/null
+++ b/lldb/tools/lldb-mcp/CMakeLists.txt
@@ -0,0 +1,33 @@
+add_lldb_tool(lldb-mcp
+  lldb-mcp.cpp
+
+  LINK_COMPONENTS
+    Option
+    Support
+  LINK_LIBS
+    liblldb
+    lldbHost
+    lldbProtocolMCP
+  )
+
+if(APPLE)
+  configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/lldb-mcp-Info.plist.in
+    ${CMAKE_CURRENT_BINARY_DIR}/lldb-mcp-Info.plist
+    )
+  target_link_options(lldb-mcp
+    PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-mcp-Info.plist)
+endif()
+
+if(LLDB_BUILD_FRAMEWORK)
+  # In the build-tree, we know the exact path to the framework directory.
+  # The installed framework can be in different locations.
+  lldb_setup_rpaths(lldb-mcp
+    BUILD_RPATH
+      "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
+    INSTALL_RPATH
+      "@loader_path/../../../SharedFrameworks"
+      "@loader_path/../../System/Library/PrivateFrameworks"
+      "@loader_path/../../Library/PrivateFrameworks"
+  )
+endif()
diff --git a/lldb/tools/lldb-mcp/lldb-mcp-Info.plist.in b/lldb/tools/lldb-mcp/lldb-mcp-Info.plist.in
new file mode 100644
index 0000000000000..7d01d3145d929
--- /dev/null
+++ b/lldb/tools/lldb-mcp/lldb-mcp-Info.plist.in
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.apple.lldb-dap</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>lldb-dap</string>
+	<key>CFBundleVersion</key>
+	<string>${LLDB_VERSION}</string>
+	<key>SecTaskAccess</key>
+	<array>
+		<string>allowed</string>
+		<string>debug</string>
+	</array>
+</dict>
+</plist>
diff --git a/lldb/tools/lldb-mcp/lldb-mcp.cpp b/lldb/tools/lldb-mcp/lldb-mcp.cpp
new file mode 100644
index 0000000000000..3769b9a7408eb
--- /dev/null
+++ b/lldb/tools/lldb-mcp/lldb-mcp.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/Config.h"
+#include "lldb/Host/File.h"
+#include "lldb/Host/MainLoop.h"
+#include "lldb/Host/MainLoopBase.h"
+#include "lldb/Protocol/MCP/Protocol.h"
+#include "lldb/Protocol/MCP/Server.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace lldb_protocol::mcp;
+
+using lldb_private::File;
+using lldb_private::MainLoop;
+using lldb_private::MainLoopBase;
+using lldb_private::NativeFile;
+
+static constexpr llvm::StringLiteral kName = "lldb-mcp";
+static constexpr llvm::StringLiteral kVersion = "0.1.0";
+
+int main(int argc, char *argv[]) {
+  llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false);
+#if !defined(__APPLE__)
+  llvm::setBugReportMsg("PLEASE submit a bug report to " LLDB_BUG_REPORT_URL
+                        " and include the crash backtrace.\n");
+#else
+  llvm::setBugReportMsg("PLEASE submit a bug report to " LLDB_BUG_REPORT_URL
+                        " and include the crash report from "
+                        "~/Library/Logs/DiagnosticReports/.\n");
+#endif
+
+#if defined(_WIN32)
+  // Windows opens stdout and stdin in text mode which converts \n to 13,10
+  // while the value is just 10 on Darwin/Linux. Setting the file mode to
+  // binary fixes this.
+  int result = _setmode(fileno(stdout), _O_BINARY);
+  assert(result);
+  result = _setmode(fileno(stdin), _O_BINARY);
+  UNUSED_IF_ASSERT_DISABLED(result);
+  assert(result);
+#endif
+
+  lldb::IOObjectSP input = std::make_shared<NativeFile>(
+      fileno(stdin), File::eOpenOptionReadOnly, NativeFile::Unowned);
+
+  lldb::IOObjectSP output = std::make_shared<NativeFile>(
+      fileno(stdout), File::eOpenOptionReadOnly, NativeFile::Unowned);
+
+  constexpr llvm::StringLiteral client_name = "stdio";
+  static MainLoop loop;
+
+  llvm::sys::SetInterruptFunction([]() {
+    loop.AddPendingCallback(
+        [](MainLoopBase &loop) { loop.RequestTermination(); });
+  });
+
+  auto transport_up = std::make_unique<lldb_protocol::mcp::MCPTransport>(
+      input, output, std::string(client_name),
+      [&](llvm::StringRef message) { llvm::errs() << message << '\n'; });
+
+  auto instance_up = std::make_unique<lldb_protocol::mcp::Server>(
+      std::string(kName), std::string(kVersion), std::move(transport_up), loop);
+
+  if (llvm::Error error = instance_up->Run()) {
+    llvm::logAllUnhandledErrors(std::move(error), llvm::WithColor::error(),
+                                "DAP session error: ");
+    return EXIT_FAILURE;
+  }
+
+  return EXIT_SUCCESS;
+}

<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>lldb-dap</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lldb-mcp?

<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.lldb-dap</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

com.apple.lldb-mcp?


if (llvm::Error error = instance_up->Run()) {
llvm::logAllUnhandledErrors(std::move(error), llvm::WithColor::error(),
"DAP session error: ");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/DAP/MCP/?

fileno(stdin), File::eOpenOptionReadOnly, NativeFile::Unowned);

lldb::IOObjectSP output = std::make_shared<NativeFile>(
fileno(stdout), File::eOpenOptionReadOnly, NativeFile::Unowned);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/eOpenOptionReadOnly/eOpenOptionWriteOnly/?

constexpr llvm::StringLiteral client_name = "stdio";
static MainLoop loop;

llvm::sys::SetInterruptFunction([]() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think MainLoop can register a signal handler, but I suppose thats not cross platform. I wonder how the llvm interrupt handler works on Windows...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked with @labath about that at the last EuroLLVM. IIRC he was going to take a stab at making that work on Windows :P

@JDevlieghere JDevlieghere merged commit aa71d95 into llvm:main Aug 27, 2025
9 checks passed
@JDevlieghere JDevlieghere deleted the lldb-mcp branch August 27, 2025 23:22
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 27, 2025

LLVM Buildbot has detected a new failure on builder cross-project-tests-sie-ubuntu running on doug-worker-1a while building lldb at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/181/builds/26803

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
83.627 [212/8/5209] Building CXX object tools/llvm-rc/CMakeFiles/llvm-rc.dir/ResourceScriptCppFilter.cpp.o
83.635 [211/8/5210] Building CXX object tools/llvm-rc/CMakeFiles/llvm-rc.dir/ResourceScriptParser.cpp.o
83.644 [210/8/5211] Building CXX object tools/llvm-rc/CMakeFiles/llvm-rc.dir/ResourceScriptStmt.cpp.o
83.652 [209/8/5212] Building CXX object tools/llvm-rc/CMakeFiles/llvm-rc.dir/ResourceScriptToken.cpp.o
83.660 [208/8/5213] Building CXX object tools/llvm-rc/CMakeFiles/llvm-rc.dir/llvm-rc-driver.cpp.o
83.662 [207/8/5214] Building Opts.inc...
83.682 [206/8/5215] Building CXX object tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/ARMWinEHPrinter.cpp.o
83.707 [205/8/5216] Building CXX object tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/COFFDumper.cpp.o
83.727 [204/8/5217] Building CXX object tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/COFFImportDumper.cpp.o
83.741 [203/8/5218] Building CXX object tools/lldb/tools/lldb-mcp/CMakeFiles/lldb-mcp.dir/lldb-mcp.cpp.o
FAILED: tools/lldb/tools/lldb-mcp/CMakeFiles/lldb-mcp.dir/lldb-mcp.cpp.o 
/opt/ccache/bin/g++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/tools/lldb-mcp -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-mcp -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/include -I/usr/include/python3.8 -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../clang/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/../clang/include -isystem /usr/include/libxml2 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-stringop-truncation -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/lldb/tools/lldb-mcp/CMakeFiles/lldb-mcp.dir/lldb-mcp.cpp.o -MF tools/lldb/tools/lldb-mcp/CMakeFiles/lldb-mcp.dir/lldb-mcp.cpp.o.d -o tools/lldb/tools/lldb-mcp/CMakeFiles/lldb-mcp.dir/lldb-mcp.cpp.o -c /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp: In function ‘int main(int, char**)’:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp:66:60: error: ‘MCPTransport’ is not a member of ‘lldb_protocol::mcp’; did you mean ‘Transport’?
   66 |   auto transport_up = std::make_unique<lldb_protocol::mcp::MCPTransport>(
      |                                                            ^~~~~~~~~~~~
      |                                                            Transport
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp:68:72: error: no matching function for call to ‘make_unique<<expression error> >(lldb::IOObjectSP&, lldb::IOObjectSP&, std::string, main(int, char**)::<lambda(llvm::StringRef)>)’
   68 |       [&](llvm::StringRef message) { llvm::errs() << message << '\n'; });
      |                                                                        ^
In file included from /usr/include/c++/9/memory:80,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/include/llvm/ADT/STLExtras.h:37,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/include/llvm/Support/FormatProviders.h:17,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include/lldb/lldb-private-enumerations.h:15,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include/lldb/lldb-private.h:12,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include/lldb/Host/Terminal.h:12,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include/lldb/Host/File.h:13,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp:10:
/usr/include/c++/9/bits/unique_ptr.h:856:5: note: candidate: ‘template<class _Tp, class ... _Args> typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...)’
  856 |     make_unique(_Args&&... __args)
      |     ^~~~~~~~~~~
/usr/include/c++/9/bits/unique_ptr.h:856:5: note:   template argument deduction/substitution failed:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp:68:72: error: template argument 1 is invalid
   68 |       [&](llvm::StringRef message) { llvm::errs() << message << '\n'; });
      |                                                                        ^
In file included from /usr/include/c++/9/memory:80,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/include/llvm/ADT/STLExtras.h:37,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/include/llvm/Support/FormatProviders.h:17,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include/lldb/lldb-private-enumerations.h:15,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include/lldb/lldb-private.h:12,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include/lldb/Host/Terminal.h:12,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include/lldb/Host/File.h:13,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp:10:
/usr/include/c++/9/bits/unique_ptr.h:862:5: note: candidate: ‘template<class _Tp> typename std::_MakeUniq<_Tp>::__array std::make_unique(std::size_t)’
  862 |     make_unique(size_t __num)
      |     ^~~~~~~~~~~
/usr/include/c++/9/bits/unique_ptr.h:862:5: note:   template argument deduction/substitution failed:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp:68:72: error: template argument 1 is invalid
   68 |       [&](llvm::StringRef message) { llvm::errs() << message << '\n'; });

@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 27, 2025

LLVM Buildbot has detected a new failure on builder cross-project-tests-sie-ubuntu-dwarf5 running on doug-worker-1b while building lldb at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/163/builds/25512

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
134.959 [231/8/5186] Building CXX object tools/llvm-pdbutil/CMakeFiles/llvm-pdbutil.dir/PrettyTypeDumper.cpp.o
134.981 [230/8/5187] Building CXX object tools/llvm-pdbutil/CMakeFiles/llvm-pdbutil.dir/PrettyTypedefDumper.cpp.o
134.982 [229/8/5188] Linking CXX executable bin/llvm-offload-wrapper
134.986 [228/8/5189] Building CXX object tools/llvm-pdbutil/CMakeFiles/llvm-pdbutil.dir/PrettyVariableDumper.cpp.o
135.006 [227/8/5190] Building CXX object tools/llvm-pdbutil/CMakeFiles/llvm-pdbutil.dir/StreamUtil.cpp.o
135.012 [226/8/5191] Building CXX object tools/llvm-pdbutil/CMakeFiles/llvm-pdbutil.dir/TypeReferenceTracker.cpp.o
135.039 [225/8/5192] Building CXX object tools/llvm-pdbutil/CMakeFiles/llvm-pdbutil.dir/YAMLOutputStyle.cpp.o
135.050 [224/8/5193] Building CXX object tools/llvm-profgen/CMakeFiles/llvm-profgen.dir/llvm-profgen.cpp.o
135.056 [223/8/5194] Building CXX object tools/llvm-profgen/CMakeFiles/llvm-profgen.dir/PerfReader.cpp.o
135.061 [222/8/5195] Building CXX object tools/lldb/tools/lldb-mcp/CMakeFiles/lldb-mcp.dir/lldb-mcp.cpp.o
FAILED: tools/lldb/tools/lldb-mcp/CMakeFiles/lldb-mcp.dir/lldb-mcp.cpp.o 
/opt/ccache/bin/g++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/tools/lldb/tools/lldb-mcp -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/tools/lldb-mcp -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/tools/lldb/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/llvm/include -I/usr/include/python3.10 -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/llvm/../clang/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/tools/lldb/../clang/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-stringop-truncation -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/lldb/tools/lldb-mcp/CMakeFiles/lldb-mcp.dir/lldb-mcp.cpp.o -MF tools/lldb/tools/lldb-mcp/CMakeFiles/lldb-mcp.dir/lldb-mcp.cpp.o.d -o tools/lldb/tools/lldb-mcp/CMakeFiles/lldb-mcp.dir/lldb-mcp.cpp.o -c /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp: In function ‘int main(int, char**)’:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp:66:60: error: ‘MCPTransport’ is not a member of ‘lldb_protocol::mcp’; did you mean ‘Transport’?
   66 |   auto transport_up = std::make_unique<lldb_protocol::mcp::MCPTransport>(
      |                                                            ^~~~~~~~~~~~
      |                                                            Transport
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp:66:73: error: no matching function for call to ‘make_unique<<expression error> >(lldb::IOObjectSP&, lldb::IOObjectSP&, std::string, main(int, char**)::<lambda(llvm::StringRef)>)’
   66 |   auto transport_up = std::make_unique<lldb_protocol::mcp::MCPTransport>(
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
   67 |       input, output, std::string(client_name),
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                           
   68 |       [&](llvm::StringRef message) { llvm::errs() << message << '\n'; });
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
In file included from /usr/include/c++/11/memory:76,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/llvm/include/llvm/ADT/STLExtras.h:37,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/llvm/include/llvm/Support/FormatProviders.h:17,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/include/lldb/lldb-private-enumerations.h:15,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/include/lldb/lldb-private.h:12,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/include/lldb/Host/Terminal.h:12,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/include/lldb/Host/File.h:13,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp:10:
/usr/include/c++/11/bits/unique_ptr.h:961:5: note: candidate: ‘template<class _Tp, class ... _Args> typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...)’
  961 |     make_unique(_Args&&... __args)
      |     ^~~~~~~~~~~
/usr/include/c++/11/bits/unique_ptr.h:961:5: note:   template argument deduction/substitution failed:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/tools/lldb-mcp/lldb-mcp.cpp:66:73: error: template argument 1 is invalid
   66 |   auto transport_up = std::make_unique<lldb_protocol::mcp::MCPTransport>(
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
   67 |       input, output, std::string(client_name),
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                           
   68 |       [&](llvm::StringRef message) { llvm::errs() << message << '\n'; });
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
In file included from /usr/include/c++/11/memory:76,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/llvm/include/llvm/ADT/STLExtras.h:37,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/llvm/include/llvm/Support/FormatProviders.h:17,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/include/lldb/lldb-private-enumerations.h:15,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/include/lldb/lldb-private.h:12,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/include/lldb/Host/Terminal.h:12,

@ashgti
Copy link
Contributor

ashgti commented Aug 27, 2025

#155720 should fix the build

@dzhidzhoev
Copy link
Member

Please note that lldb-remote-linux-win is still failing with:

C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\tools\lldb-mcp\lldb-mcp.cpp(45): error C2065: '_O_BINARY': undeclared identifier
C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\tools\lldb-mcp\lldb-mcp.cpp(47): error C2065: '_O_BINARY': undeclared identifier

https://lab.llvm.org/buildbot/#/builders/211/builds/1695

@mstorsjo
Copy link
Member

Please note that lldb-remote-linux-win is still failing with:

C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\tools\lldb-mcp\lldb-mcp.cpp(45): error C2065: '_O_BINARY': undeclared identifier
C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\tools\lldb-mcp\lldb-mcp.cpp(47): error C2065: '_O_BINARY': undeclared identifier

https://lab.llvm.org/buildbot/#/builders/211/builds/1695

I also ran into this, at https://github.com/mstorsjo/llvm-mingw/actions/runs/17282716726/job/49063271475.

It's trivially fixable with this at the head of the file:

#if defined(_WIN32)
#include <fcntl.h>
#endif

It's also possible to switch to using ChangeStdoutToBinary from https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/Program.h#L88-L92.

If you don't mind, I can push the former fix to unbreak builds, and you can look into switching to the neater API forms separately afterwards.

@mstorsjo
Copy link
Member

I pushed the trivial fix to add the missing include in 1ec0688.

@JDevlieghere
Copy link
Member Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants