原文: https://zhuanlan.zhihu.com/p/83775779
开始之前,可以先尝试在本地编译一下 libuv 的源码。
**Joey:libuv 源码阅读之准备篇**zhuanlan.zhihu.com
1. Build the Node debugging build
$ cd $NODE_HOME # clone 下来的 node 仓库 $ ./configure --debug $ make -j8
2. add launch.json
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: <https://go.microsoft.com/fwlink/?linkid=830387> "version": "0.2.0", "configurations": [ { "type": "node", "request": "attach", "name": "启动调试", "port": 9228 }, { "name": "node index.js", "type": "lldb", "request": "launch", "program": "${workspaceFolder}/node_g", "args": [ // "--inspect-brk=127.0.0.1:9228", "./hello.js" ], "cwd": "${workspaceFolder}" } ] }
3. add launch.json

- 丢个 debug.js 到当前目录,可以随意的打印下 "hello world"
console.log('hello world');
- 在 node_main.c 中设置断点

- enjoy yourself !!!
















