Embedding V8: How to make Chrome Dev Tools show the JavaScript source

493 views
Skip to first unread message

DaManuell

unread,
Apr 11, 2019, 10:29:13 AM4/11/19
to v8-users

DaManuell

unread,
Apr 12, 2019, 4:17:40 AM4/12/19
to v8-users
I used CDT on CDT to record the WebSocket Traffic between Chrome and my embedding app.

Sent by Chrome to my app:
{"id":1,"method":"Profiler.enable"}
{"id":2,"method":"Runtime.enable"}
{"id":3,"method":"Debugger.enable"}
{"id":4,"method":"Debugger.setPauseOnExceptions","params":{"state":"none"}}
{"id":5,"method":"Debugger.setAsyncCallStackDepth","params":{"maxDepth":32}}
{"id":6,"method":"Debugger.setBlackboxPatterns","params":{"patterns":[]}}
{"id":7,"method":"Runtime.runIfWaitingForDebugger"}

Sent by my app to chrome:
{"id":1,"result":{}}
{"method":"Runtime.executionContextCreated","params":{"context":{"id":1,"origin":"","name":"MyApp"}}}
{"id":2,"result":{}}
{"method":"Debugger.scriptParsed","params":{"scriptId":"4","url":"func_add.js","startLine":0,"startColumn":0,"endLine":2,"endColumn":2,"executionContextId":1,"hash":"1445a7804cf3405670df7a539876752304d4fa3a","isLiveEdit":false,"sourceMapURL":"","hasSourceURL":false,"isModule":false,"length":37}}
{"id":3,"result":{"debuggerId":"(1FEE5CC1932E43F4AC090457F0333F66)"}}
{"id":4,"result":{}}
{"id":5,"result":{}}
{"id":6,"result":{}}
{"id":7,"result":{}}

Chrome does not send the "Debugger.getScriptSource" request...

Le jeudi 11 avril 2019 16:29:13 UTC+2, DaManuell a écrit :

Alexey Shcherbyna

unread,
Apr 12, 2019, 5:12:49 AM4/12/19
to v8-u...@googlegroups.com
Hi, my suggestions are:
1) to double check if the path to your sources is correct and accessible
2) put script source as parameter when you compile script in v8

#if defined(DEBUG)
auto src = File::ReadText(filename);
auto originName = "file://" + filename;
v8::ScriptOrigin origin(ArgConverter::ConvertToV8String(isolate, originName));
script = v8::Script::Compile(getContext(), sourcePersistent.Get(isolate), &origin);

#else
script = v8::Script::Compile(getContext(), sourcePersistent.Get(isolate));
#endif // DEBUG

пт, 12 апр. 2019 г. в 11:17, DaManuell <manuel....@gmail.com>:
--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

DaManuell

unread,
Apr 12, 2019, 7:25:48 AM4/12/19
to v8-users
Thank you. Your suggestion made me review my code.
The version I used when playing with the v8::ScriptOrigin using "file://" url was missing the infamous third slash before D:...
Now, my file is visible in CDT, and I can put a breakpoint (which makes my embedding process crashes immediately for some threading issues, but that was "expected", in a way...)

But why is CDT asking me for the Script source via:
{"id":8,"method":"Debugger.getScriptSource","params":{"scriptId":"4"}} ?
Does that means that I just have to provide a well formed url when compiling and that CDT will ask me for the source anyway?
If so, what kind of "ScriptOrigin" value should I give to "Compile" when the script is a scriptlet not backed up by a file?
Reply all
Reply to author
Forward
0 new messages