Skip to content

Commit f3095ec

Browse files
committed
Web Inspector: Debugger: preserve the pause reason and data when stepping over await
https://bugs.webkit.org/show_bug.cgi?id=291670 Reviewed by BJ Burg. Currently the pause reason section of the navigation sidebar in the Sources Tab is empty when stepping over the `await` in code like ```js (async function() { debugger; console.log("before"); await (async function() { return 42; })(); console.log("after"); })() ``` It should show "Debugger Statement" as the pause reason with the debugger breakpoint next to it so that the developer can see why the pause happened in the first place. * Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h: * Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::updatePauseReasonAndData): (Inspector::InspectorDebuggerAgent::didPause): Only override the cached last `DebuggerFrontendDispatcher::Reason` and pause data when the current `DebuggerFrontendDispatcher::Reason` is not invalid so as to preserve why Web Inspector paused even over an async boundary, which normally would clear that information. * Source/JavaScriptCore/debugger/Debugger.h: * Source/JavaScriptCore/debugger/Debugger.cpp: (JSC::Debugger::~Debugger): (JSC::Debugger::pauseIfNeeded): (JSC::Debugger::willAwait): (JSC::Debugger::didAwait): (JSC::Debugger::resetAsyncPauseState): (JSC::Debugger::AbandonPauseInAwaitTimer::AbandonPauseInAwaitTimer): Added. (JSC::Debugger::AbandonPauseInAwaitTimer::doWork): Added. Drive-by: only try to pause when stepping over an `await` so long as it's not been more than 1s as any longer could be confusing (e.g. "why is Web Inspector suddenly pausing?"). * LayoutTests/inspector/debugger/stepping/stepNext-await-expected.txt: * LayoutTests/inspector/debugger/stepping/stepOver-await-expected.txt: Canonical link: https://commits.webkit.org/293844@main
1 parent 27e3e70 commit f3095ec

6 files changed

Lines changed: 132 additions & 86 deletions

File tree

LayoutTests/inspector/debugger/stepping/stepNext-await-expected.txt

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PAUSE AT <anonymous>:7:5
2323
9 }
2424

2525
RESUMED
26-
PAUSED (other)
26+
PAUSED (debugger-statement)
2727
PAUSE AT <anonymous>:8:5
2828
4 async function testStatements() {
2929
5 debugger;
@@ -34,7 +34,7 @@ PAUSE AT <anonymous>:8:5
3434
10
3535

3636
RESUMED
37-
PAUSED (other)
37+
PAUSED (debugger-statement)
3838
PAUSE AT <anonymous>:9:5
3939
5 debugger;
4040
6 let x = await 1;
@@ -67,7 +67,7 @@ PAUSE AT <anonymous>:14:5
6767
16 TestPage.dispatchEventToFrontend("done");
6868

6969
RESUMED
70-
PAUSED (other)
70+
PAUSED (debugger-statement)
7171
PAUSE AT <anonymous>:15:5
7272
11 async function testFunctions() {
7373
12 debugger;
@@ -78,7 +78,7 @@ PAUSE AT <anonymous>:15:5
7878
17 }
7979

8080
RESUMED
81-
PAUSED (other)
81+
PAUSED (debugger-statement)
8282
PAUSE AT <anonymous>:16:5
8383
12 debugger;
8484
13 let before = await 1;
@@ -89,7 +89,7 @@ PAUSE AT <anonymous>:16:5
8989
18
9090

9191
RESUMED
92-
PAUSED (other)
92+
PAUSED (debugger-statement)
9393
PAUSE AT <anonymous>:17:5
9494
13 let before = await 1;
9595
14 await a();
@@ -122,7 +122,7 @@ PAUSE AT <anonymous>:22:5
122122
24 TestPage.dispatchEventToFrontend("done");
123123

124124
RESUMED
125-
PAUSED (other)
125+
PAUSED (debugger-statement)
126126
PAUSE AT <anonymous>:23:5
127127
19 async function testEval() {
128128
20 debugger;
@@ -133,7 +133,7 @@ PAUSE AT <anonymous>:23:5
133133
25 }
134134

135135
RESUMED
136-
PAUSED (other)
136+
PAUSED (debugger-statement)
137137
PAUSE AT <anonymous>:24:5
138138
20 debugger;
139139
21 let before = await 1;
@@ -144,7 +144,7 @@ PAUSE AT <anonymous>:24:5
144144
26
145145

146146
RESUMED
147-
PAUSED (other)
147+
PAUSED (debugger-statement)
148148
PAUSE AT <anonymous>:25:5
149149
21 let before = await 1;
150150
22 await eval("1 + 1");
@@ -177,7 +177,7 @@ PAUSE AT <anonymous>:31:9
177177
33 TestPage.dispatchEventToFrontend("done");
178178

179179
RESUMED
180-
PAUSED (other)
180+
PAUSED (debugger-statement)
181181
PAUSE AT <anonymous>:33:5
182182
29 debugger;
183183
30 let inner = await 1;
@@ -188,7 +188,7 @@ PAUSE AT <anonymous>:33:5
188188
35
189189

190190
RESUMED
191-
PAUSED (other)
191+
PAUSED (debugger-statement)
192192
PAUSE AT <anonymous>:34:5
193193
30 let inner = await 1;
194194
31 })();
@@ -221,7 +221,7 @@ PAUSE AT <anonymous>:39:5
221221
41 await a(), await b(), await c();
222222

