nodejs, how to do debugging using GDB

After searching in google, I found the below way to do gdb on nodejs application, build node with ./configure --debug option and then do

  gdb --args ~/node_g start.js

Using this I am trying to debug a small program, but after setting the breakpoint, I am not able to see that it is breaking in that function,

My simple program gdb_node.js looks like this:

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

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

 bcd();

Now I am issuing 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  

++++......................................................................................................................................... done

 In abc
 Done abc

 Program exited normally.
 (gdb) 

Can someone please let me know what I am missing here?

Regards, -M-

gdb tries to lookup bcd symbol in debugging information generated from c++ source. It seems that you actually want to debug javascript and not c++.

V8 has built in debugger, and node.js has client for debugger protocol

To start node.js with debugger client attached to program:

node debug test.js

You can set breakpoints using debugger commands:

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>

Or use debugger keyword:

 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>

There are GUI clients for V8 debugger as well: node-webkit-agent, node-inspector, eclipse and others