Bug 161658 - Web Inspector: Stepping through `a(); b(); c();` it is unclear where we are and what is about to execute
Summary: Web Inspector: Stepping through `a(); b(); c();` it is unclear where we are a...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
: 161660 (view as bug list)
Depends on: 155325
Blocks: 162753
  Show dependency treegraph
 
Reported: 2016-09-06 17:06 PDT by Joseph Pecoraro
Modified: 2016-09-30 17:58 PDT (History)
9 users (show)

See Also:


Attachments
[IMAGE] Multiple Statements on one line (185.54 KB, image/png)
2016-09-28 13:50 PDT, Joseph Pecoraro
no flags Details
[IMAGE] Multiple Function Calls on One Line (step-in and step-out) (185.31 KB, image/png)
2016-09-28 13:50 PDT, Joseph Pecoraro
no flags Details
[IMAGE] Condition / Loop expressions (322.07 KB, image/png)
2016-09-28 13:51 PDT, Joseph Pecoraro
no flags Details
[IMAGE] Inside Function Call (looking at parent call frame) (336.61 KB, image/png)
2016-09-28 13:52 PDT, Joseph Pecoraro
no flags Details
[IMAGE] Multi-line statement (275.78 KB, image/png)
2016-09-28 13:52 PDT, Joseph Pecoraro
no flags Details
[PATCH] Proposed Fix (29.56 KB, patch)
2016-09-28 13:59 PDT, Joseph Pecoraro
ggaren: review+
joepeck: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2016-09-06 17:06:42 PDT
Summary:
Stepping through `a(); b(); c();` it is unclear where we are and what is about to execute

Test:
1. <script>
2. function a() { console.log("a"); }
3. function b() { console.log("b"); }
4. function c() { console.log("c"); }
5. a(); b(); c();
6. <script>

Steps to Reproduce:
1. Inspect test page
2. Set a breakpoint on line 5
3. Reload
4. Step over multiple times
  => Same line highlights, it is unclear what is about to execute

Notes:
- We have a line/column. We can highlight from that position onward.
  - I think Chrome does this as well
Comment 1 Radar WebKit Bug Importer 2016-09-06 17:07:17 PDT
<rdar://problem/28181254>
Comment 2 Joseph Pecoraro 2016-09-08 10:52:59 PDT
- Safari just shows the line you are paused on with no info about where
- Firefox just shows the line you are paused on with no info about where
- Chrome shows the line you are paused on and highlights the pause point to the end of the line indicating what is next to be evaluated. This breaks down for multiline expressions.
- Edge highlights the entire statement that is about to be evaluated. This breaks down when there are multiple subexpressions that are calls.

I think the ideal highlight would be both the statement and the expression within the statement that is about to be evaluated.

Take these example lines:

    a(); b(); c();
    a() + b() + c();

The first has 3 statements, highlighting the entire statement makes it clear where you are stepping. The second has one statement with 3 calls that can be stepped into. It would be good to highlight exactly which call you are about to make.

This should be doable on the frontend with an AST. Determine the (1) Statement the pause location is in and (2) determine if there is a CallExpression (or anything that can be stepped-into) at the current pause location. I might be overlooking something obvious.

Likewise, the "highlight the line onward" approach is a very simple and easy approach that I should be able to get done quickly in the meantime.
Comment 3 Joseph Pecoraro 2016-09-28 13:46:17 PDT
Using Esprima (inside JS files, not yet inside <script> for HTML) we can highlight more accurately what statement/expression we are inside of / about to execute.
Comment 4 Joseph Pecoraro 2016-09-28 13:50:15 PDT
Created attachment 290113 [details]
[IMAGE] Multiple Statements on one line
Comment 5 Joseph Pecoraro 2016-09-28 13:50:42 PDT
Created attachment 290114 [details]
[IMAGE] Multiple Function Calls on One Line (step-in and step-out)
Comment 6 Joseph Pecoraro 2016-09-28 13:51:26 PDT
Created attachment 290115 [details]
[IMAGE] Condition / Loop expressions
Comment 7 Joseph Pecoraro 2016-09-28 13:52:00 PDT
Created attachment 290116 [details]
[IMAGE] Inside Function Call (looking at parent call frame)
Comment 8 Joseph Pecoraro 2016-09-28 13:52:20 PDT
Created attachment 290117 [details]
[IMAGE] Multi-line statement
Comment 9 Joseph Pecoraro 2016-09-28 13:59:38 PDT
Created attachment 290118 [details]
[PATCH] Proposed Fix

Blocked by other patches that have not yet landed.
Comment 10 Geoffrey Garen 2016-09-28 14:30:59 PDT
Comment on attachment 290118 [details]
[PATCH] Proposed Fix

r=me
Comment 11 Joseph Pecoraro 2016-09-30 12:37:28 PDT
<https://trac.webkit.org/changeset/206654>
Comment 12 Joseph Pecoraro 2016-09-30 16:38:01 PDT
Follow-up for better locations in call stacks with failures due to unary operations:
<https://trac.webkit.org/changeset/206677>
Comment 13 Joseph Pecoraro 2016-09-30 17:58:08 PDT
*** Bug 161660 has been marked as a duplicate of this bug. ***