223223
RESUMED
224-
PAUSED (other)
224+
PAUSED (debugger-statement)
225225
PAUSE AT <anonymous>:40:9
226226
36 async function testCommas() {
227227
37 debugger;
@@ -232,7 +232,7 @@ PAUSE AT <anonymous>:40:9
232232
42 await true && (await a(), await b(), await c()) && await true;
233233

234234
RESUMED
235-
PAUSED (other)
235+
PAUSED (debugger-statement)
236236
PAUSE AT <anonymous>:41:9
237237
37 debugger;
238238
38 let x = await 1,
@@ -243,7 +243,7 @@ PAUSE AT <anonymous>:41:9
243243
43 TestPage.dispatchEventToFrontend("done");
244244

245245
RESUMED
246-
PAUSED (other)
246+
PAUSED (debugger-statement)
247247
PAUSE AT <anonymous>:42:5
248248
38 let x = await 1,
249249
39 y = await 2,
@@ -254,7 +254,7 @@ PAUSE AT <anonymous>:42:5
254254
44 }
255255

256256
RESUMED
257-
PAUSED (other)
257+
PAUSED (debugger-statement)
258258
PAUSE AT <anonymous>:42:16
259259
38 let x = await 1,
260260
39 y = await 2,
@@ -265,7 +265,7 @@ PAUSE AT <anonymous>:42:16
265265
44 }
266266

267267
RESUMED
268-
PAUSED (other)
268+
PAUSED (debugger-statement)
269269
PAUSE AT <anonymous>:42:27
270270
38 let x = await 1,
271271
39 y = await 2,
@@ -276,7 +276,7 @@ PAUSE AT <anonymous>:42:27
276276
44 }
277277

278278
RESUMED
279-
PAUSED (other)
279+
PAUSED (debugger-statement)
280280
PAUSE AT <anonymous>:43:5
281281
39 y = await 2,
282282
40 z = await 3;
@@ -287,7 +287,7 @@ PAUSE AT <anonymous>:43:5
287287
45
288288

289289
RESUMED
290-
PAUSED (other)
290+
PAUSED (debugger-statement)
291291
PAUSE AT <anonymous>:43:20
292292
39 y = await 2,
293293
40 z = await 3;
@@ -298,7 +298,7 @@ PAUSE AT <anonymous>:43:20
298298
45
299299

300300
RESUMED
301-
PAUSED (other)
301+
PAUSED (debugger-statement)
302302
PAUSE AT <anonymous>:43:31
303303
39 y = await 2,
304304
40 z = await 3;
@@ -309,7 +309,7 @@ PAUSE AT <anonymous>:43:31
309309
45
310310

