Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented displaying data from local variables and arguments in Chr…
…ome DevTools when V8 stopped on debug break point: 1. On break - create Single Synthetic Scope with object id as unique key for frame's variables. This key is used latter by Chrome DevTools for retrieving local variables and arguments. 2. On break event - store local variables and arguments in Runtime. Later (when Debugger.paused is sent) Chrome DevTools asks Runtime for them and displays on UI. 3. Store connected JsonRpcPeer from Debugger.enable as it's required later for storing local variables and arguments in Runtime. 4. Replace Runtime domain with custom class, which override .getProperties() and changes "ownProperties" to true so that stored local variables could be read by Chrome DevTools and displayed on UI. 5.
- Loading branch information
1 parent
49a9cc7
commit fc2987d
Showing
5 changed files
with
130 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
j2v8-debugger/src/main/java/com/alexii/j2v8debugger/Runtime.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.alexii.j2v8debugger | ||
|
||
import com.facebook.stetho.inspector.console.RuntimeReplFactory | ||
import com.facebook.stetho.inspector.jsonrpc.JsonRpcPeer | ||
import com.facebook.stetho.inspector.jsonrpc.JsonRpcResult | ||
import com.facebook.stetho.inspector.protocol.ChromeDevtoolsMethod | ||
import org.json.JSONObject | ||
import com.facebook.stetho.inspector.protocol.module.Runtime as FacebookRuntimeBase | ||
|
||
/** | ||
* V8 JS Debugger. Name of the class and methods must match names defined in Chrome Dev Tools protocol. | ||
* | ||
* [initialize] must be called before actual debugging (adding breakpoints in Chrome DevTools). | ||
* Otherwise setting breakpoint, etc. makes no effect. | ||
*/ | ||
class Runtime( | ||
replFactory: RuntimeReplFactory? | ||
) : FacebookRuntimeBase(replFactory) { | ||
|
||
@ChromeDevtoolsMethod | ||
override fun getProperties(peer: JsonRpcPeer?, params: JSONObject?): JsonRpcResult { | ||
/** | ||
* hack needed to return local variables: Runtime.getProperties called after Debugger.paused. | ||
* https://github.com/facebook/stetho/issues/611 | ||
* xxx: check if it should be conditional for requested related to Debugger only | ||
*/ | ||
|
||
params?.put("ownProperties", true) | ||
|
||
val result = super.getProperties(peer, params) | ||
|
||
return result | ||
} | ||
|
||
@ChromeDevtoolsMethod | ||
override fun releaseObject(peer: JsonRpcPeer?, params: JSONObject?) = super.releaseObject(peer, params) | ||
|
||
@ChromeDevtoolsMethod | ||
override fun releaseObjectGroup(peer: JsonRpcPeer?, params: JSONObject?) = super.releaseObjectGroup(peer, params) | ||
|
||
/** | ||
* Replaces [FacebookRuntimeBase.callFunctionOn] as override can't be used: CallFunctionOnResponse is private (return type) | ||
*/ | ||
//FIXME check why when we add following - Stetho is not working completely | ||
// @ChromeDevtoolsMethod | ||
// fun callFunctionOn(peer: JsonRpcPeer?, params: Any?): JsonRpcResult? = super.callFunctionOn(peer, params as JSONObject?) | ||
|
||
@ChromeDevtoolsMethod | ||
override fun evaluate(peer: JsonRpcPeer?, params: JSONObject?): JsonRpcResult = super.evaluate(peer, params) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters