Line numbers when using mdb to debug node.js/V8

Someone on IRC was trying to follow along with http://dtrace.org/blogs/dap/2011/10/31/nodejs-v8-postmortem-debugging/ and got stuck because it's a bit outdated.

Some notes

  • The module has changed name from mdb_v8.so to v8.so
  • ::jsstack doesn't display file name and line numbers anymore (confusing)
  • ::jsstack -v gives verbose output including line numbers

Some shell output for playing along

[nshalman@shalman ~]$ uname -v
joyent_20131105T084235Z
[nshalman@shalman ~]$ which node
/opt/local/bin/node
[nshalman@shalman ~]$ node --version
v0.10.24
[nshalman@shalman ~]$ cat loop-anon.js 
new Error().stack;
function main() { func1(); }
function func1() { func2(); }

function func2()
{
        (function () {
         for (;;)
         ;
         })();
} 

main();
[nshalman@shalman ~]$ node loop-anon.js &
[1] 13943
[nshalman@shalman ~]$ mdb -p 13943
Loading modules: [ ld.so.1 libumem.so.1 libc.so.1 ]
> ::load v8  
V8 version: 3.14.5.9
Autoconfigured V8 support from target
C++ symbol demangling enabled
> ::jsstack
80471c8 0x9d35b40e <anonymous> (as <anon>) (81784775)
    file: /home/nshalman/loop-anon.js
    posn: line 7
80471e0 0x9d35af71 func2 (81780d85)
80471f8 0x9d35ae0b func1 (81780d61)
8047210 0x9d35ad6b main (81780d3d)
804722c 0x9d3552c7 <anonymous> (as <anon>) (81780ca1)
8047260 0x9d3141a5 <InternalFrame>
8047298 0x9d354cd7 <anonymous> (as Module._compile) (ad62e079)
80472b8 0x9d350dd9 <anonymous> (as Module._extensions..js) (ad62e0b9)
80472dc 0x9d34dd7f <anonymous> (as Module.load) (ad62e031)
804731c 0x9d33fef7 <anonymous> (as Module._load) (ad62dfe9)
804733c 0x9d33fa53 <anonymous> (as Module.runMain) (ad62e101)
8047370 0x9d3298f6 startup (81724609)
804738c 0x9d32910b <anonymous> (as <anon>) (81723f81)
80473ac 0x9d30fe19 <InternalFrame>
80473e8 0x9d30a0aa <EntryFrame>
8047458 _ZN2v88internalL6InvokeEbNS0_6HandleINS0_10JSFunctionEEENS1_INS0_6ObjectEEEiPS5_Pb+0xef
8047498 v8::internal::Execution::Call+0xd0
80474f8 v8::Function::Call+0x15c
8047568 node::Load+0x152
80475d8 node::Start+0x166
80475f8 main+0x1b
804761c _start+0x83
> ::jsstack -v
80471c8 0x9d35b40e <anonymous> (as <anon>) (81784775)
    file: /home/nshalman/loop-anon.js
    posn: line 7
80471e0 0x9d35af71 func2 (81780d85)
    file: /home/nshalman/loop-anon.js
    posn: line 5
80471f8 0x9d35ae0b func1 (81780d61)
    file: /home/nshalman/loop-anon.js
    posn: line 3
8047210 0x9d35ad6b main (81780d3d)
    file: /home/nshalman/loop-anon.js
    posn: line 2
804722c 0x9d3552c7 <anonymous> (as <anon>) (81780ca1)
    file: /home/nshalman/loop-anon.js
    posn: line 1
    arg1: 8177f4cd (JSObject)
    arg2: 817806b1 (JSFunction)
    arg3: 8177f451 (JSObject)
    arg4: 8177e119 (ConsString)
    arg5: 81780b69 (ConsString)
8047260 0x9d3141a5 <InternalFrame>
8047298 0x9d354cd7 <anonymous> (as Module._compile) (ad62e079)
    file: module.js
    posn: line 374
    arg1: 81780555 (SeqAsciiString)
    arg2: 8177e119 (ConsString)
80472b8 0x9d350dd9 <anonymous> (as Module._extensions..js) (ad62e0b9)
    file: module.js
    posn: line 472
    arg1: 8177f451 (JSObject)
    arg2: 8177e119 (ConsString)
80472dc 0x9d34dd7f <anonymous> (as Module.load) (ad62e031)
    file: module.js
    posn: line 346
    arg1: 8177e119 (ConsString)
804731c 0x9d33fef7 <anonymous> (as Module._load) (ad62dfe9)
    file: module.js
    posn: line 275
    arg1: 817464cd (ConsString)
    arg2: ad608081 (Oddball: "null")
    arg3: ad6080a1 (Oddball: "true")
804733c 0x9d33fa53 <anonymous> (as Module.runMain) (ad62e101)
    file: module.js
    posn: line 495
8047370 0x9d3298f6 startup (81724609)
    file: node.js
    posn: line 30
804738c 0x9d32910b <anonymous> (as <anon>) (81723f81)
    file: node.js
    posn: line 27
    arg1: 8171e9a9 (JSObject)
80473ac 0x9d30fe19 <InternalFrame>
80473e8 0x9d30a0aa <EntryFrame>
8047458 _ZN2v88internalL6InvokeEbNS0_6HandleINS0_10JSFunctionEEENS1_INS0_6ObjectEEEiPS5_Pb+0xef
8047498 v8::internal::Execution::Call+0xd0
80474f8 v8::Function::Call+0x15c
8047568 node::Load+0x152
80475d8 node::Start+0x166
80475f8 main+0x1b
804761c _start+0x83