311311
RESUMED
312-
PAUSED (other)
312+
PAUSED (debugger-statement)
313313
PAUSE AT <anonymous>:43:42
314314
39 y = await 2,
315315
40 z = await 3;
@@ -320,7 +320,7 @@ PAUSE AT <anonymous>:43:42
320320
45
321321

322322
RESUMED
323-
PAUSED (other)
323+
PAUSED (debugger-statement)
324324
PAUSE AT <anonymous>:44:5
325325
40 z = await 3;
326326
41 await a(), await b(), await c();
@@ -353,7 +353,7 @@ PAUSE AT <anonymous>:49:5
353353
51
354354

355355
RESUMED
356-
PAUSED (other)
356+
PAUSED (debugger-statement)
357357
PAUSE AT <anonymous>:49:24
358358
45
359359
46 async function testChainedExpressions() {
@@ -364,7 +364,7 @@ PAUSE AT <anonymous>:49:24
364364
51
365365

366366
RESUMED
367-
PAUSED (other)
367+
PAUSED (debugger-statement)
368368
PAUSE AT <anonymous>:49:37
369369
45
370370
46 async function testChainedExpressions() {
@@ -375,7 +375,7 @@ PAUSE AT <anonymous>:49:37
375375
51
376376

377377
RESUMED
378-
PAUSED (other)
378+
PAUSED (debugger-statement)
379379
PAUSE AT <anonymous>:50:5
380380
46 async function testChainedExpressions() {
381381
47 debugger;
@@ -408,7 +408,7 @@ PAUSE AT <anonymous>:55:5
408408
57 TestPage.dispatchEventToFrontend("done");
409409

410410
RESUMED
411-
PAUSED (other)
411+
PAUSED (debugger-statement)
412412
PAUSE AT <anonymous>:56:9
413413
52 async function testDeclarations() {
414414
53 debugger;
@@ -419,7 +419,7 @@ PAUSE AT <anonymous>:56:9
419419
58 }
420420

421421
RESUMED
422-
PAUSED (other)
422+
PAUSED (debugger-statement)
423423
PAUSE AT <anonymous>:57:9
424424
53 debugger;
425425
54 let x = await a(),
@@ -430,7 +430,7 @@ PAUSE AT <anonymous>:57:9
430430
59
431431

432432
RESUMED
433-
PAUSED (other)
433+
PAUSED (debugger-statement)
434434
PAUSE AT <anonymous>:58:5
435435
54 let x = await a(),
436436
55 y = await b(),
@@ -494,7 +494,7 @@ PAUSE AT <anonymous>:74:16
494494
76 TestPage.dispatchEventToFrontend("done");
495495

496496
RESUMED
497-
PAUSED (other)
497+
PAUSED (debugger-statement)
498498
PAUSE AT <anonymous>:75:9
499499
71 async function testFor() {
500500
72 debugger;
@@ -514,7 +514,7 @@ PAUSE AT <anonymous>:74:16
514514
76 TestPage.dispatchEventToFrontend("done");
515515

516516
RESUMED
517-
PAUSED (other)
517+
PAUSED (debugger-statement)
518518
PAUSE AT <anonymous>:75:9
519519
71 async function testFor() {
520520
72 debugger;
@@ -534,7 +534,7 @@ PAUSE AT <anonymous>:74:16
534534
76 TestPage.dispatchEventToFrontend("done");
535535

536536
RESUMED
537-
PAUSED (other)
537+
PAUSED (debugger-statement)
538538
PAUSE AT <anonymous>:77:5
539539
73 for await (let item of [a(), b()]) {
540540
74 c();
@@ -576,7 +576,7 @@ PAUSE AT <anonymous>:86:9
576576
88 if (state === 2)
577577

578578
RESUMED
579-
PAUSED (other)
579+
PAUSED (debugger-statement)
580580
PAUSE AT <anonymous>:87:13
581581
83 if (state === 1)
582582
84 await a(); // should not pause on this line

0 commit comments

Comments
 (0)