[Lldb-commits] [lldb] e270ee5 - [lldb-dap] Fix runInTerminal error message serialization (#221504)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 15 13:09:33 PDT 2026
Author: cui fliter
Date: 2026-09-15T21:09:29+01:00
New Revision: e270ee55cce78c61bda92d78b69869a53d1f36f7
URL: https://github.com/llvm/llvm-project/commit/e270ee55cce78c61bda92d78b69869a53d1f36f7
DIFF: https://github.com/llvm/llvm-project/commit/e270ee55cce78c61bda92d78b69869a53d1f36f7.diff
LOG: [lldb-dap] Fix runInTerminal error message serialization (#221504)
`RunInTerminalMessageError::ToJSON()` serializes the error message using
the `"value"` field, while `ParseJSONMessage()` expects the `"error"`
field.
When the runInTerminal launcher fails, the debug adapter cannot
deserialize the launcher error and reports an `Incorrect JSON message`
error instead of preserving the original diagnostic.
This patch makes the serialized field name match the parser and adds a
round-trip test covering launcher error propagation.
Signed-off-by: cuishuang <imcusg at gmail.com>
Added:
lldb/unittests/DAP/RunInTerminalTest.cpp
Modified:
lldb/tools/lldb-dap/RunInTerminal.cpp
lldb/unittests/DAP/CMakeLists.txt
Removed:
################################################################################
diff --git a/lldb/tools/lldb-dap/RunInTerminal.cpp b/lldb/tools/lldb-dap/RunInTerminal.cpp
index 75bdac910f1f8..35a211c7e716e 100644
--- a/lldb/tools/lldb-dap/RunInTerminal.cpp
+++ b/lldb/tools/lldb-dap/RunInTerminal.cpp
@@ -49,7 +49,7 @@ RunInTerminalMessageError::RunInTerminalMessageError(StringRef error)
: RunInTerminalMessage(eRunInTerminalMessageKindError), error(error) {}
json::Value RunInTerminalMessageError::ToJSON() const {
- return json::Object{{"kind", "error"}, {"value", error}};
+ return json::Object{{"kind", "error"}, {"error", error}};
}
RunInTerminalMessageDidAttach::RunInTerminalMessageDidAttach()
diff --git a/lldb/unittests/DAP/CMakeLists.txt b/lldb/unittests/DAP/CMakeLists.txt
index c6a2a0a9675d2..3fce38d2b582f 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -15,6 +15,7 @@ add_lldb_unittest(DAPTests
ProtocolRequestsTest.cpp
ProtocolTypesTest.cpp
ProtocolUtilsTest.cpp
+ RunInTerminalTest.cpp
TestBase.cpp
VariablesTest.cpp
diff --git a/lldb/unittests/DAP/RunInTerminalTest.cpp b/lldb/unittests/DAP/RunInTerminalTest.cpp
new file mode 100644
index 0000000000000..4b607d8485e9c
--- /dev/null
+++ b/lldb/unittests/DAP/RunInTerminalTest.cpp
@@ -0,0 +1,28 @@
+//===-- RunInTerminalTest.cpp --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "RunInTerminal.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+#include <thread>
+
+using namespace lldb_dap;
+using namespace llvm;
+
+TEST(RunInTerminalTest, ErrorRoundTrip) {
+ Expected<std::shared_ptr<FifoFile>> fifo = CreateRunInTerminalCommFile();
+ ASSERT_THAT_EXPECTED(fifo, Succeeded());
+
+ RunInTerminalLauncherCommChannel launcher((*fifo)->GetPath());
+ (*fifo)->Connect();
+ RunInTerminalDebugAdapterCommChannel adapter(*fifo);
+
+ std::thread sender([&launcher]() { launcher.NotifyError("boom"); });
+ EXPECT_EQ(adapter.GetLauncherError(), "boom");
+ sender.join();
+}
More information about the lldb-commits
mailing list