Google Chrome Remote Debugging Protocol: Cannot Get Scope

I am writing a custom debugger for Google Chrome using the Remote Debugging Protocol . My debugger works fine, except that it cannot access the function area. I listen to the Debugger.paused event and the listener receives an array of CallFrame s. I get a closure area from each frame and so I can get all the associated variables with my properties. Among these variables are functions. I send Runtime.getProperties with the identifier of one of the functions in Chrome and get its properties. And here is what I get in response:

 { "result":[ { "configurable":false, "enumerable":false, "isOwn":true, "name":"length", "value":{ "description":"0", "type":"number", "value":0 }, "writable":false }, { "configurable":false, "enumerable":false, "isOwn":true, "name":"name", "value":{ "type":"string", "value":"" }, "writable":false }, { "configurable":false, "enumerable":false, "get":{ "className":"Function", "description":"function ThrowTypeError() { [native code] }", "objectId":"{\"injectedScriptId\":3,\"id\":34}", "type":"function" }, "isOwn":true,"name":"arguments", "set":{ "className":"Function", "description":"function ThrowTypeError() { [native code] }", "objectId":"{\"injectedScriptId\":3,\"id\":35}", "type":"function" } }, { "configurable":false, "enumerable":false, "get":{ "className":"Function", "description":"function ThrowTypeError() { [native code] }", "objectId":"{\"injectedScriptId\":3,\"id\":36}", "type":"function" }, "isOwn":true, "name":"caller", "set":{ "className":"Function", "description":"function ThrowTypeError() { [native code] }", "objectId":"{\"injectedScriptId\":3,\"id\":37}", "type":"function" } }, { "configurable":false, "enumerable":false, "isOwn":true, "name":"prototype", "value":{ "className":"Object", "description":"Object", "objectId":"{\"injectedScriptId\":3,\"id\":38}", "type":"object" }, "writable":true }, { "configurable":true, "enumerable":false, "isOwn":true, "name":"__proto__", "value":{ "className":"Function", "description":"function Empty() {}", "objectId":"{\"injectedScriptId\":3,\"id\":39}", "type":"function" }, "writable":true } ] } 

As you can see, there is no <function scope> property. However, when I debug the same code and stop in the same place, I can open closure$return<function scope> . I really need this because $ return is a callback that contains related variables in its scope, so by moving through the callback closure chain, I can rebuild the stack trace.

+5
source share

Source: https://habr.com/ru/post/1213381/


All Articles