Skip to content

Commit 06a205c

Browse files
da-viperAnkur-0429
authored andcommitted
[lldb][lldb-dap] Redirect LLDB's messages to the right output category. (llvm#137002)
Based on the DAP specification. The output categories stdout and stderr should only be used for the debuggee's stdout and stderr. ```jsonc /** * The output category. If not specified or if the category is not * understood by the client, `console` is assumed. * Values: * 'console': Show the output in the client's default message UI, e.g. a * 'debug console'. This category should only be used for informational * output from the debugger (as opposed to the debuggee). * 'important': A hint for the client to show the output in the client's UI * for important and highly visible information, e.g. as a popup * notification. This category should only be used for important messages * from the debugger (as opposed to the debuggee). Since this category value * is a hint, clients might ignore the hint and assume the `console` * category. * 'stdout': Show the output as normal program output from the debuggee. * 'stderr': Show the output as error program output from the debuggee. * 'telemetry': Send the output to telemetry instead of showing it to the * user. * etc. */ category?: 'console' | 'important' | 'stdout' | 'stderr' | 'telemetry' | string; ``` What I am not sure if error should use the important category ? --------- Signed-off-by: Ebuka Ezike <[email protected]>
1 parent 2ffcb30 commit 06a205c

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_inflight_request(self):
8282

8383
blocking_seq = self.async_blocking_request(duration=self.timeoutval / 2)
8484
# Wait for the sleep to start to cancel the inflight request.
85-
self.collect_stdout(
85+
self.collect_console(
8686
timeout_secs=self.timeoutval,
8787
pattern="starting sleep",
8888
)

lldb/test/API/tools/lldb-dap/output/TestDAP_output.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ def test_output(self):
4040
output += self.get_stdout(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval)
4141
self.assertTrue(output and len(output) > 0, "expect program stdout")
4242
self.assertIn(
43-
"abcdefghi\r\nhello world\r\nfinally\0\0out\0\0\r\nerr\0\0",
43+
"abcdefghi\r\nhello world\r\nfinally\0\0",
4444
output,
4545
"full stdout not found in: " + repr(output),
4646
)
47+
console = self.get_console(timeout=self.timeoutval)
48+
self.assertTrue(console and len(console) > 0, "expect dap messages")
49+
self.assertIn(
50+
"out\0\0\r\nerr\0\0\r\n", console, f"full console message not found"
51+
)

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ llvm::Error DAP::ConfigureIO(std::FILE *overrideOut, std::FILE *overrideErr) {
209209
in = lldb::SBFile(std::fopen(DEV_NULL, "r"), /*transfer_ownership=*/true);
210210

211211
if (auto Error = out.RedirectTo(overrideOut, [this](llvm::StringRef output) {
212-
SendOutput(OutputType::Stdout, output);
212+
SendOutput(OutputType::Console, output);
213213
}))
214214
return Error;
215215

216216
if (auto Error = err.RedirectTo(overrideErr, [this](llvm::StringRef output) {
217-
SendOutput(OutputType::Stderr, output);
217+
SendOutput(OutputType::Console, output);
218218
}))
219219
return Error;
220220

0 commit comments

Comments
 (0)