简体   繁体   中英

How do I run a v8 engine standalone and debug with Chrome DevTools

I built a v8 binary for my platform (MacOS).

I could start a v8 shell by executing that binary and run arbitrary JS code.

bash-$ ./v8
v8> var foo = 42
v8> 42

What I want is to somehow use chrome devtools as the debugging front-end for this v8 instance, like how I can use devtools for remote-debugging another chrome instance.

To put simply, something like this

bash-$ ./v8 --remote-debugging-port=9222

Since NodeJS already has good support for Chrome DevTools, I forked NodeJS and tweaked it to run my code in vanilla V8 environment.

Build my fork: https://github.com/joelewis/node

Then run the binary:

$ /out/Debug/node --inspect --inspect-brk mycode.js

This will open Chrome DevTools window with a breakpoint in the first line of mycode.js. In this environment there's no NodeJS globals (like require, exports, module). It's a pure V8 environment!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM