Bug 162848 - Web Inspector: Show return value when stepping out of a function
Summary: Web Inspector: Show return value when stepping out of a function
Status: NEW
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
Depends on:
Blocks:
 
Reported: 2016-10-01 16:55 PDT by Joseph Pecoraro
Modified: 2016-12-13 15:37 PST (History)
4 users (show)

See Also:


Attachments
[WIP] Return Value when leaving function (35.28 KB, patch)
2016-10-17 12:03 PDT, Joseph Pecoraro
joepeck: review-
Details | Formatted Diff | Diff
[WIP] Last Returned Value (45.38 KB, patch)
2016-10-17 12:03 PDT, Joseph Pecoraro
joepeck: review-
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-10-01 16:55:51 PDT
Summary:
Show return value when stepping out of a function

When stepping out of a function, or when stepping through an leaving it (paused at the closing brace) we should show the return value somewhere in the UI. Often it is the result of a computation and it would be useful for the user to see + interact with it.
Comment 1 Radar WebKit Bug Importer 2016-10-01 16:56:03 PDT
<rdar://problem/28579565>
Comment 2 Joseph Pecoraro 2016-10-17 12:03:11 PDT
Created attachment 291853 [details]
[WIP] Return Value when leaving function

This didn't handle stepping out of Constructors, where the op_debug is not immediately before an op_return.
Comment 3 Joseph Pecoraro 2016-10-17 12:03:48 PDT
Created attachment 291854 [details]
[WIP] Last Returned Value

This adds in Last Return Value whenever you step over / step out of a function call.
Comment 4 Joseph Pecoraro 2016-10-17 12:09:52 PDT
After playing with these I believe they are a little too simplistic. They depend on op_ret which doesn't happen for Native/Host functions, so it ends up missing return values of host functions (e.g. the `undefined` from `console.log(1)`).

I think a better approach would be:

  - When compiling with DebugHooks, replace op_call* with op_debug_call*
  - Which would be equivalent to:

        op_debug BeforeCall
        op_call ...
        op_debug AfterCall

  - Currently we have BeforeCall but not AfterCall.
    - BeforeCall is used as a pause opportunity.
    - AfterCall is can be used to save the return value for the next pause opportunity.
    - AfterCall may eventually be useful as a pause opportunity for stepping out.

So that is why I put up two patches. I think we still end up taking the original patch for "Return Value when leaving function" because this is right before we are leaving the function. it just needs to address the Constructor edge case and get tests. However to get "Last Returned Value" working everywhere I think we need a better approach like the one above.