nodejs,如何使用GDB进行debugging

在谷歌search后,我发现下面的方式做nodejs应用gdb,build立节点./configure –debug选项,然后做

gdb --args ~/node_g start.js 

使用这个我试图debugging一个小程序,但是在设置了断点后,我不能看到它正在打破这个function,

我的简单程序gdb_node.js看起来像这样:

  function abc() { console.log("In abc"); } function bcd() { abc(); console.log("Done abc"); } bcd(); 

现在我正在发行gdb:

 (gdb) b bcd Function "bcd" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (bcd) pending. (gdb) run Starting program: /Users/mayukh/node_g gdb_node.js Reading symbols for shared libraries 

++++ ………………………………………. ………………………………………….. …………………………………..完成

  In abc Done abc Program exited normally. (gdb) 

有人能让我知道我在这里失踪了吗?

问候,-M-

gdb尝试在debugging从c ++源生成的信息中查找bcd符号。 看来你真的想debuggingJavaScript而不是C ++。

V8内置了debugging器,而node.js具有debugging器协议的 客户端

用debugging器客户端连接到程序来启动node.js:

 node debug test.js 

您可以使用debugging器命令设置断点:

 sh-3.2$ node debug test.js < debugger listening on port 5858 connecting... ok break in test.js:10 8 } 9 10 bcd(); 11 12 }); debug> sb(6) 5 function bcd() { * 6 abc(); 7 console.log("Done abc"); 8 } 9 10 bcd(); 11 12 }); debug> 

或者使用debugger关键字:

  function abc() { console.log("In abc"); } function bcd() { debugger; abc(); console.log("Done abc"); } bcd(); 

=

 sh-3.2$ node debug test.js < debugger listening on port 5858 connecting... ok break in test.js:11 9 } 10 11 bcd(); 12 13 }); debug> c break in test.js:6 4 5 function bcd() { 6 debugger; 7 abc(); 8 console.log("Done abc"); debug> 

还有V8debugging器的GUI客户端: node-webkit-agent , node-inspector , eclipse等