Skip to content

Commit 3d28520

Browse files
committed
Capture output while we're still waiting on output handler callback
1 parent 964fb67 commit 3d28520

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

assets/test/defaultPackage/.vscode/launch.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@
1717
"args": [],
1818
"cwd": "${workspaceFolder:defaultPackage}",
1919
"preLaunchTask": "swift: Build Release package1"
20+
},
21+
{
22+
"type": "swift",
23+
"request": "launch",
24+
"args": [],
25+
"cwd": "${workspaceFolder:defaultPackage}",
26+
"name": "Debug PackageExe",
27+
"program": "${workspaceFolder:defaultPackage}/.build/debug/PackageExe",
28+
"preLaunchTask": "swift: Build Debug PackageExe"
29+
},
30+
{
31+
"type": "swift",
32+
"request": "launch",
33+
"args": [],
34+
"cwd": "${workspaceFolder:defaultPackage}",
35+
"name": "Release PackageExe",
36+
"program": "${workspaceFolder:defaultPackage}/.build/release/PackageExe",
37+
"preLaunchTask": "swift: Build Release PackageExe"
2038
}
2139
]
2240
}

src/debugger/lldb.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export function updateLaunchConfigForCI(
3838
// Tell LLDB not to disable ASLR when running in Docker CI https://stackoverflow.com/a/78471987
3939
result.disableASLR = false;
4040
result.initCommands = ["settings set target.disable-aslr false"];
41-
result.runInTerminal = process.platform !== "win32";
4241
return result;
4342
}
4443

src/debugger/logTracker.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class LoggingDebugAdapterTracker implements vscode.DebugAdapterTracker {
6868
private static debugSessionIdMap: { [id: string]: LoggingDebugAdapterTracker } = {};
6969

7070
private cb?: (output: string) => void;
71+
private output: string[] = [];
7172

7273
constructor(public id: string) {
7374
LoggingDebugAdapterTracker.debugSessionIdMap[id] = this;
@@ -81,6 +82,10 @@ export class LoggingDebugAdapterTracker implements vscode.DebugAdapterTracker {
8182
const loggingDebugAdapter = this.debugSessionIdMap[session.id];
8283
if (loggingDebugAdapter) {
8384
loggingDebugAdapter.cb = cb;
85+
for (const o of loggingDebugAdapter.output) {
86+
cb(o);
87+
}
88+
loggingDebugAdapter.output = [];
8489
} else {
8590
outputChannel.appendLine("Could not find debug adapter for session: " + session.id);
8691
}
@@ -93,13 +98,20 @@ export class LoggingDebugAdapterTracker implements vscode.DebugAdapterTracker {
9398
onDidSendMessage(message: unknown): void {
9499
const debugMessage = message as DebugMessage;
95100
if (
96-
this.cb &&
97-
debugMessage &&
98-
debugMessage.type === "event" &&
99-
debugMessage.event === "output" &&
100-
debugMessage.body.category !== "console"
101+
!(
102+
debugMessage &&
103+
debugMessage.type === "event" &&
104+
debugMessage.event === "output" &&
105+
debugMessage.body.category !== "console"
106+
)
101107
) {
102-
this.cb(debugMessage.body.output);
108+
return;
109+
}
110+
const output = debugMessage.body.output;
111+
if (this.cb) {
112+
this.cb(output);
113+
} else {
114+
this.output.push(output);
103115
}
104116
}
105117

0 commit comments

Comments
 (0)