Skip to content

Commit b704a1b

Browse files
committed
Don't clear the pause reason for other threads when processing a stopped event with allThreadsStopped=true
Fix #165032
1 parent caf921d commit b704a1b

File tree

7 files changed

+93
-40
lines changed

7 files changed

+93
-40
lines changed

src/vs/workbench/contrib/debug/browser/debugSession.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ export class DebugSession implements IDebugSession {
889889
// whether the thread is stopped or not
890890
if (stoppedDetails.allThreadsStopped) {
891891
this.threads.forEach(thread => {
892-
thread.stoppedDetails = thread.threadId === stoppedDetails.threadId ? stoppedDetails : { reason: undefined };
892+
thread.stoppedDetails = thread.threadId === stoppedDetails.threadId ? stoppedDetails : { reason: thread.stoppedDetails?.reason };
893893
thread.stopped = true;
894894
thread.clearCallStack();
895895
});

src/vs/workbench/contrib/debug/test/browser/baseDebugView.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlighte
1111
import { LinkDetector } from 'vs/workbench/contrib/debug/browser/linkDetector';
1212
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
1313
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
14-
import { createMockSession } from 'vs/workbench/contrib/debug/test/browser/callStack.test';
14+
import { createTestSession } from 'vs/workbench/contrib/debug/test/browser/callStack.test';
1515
import { isStatusbarInDebugMode } from 'vs/workbench/contrib/debug/browser/statusbarColorProvider';
1616
import { State } from 'vs/workbench/contrib/debug/common/debug';
1717
import { isWindows } from 'vs/base/common/platform';
@@ -132,8 +132,8 @@ suite('Debug - Base Debug View', () => {
132132

133133
test('statusbar in debug mode', () => {
134134
const model = createMockDebugModel();
135-
const session = createMockSession(model);
136-
const session2 = createMockSession(model, undefined, { suppressDebugStatusbar: true });
135+
const session = createTestSession(model);
136+
const session2 = createTestSession(model, undefined, { suppressDebugStatusbar: true });
137137
assert.strictEqual(isStatusbarInDebugMode(State.Inactive, []), false);
138138
assert.strictEqual(isStatusbarInDebugMode(State.Initializing, [session]), false);
139139
assert.strictEqual(isStatusbarInDebugMode(State.Running, [session]), true);

src/vs/workbench/contrib/debug/test/browser/breakpoints.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { createBreakpointDecorations } from 'vs/workbench/contrib/debug/browser/
1414
import { OverviewRulerLane } from 'vs/editor/common/model';
1515
import { MarkdownString } from 'vs/base/common/htmlContent';
1616
import { createTextModel } from 'vs/editor/test/common/testTextModel';
17-
import { createMockSession } from 'vs/workbench/contrib/debug/test/browser/callStack.test';
17+
import { createTestSession } from 'vs/workbench/contrib/debug/test/browser/callStack.test';
1818
import { createMockDebugModel, MockDebugService } from 'vs/workbench/contrib/debug/test/browser/mockDebug';
1919
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
2020
import { ILanguageService } from 'vs/editor/common/languages/language';
@@ -174,7 +174,7 @@ suite('Debug - Breakpoints', () => {
174174
const modelUri = uri.file('/myfolder/myfile.js');
175175
addBreakpointsAndCheckEvents(model, modelUri, [{ lineNumber: 5, enabled: true, condition: 'x > 5' }, { lineNumber: 10, enabled: false }]);
176176
const breakpoints = model.getBreakpoints();
177-
const session = createMockSession(model);
177+
const session = createTestSession(model);
178178
const data = new Map<string, DebugProtocol.Breakpoint>();
179179

180180
assert.strictEqual(breakpoints[0].lineNumber, 5);
@@ -186,7 +186,7 @@ suite('Debug - Breakpoints', () => {
186186
assert.strictEqual(breakpoints[0].lineNumber, 5);
187187
assert.strictEqual(breakpoints[1].lineNumber, 50);
188188

189-
const session2 = createMockSession(model);
189+
const session2 = createTestSession(model);
190190
const data2 = new Map<string, DebugProtocol.Breakpoint>();
191191
data2.set(breakpoints[0].getId(), { verified: true, line: 100 });
192192
data2.set(breakpoints[1].getId(), { verified: true, line: 500 });

src/vs/workbench/contrib/debug/test/browser/callStack.test.ts

+70-17
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const mockWorkspaceContextService = {
2929
}
3030
} as any;
3131

32-
export function createMockSession(model: DebugModel, name = 'mockSession', options?: IDebugSessionOptions): DebugSession {
32+
export function createTestSession(model: DebugModel, name = 'mockSession', options?: IDebugSessionOptions): DebugSession {
3333
return new DebugSession(generateUuid(), { resolved: { name, type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, options, {
3434
getViewModel(): any {
3535
return {
@@ -79,7 +79,7 @@ suite('Debug - CallStack', () => {
7979
test('threads simple', () => {
8080
const threadId = 1;
8181
const threadName = 'firstThread';
82-
const session = createMockSession(model);
82+
const session = createTestSession(model);
8383
model.addSession(session);
8484

8585
assert.strictEqual(model.getSessions(true).length, 1);
@@ -98,15 +98,15 @@ suite('Debug - CallStack', () => {
9898
assert.strictEqual(model.getSessions(true).length, 1);
9999
});
100100

101-
test('threads multiple wtih allThreadsStopped', async () => {
101+
test('threads multiple with allThreadsStopped', async () => {
102102
const threadId1 = 1;
103103
const threadName1 = 'firstThread';
104104
const threadId2 = 2;
105105
const threadName2 = 'secondThread';
106106
const stoppedReason = 'breakpoint';
107107

108108
// Add the threads
109-
const session = createMockSession(model);
109+
const session = createTestSession(model);
110110
model.addSession(session);
111111

112112
session['raw'] = <any>rawSession;
@@ -178,15 +178,68 @@ suite('Debug - CallStack', () => {
178178
assert.strictEqual(session.getAllThreads().length, 0);
179179
});
180180

181-
test('threads mutltiple without allThreadsStopped', async () => {
181+
test('allThreadsStopped in multiple events', async () => {
182+
const threadId1 = 1;
183+
const threadName1 = 'firstThread';
184+
const threadId2 = 2;
185+
const threadName2 = 'secondThread';
186+
const stoppedReason = 'breakpoint';
187+
188+
// Add the threads
189+
const session = createTestSession(model);
190+
model.addSession(session);
191+
192+
session['raw'] = <any>rawSession;
193+
194+
// Stopped event with all threads stopped
195+
model.rawUpdate({
196+
sessionId: session.getId(),
197+
threads: [{
198+
id: threadId1,
199+
name: threadName1
200+
}, {
201+
id: threadId2,
202+
name: threadName2
203+
}],
204+
stoppedDetails: {
205+
reason: stoppedReason,
206+
threadId: threadId1,
207+
allThreadsStopped: true
208+
},
209+
});
210+
211+
model.rawUpdate({
212+
sessionId: session.getId(),
213+
threads: [{
214+
id: threadId1,
215+
name: threadName1
216+
}, {
217+
id: threadId2,
218+
name: threadName2
219+
}],
220+
stoppedDetails: {
221+
reason: stoppedReason,
222+
threadId: threadId2,
223+
allThreadsStopped: true
224+
},
225+
});
226+
227+
const thread1 = session.getThread(threadId1)!;
228+
const thread2 = session.getThread(threadId2)!;
229+
230+
assert.strictEqual(thread1.stoppedDetails?.reason, stoppedReason);
231+
assert.strictEqual(thread2.stoppedDetails?.reason, stoppedReason);
232+
});
233+
234+
test('threads multiple without allThreadsStopped', async () => {
182235
const sessionStub = sinon.spy(rawSession, 'stackTrace');
183236

184237
const stoppedThreadId = 1;
185238
const stoppedThreadName = 'stoppedThread';
186239
const runningThreadId = 2;
187240
const runningThreadName = 'runningThread';
188241
const stoppedReason = 'breakpoint';
189-
const session = createMockSession(model);
242+
const session = createTestSession(model);
190243
model.addSession(session);
191244

192245
session['raw'] = <any>rawSession;
@@ -258,7 +311,7 @@ suite('Debug - CallStack', () => {
258311
});
259312

260313
test('stack frame get specific source name', () => {
261-
const session = createMockSession(model);
314+
const session = createTestSession(model);
262315
model.addSession(session);
263316
const { firstStackFrame, secondStackFrame } = createTwoStackFrames(session);
264317

@@ -267,7 +320,7 @@ suite('Debug - CallStack', () => {
267320
});
268321

269322
test('stack frame toString()', () => {
270-
const session = createMockSession(model);
323+
const session = createTestSession(model);
271324
const thread = new Thread(session, 'mockthread', 1);
272325
const firstSource = new Source({
273326
name: 'internalModule.js',
@@ -283,17 +336,17 @@ suite('Debug - CallStack', () => {
283336
});
284337

285338
test('debug child sessions are added in correct order', () => {
286-
const session = createMockSession(model);
339+
const session = createTestSession(model);
287340
model.addSession(session);
288-
const secondSession = createMockSession(model, 'mockSession2');
341+
const secondSession = createTestSession(model, 'mockSession2');
289342
model.addSession(secondSession);
290-
const firstChild = createMockSession(model, 'firstChild', { parentSession: session });
343+
const firstChild = createTestSession(model, 'firstChild', { parentSession: session });
291344
model.addSession(firstChild);
292-
const secondChild = createMockSession(model, 'secondChild', { parentSession: session });
345+
const secondChild = createTestSession(model, 'secondChild', { parentSession: session });
293346
model.addSession(secondChild);
294-
const thirdSession = createMockSession(model, 'mockSession3');
347+
const thirdSession = createTestSession(model, 'mockSession3');
295348
model.addSession(thirdSession);
296-
const anotherChild = createMockSession(model, 'secondChild', { parentSession: secondSession });
349+
const anotherChild = createTestSession(model, 'secondChild', { parentSession: secondSession });
297350
model.addSession(anotherChild);
298351

299352
const sessions = model.getSessions();
@@ -306,7 +359,7 @@ suite('Debug - CallStack', () => {
306359
});
307360

308361
test('decorations', () => {
309-
const session = createMockSession(model);
362+
const session = createTestSession(model);
310363
model.addSession(session);
311364
const { firstStackFrame, secondStackFrame } = createTwoStackFrames(session);
312365
let decorations = createDecorationsForStackFrame(firstStackFrame, true, false);
@@ -338,7 +391,7 @@ suite('Debug - CallStack', () => {
338391
});
339392

340393
test('contexts', () => {
341-
const session = createMockSession(model);
394+
const session = createTestSession(model);
342395
model.addSession(session);
343396
const { firstStackFrame, secondStackFrame } = createTwoStackFrames(session);
344397
let context = getContext(firstStackFrame);
@@ -378,7 +431,7 @@ suite('Debug - CallStack', () => {
378431
}
379432
}(generateUuid(), { resolved: { name: 'stoppedSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, undefined, undefined!, undefined!, undefined!, undefined!, undefined!, mockWorkspaceContextService, undefined!, undefined!, undefined!, mockUriIdentityService, new TestInstantiationService(), undefined!, undefined!);
380433

381-
const runningSession = createMockSession(model);
434+
const runningSession = createTestSession(model);
382435
model.addSession(runningSession);
383436
model.addSession(session);
384437

src/vs/workbench/contrib/debug/test/browser/debugANSIHandling.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ansiColorMap } from 'vs/workbench/contrib/terminal/common/terminalColor
1616
import { DebugModel } from 'vs/workbench/contrib/debug/common/debugModel';
1717
import { DebugSession } from 'vs/workbench/contrib/debug/browser/debugSession';
1818
import { createMockDebugModel } from 'vs/workbench/contrib/debug/test/browser/mockDebug';
19-
import { createMockSession } from 'vs/workbench/contrib/debug/test/browser/callStack.test';
19+
import { createTestSession } from 'vs/workbench/contrib/debug/test/browser/callStack.test';
2020
import { DisposableStore } from 'vs/base/common/lifecycle';
2121

2222
suite('Debug - ANSI Handling', () => {
@@ -33,7 +33,7 @@ suite('Debug - ANSI Handling', () => {
3333
setup(() => {
3434
disposables = new DisposableStore();
3535
model = createMockDebugModel();
36-
session = createMockSession(model);
36+
session = createTestSession(model);
3737

3838
const instantiationService: TestInstantiationService = <TestInstantiationService>workbenchInstantiationService(undefined, disposables);
3939
linkDetector = instantiationService.createInstance(LinkDetector);

src/vs/workbench/contrib/debug/test/browser/debugHover.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as assert from 'assert';
77
import { findExpressionInStackFrame } from 'vs/workbench/contrib/debug/browser/debugHover';
8-
import { createMockSession } from 'vs/workbench/contrib/debug/test/browser/callStack.test';
8+
import { createTestSession } from 'vs/workbench/contrib/debug/test/browser/callStack.test';
99
import { StackFrame, Thread, Scope, Variable } from 'vs/workbench/contrib/debug/common/debugModel';
1010
import { Source } from 'vs/workbench/contrib/debug/common/debugSource';
1111
import type { IScope, IExpression } from 'vs/workbench/contrib/debug/common/debug';
@@ -14,7 +14,7 @@ import { createMockDebugModel, mockUriIdentityService } from 'vs/workbench/contr
1414
suite('Debug - Hover', () => {
1515
test('find expression in stack frame', async () => {
1616
const model = createMockDebugModel();
17-
const session = createMockSession(model);
17+
const session = createTestSession(model);
1818

1919
const thread = new class extends Thread {
2020
public override getCallStack(): StackFrame[] {

src/vs/workbench/contrib/debug/test/browser/repl.test.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { MockRawSession, MockDebugAdapter, createMockDebugModel } from 'vs/workb
1111
import { SimpleReplElement, RawObjectReplElement, ReplEvaluationInput, ReplModel, ReplEvaluationResult, ReplGroup } from 'vs/workbench/contrib/debug/common/replModel';
1212
import { RawDebugSession } from 'vs/workbench/contrib/debug/browser/rawDebugSession';
1313
import { timeout } from 'vs/base/common/async';
14-
import { createMockSession } from 'vs/workbench/contrib/debug/test/browser/callStack.test';
14+
import { createTestSession } from 'vs/workbench/contrib/debug/test/browser/callStack.test';
1515
import { ReplFilter } from 'vs/workbench/contrib/debug/browser/replFilter';
1616
import { TreeVisibility } from 'vs/base/browser/ui/tree/tree';
1717
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
@@ -27,7 +27,7 @@ suite('Debug - REPL', () => {
2727
});
2828

2929
test('repl output', () => {
30-
const session = createMockSession(model);
30+
const session = createTestSession(model);
3131
const repl = new ReplModel(configurationService);
3232
repl.appendToRepl(session, 'first line\n', severity.Error);
3333
repl.appendToRepl(session, 'second line ', severity.Error);
@@ -85,7 +85,7 @@ suite('Debug - REPL', () => {
8585
});
8686

8787
test('repl output count', () => {
88-
const session = createMockSession(model);
88+
const session = createTestSession(model);
8989
const repl = new ReplModel(configurationService);
9090
repl.appendToRepl(session, 'first line\n', severity.Info);
9191
repl.appendToRepl(session, 'first line\n', severity.Info);
@@ -107,11 +107,11 @@ suite('Debug - REPL', () => {
107107

108108
test('repl merging', () => {
109109
// 'mergeWithParent' should be ignored when there is no parent.
110-
const parent = createMockSession(model, 'parent', { repl: 'mergeWithParent' });
111-
const child1 = createMockSession(model, 'child1', { parentSession: parent, repl: 'separate' });
112-
const child2 = createMockSession(model, 'child2', { parentSession: parent, repl: 'mergeWithParent' });
113-
const grandChild = createMockSession(model, 'grandChild', { parentSession: child2, repl: 'mergeWithParent' });
114-
const child3 = createMockSession(model, 'child3', { parentSession: parent });
110+
const parent = createTestSession(model, 'parent', { repl: 'mergeWithParent' });
111+
const child1 = createTestSession(model, 'child1', { parentSession: parent, repl: 'separate' });
112+
const child2 = createTestSession(model, 'child2', { parentSession: parent, repl: 'mergeWithParent' });
113+
const grandChild = createTestSession(model, 'grandChild', { parentSession: child2, repl: 'mergeWithParent' });
114+
const child3 = createTestSession(model, 'child3', { parentSession: parent });
115115

116116
let parentChanges = 0;
117117
parent.onDidChangeReplElements(() => ++parentChanges);
@@ -150,7 +150,7 @@ suite('Debug - REPL', () => {
150150
});
151151

152152
test('repl expressions', () => {
153-
const session = createMockSession(model);
153+
const session = createTestSession(model);
154154
assert.strictEqual(session.getReplElements().length, 0);
155155
model.addSession(session);
156156

@@ -172,7 +172,7 @@ suite('Debug - REPL', () => {
172172
});
173173

174174
test('repl ordering', async () => {
175-
const session = createMockSession(model);
175+
const session = createTestSession(model);
176176
model.addSession(session);
177177

178178
const adapter = new MockDebugAdapter();
@@ -194,7 +194,7 @@ suite('Debug - REPL', () => {
194194
});
195195

196196
test('repl groups', async () => {
197-
const session = createMockSession(model);
197+
const session = createTestSession(model);
198198
const repl = new ReplModel(configurationService);
199199

200200
repl.appendToRepl(session, 'first global line', severity.Info);
@@ -232,7 +232,7 @@ suite('Debug - REPL', () => {
232232
});
233233

234234
test('repl filter', async () => {
235-
const session = createMockSession(model);
235+
const session = createTestSession(model);
236236
const repl = new ReplModel(configurationService);
237237
const replFilter = new ReplFilter();
238238

0 commit comments

Comments
 (0)