简体   繁体   English

使用Chrome devTools和Inspector API嵌入V8引擎调试

[英]Embed V8 engine debug using chrome devTools and inspector api

I try to add inspector in my application that embed v8 engine. 我尝试在嵌入v8引擎的应用程序中添加检查器。

All my try failed, so i try to look on node.js implementation : it's to heavy, so i switch to inspector-test and d8 from v8 soucres. 我所有的尝试都失败了,所以我尝试着看一下node.js的实现:它很繁重,所以我从v8源代码切换到了inspector-test和d8。 But i don't found how connect it to chrome :( 但是我没有找到如何将其连接到chrome :(

So before continue dev, i will want to establish a debug connection between chrome and a debuggable application like d8 or v8_shell to analyse how it work. 因此,在继续开发之前,我将要在chrome和可调试应用程序(例如d8或v8_shell)之间建立调试连接,以分析其工作方式。

My question : how to connect "inspector-test or d8 or v8_shell" to chrome://inspect/#devices on the same computer. 我的问题:如何将“ inspector-test或d8或v8_shell”连接到同一台计算机上的chrome:// inspect /#devices。

Thanks for your help 谢谢你的帮助

1 : Be sure to understand this : 1:请务必了解以下内容:

=> https://github.com/v8/v8/wiki/Embedder%27s-Guide (very important) => https://github.com/v8/v8/wiki/Embedder%27s-Guide (非常重要)

2 : Compile your own version of v8, the goal is to understand a lot a things (when you found how do this it will be your first victory and you way use precompiled version). 2:编译自己的v8版本,目标是要了解很多东西(当您发现如何做到这一点将是您的第一个胜利,并且您将使用预编译的版本)。

=> Under windows it's a nightmare and you need VS2015 some extra lib. =>在Windows下这是一场噩梦,而VS2015需要一些额外的库。

=> The simple & safe way is to setup an ubuntu virtual machine. =>简单安全的方法是设置ubuntu虚拟机。

3 : Read the code of D8 (include in v8 source), D for debug and inspector-test.cc . 3:读取D8(包含在v8源代码中),D的代码以进行调试和inspector-test.cc。

=> It a minimal debugger (no communication with frontend). =>它是最小的调试器(与前端无通讯)。

=> Can be done online : https://cs.chromium.org/chromium/src/v8/src/d8.cc?type=cs&q=InspectorClient+package:%5Echromium $&l=1916 =>可以在线完成: https : //cs.chromium.org/chromium/src/v8/src/d8.cc? type=cs&q=InspectorClient+package:% 5Echromium $&l = 1916

=> https://cs.chromium.org/chromium/src/v8/test/inspector/inspector-test.cc?q=inspector-te+package:%5Echromium $&l=1 => https://cs.chromium.org/chromium/src/v8/test/inspector/inspector-test.cc?q=inspector-te+package:%5Echromium $&l = 1

4 : Lock at Node.js source code there's a complete integration of debugger with Chrome as front-end, but the code is connected with node internal framework it's not easy to remove all un-need things... 4:锁定Node.js源代码,将调试器与Chrome作为前端进行了完全集成,但是该代码与节点内部框架相连,要删除所有不需要的东西并不容易...

=> This link may help : https://github.com/nodejs/node/pull/6792 =>此链接可能有帮助: https : //github.com/nodejs/node/pull/6792

5 : If you have not a minimal command line sample that allow you to execute your own java-script file, write it, be sure to handle all error you will known where it crash... 5:如果您没有最小的命令行示例来执行自己的Java脚本文件,请将其编写,请确保处理将在崩溃时知道的所有错误...

=> This will help : https://github.com/underscorediscovery/v8-tutorials =>这会有所帮助: https : //github.com/underscorediscovery/v8-tutorials

6 : When you v8 engine embedded code is ok (no crash) : lock at this it will help you to start : 6:当您的v8引擎嵌入式代码正常(不会崩溃):锁定此位将帮助您开始:

=> https://github.com/v8/v8/wiki/Debugging-over-the-V8-Inspector-API => https://github.com/v8/v8/wiki/Debugging-over-the-V8-Inspector-API

=> https://medium.com/@hyperandroid/v8-inspector-from-an-embedder-standpoint-7f9c0472e2b7 => https://medium.com/@hyperandroid/v8-inspector-from-an-embedder-standpoint-7f9c0472e2b7

Warning : javascript is executed on a single thread, and debugger need to run in an other one (v8 task if i remember correctly). 警告:javascript是在单个线程上执行的,调试器需要在另一个线程中运行(如果我没有记错的话,则是v8任务)。

Good luke it's a hard job. 祝你好运,这是一项艰巨的工作。

You can use the V8 inspector programmatically in Node.js. 您可以在Node.js中以编程方式使用V8检查器。 Eg, you can write a module that's starting the inspector, runs some code, parses the results from the inspector and so on. 例如,您可以编写一个模块来启动检查器,运行一些代码,解析检查器的结果,等等。

Have a look at this example code: 看下面的示例代码:

Demo for collecting code coverage within Node.js 在Node.js中收集代码覆盖范围的演示

You need Node 9.3 or newer, then run node coverage/demo.js and open localhost:8080. 您需要Node 9.3或更高版本,然后运行node coverage/demo.js并打开localhost:8080。 (For the type profile demo, you need a custom build Node with newer V8.) (对于类型概要文件演示,您需要一个带有较新V8的自定义构建节点。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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