简体   繁体   English

使用node-inspector调试节点src / http.js

[英]Debugging nodes src/http.js with node-inspector

I'm having some bad luck debugging a node.js application. 我在调试node.js应用程序时遇到了不幸。 The problem is that I need to set a breakpoint in a file that isn't loaded at start (when --debug-blk) hits in. The file is http.js from node itself. 问题是我需要在启动时(当--debug-blk时)未加载的文件中设置一个断点。该文件是来自节点本身的http.js。

So I would like to modify the file to add a debugger; 所以我想修改文件以添加调试器; statement, but I'm unable to find this http.js file on my disk? 语句,但是我无法在磁盘上找到此http.js文件? The only place I see it on my disk is in the source distribution of node (lib/http.js). 我在磁盘上看到的唯一位置是节点(lib / http.js)的源代码分布。 Where is this file located after a make install in node-src, and how can I set breakpoints inside it? 在node-src中进行make安装后,此文件位于何处?如何在其中设置断点?

http.js is internal to the node executable. http.js在节点可执行文件内部。 It doesn't exist on disk, and the only way to modify it is to build node from source. 它在磁盘上不存在,并且修改它的唯一方法是从源代码构建节点。

Do this: 做这个:

var http = require('http');
debugger;

// the rest of your app

Your app will start, load http, and then pause. 您的应用将启动,加载http,然后暂停。 Now you can use the inspector to set breakpoints inside http. 现在,您可以使用检查器在http内设置断点。 (You won't need --debug-brk since the debugger statement will pause the app before anything really happens.) (您不需要--debug-brk因为debugger语句将在真正发生任何事情之前暂停应用程序。)

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

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