Skip to content

Instantly share code, notes, and snippets.

@wolfeidau
Created March 12, 2013 07:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolfeidau/5141024 to your computer and use it in GitHub Desktop.
Save wolfeidau/5141024 to your computer and use it in GitHub Desktop.
Messing around with dtrace and node.

Monitoring a process which was exec'd using the -c switch.

$ pfexec dtrace -n 'profile-97/pid == $target && arg1/{@[jstack(100, 8000)] = count(); } tick-60s { exit(0); }' -c node
dtrace: description 'profile-97' matched 2 probes
> dtrace: pid 79919 has exited


              node`ares__read_line
              node`_ZN4node10cares_wrapL10InitializeEN2v86HandleINS1_6ObjectEEE+0x6a
              node`_ZN4nodeL7BindingERKN2v89ArgumentsE+0xe8
              node`_ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE+0x1a5
              << internal code >>
              (anon) as (anon) at net.js position 2
              << adaptor >>
              (anon) as NativeModule.compile at node.js position 55464
              (anon) as NativeModule.require at node.js position 53454
              (anon) as (anon) at tty.js position 2
              << adaptor >>
              (anon) as NativeModule.compile at node.js position 55464
              (anon) as NativeModule.require at node.js position 53454
              startup at node.js position 2892
              (anon) as (anon) at node.js position 2802
              << internal >>
              << entry >>
              node`_ZN2v88internalL6InvokeEbNS0_6HandleINS0_10JSFunctionEEENS1_INS0_6ObjectEEEiPS5_Pb+0xf7
              node`_ZN2v88internal9Execution4CallENS0_6HandleINS0_6ObjectEEES4_iPS4_Pbb+0xc8
              node`_ZN2v88Function4CallENS_6HandleINS_6ObjectEEEiPNS1_INS_5ValueEEE+0x14a
              node`_ZN4node4LoadEN2v86HandleINS0_6ObjectEEE+0xf5
              node`_ZN4node5StartEiPPc+0x139
              node`_start+0x6c
                1

              node`_ZN2v88internal12RegExpParser11ParseRegExpEPNS0_16FlatStringReaderEbPNS0_17RegExpCompileDataEPNS0_4ZoneE
              node`_ZN2v88internal21Runtime_RegExpCompileENS0_9ArgumentsEPNS0_7IsolateE+0xf3
              << internal code >>
              DoConstructRegExp at native regexp.js line 243
              0x3d953181dc06
              << constructor >>
              << internal >>
              << entry_construt >>
              node`_ZN2v88internalL6InvokeEbNS0_6HandleINS0_10JSFunctionEEENS1_INS0_6ObjectEEEiPS5_Pb+0xf7
              node`_ZN2v88internal9Execution3NewENS0_6HandleINS0_10JSFunctionEEEiPNS2_INS0_6ObjectEEEPb+0x88
              node`_ZN2v88internal10RegExpImpl19CreateRegExpLiteralENS0_6HandleINS0_10JSFunctionEEENS2_INS0_6StringEEES6_Pb+0x1e
              node`_ZN2v88internal32Runtime_MaterializeRegExpLiteralENS0_9ArgumentsEPNS0_7IsolateE+0x10f
              << internal code >>
              (anon) as (anon) at util.js position 2
              << adaptor >>
              (anon) as NativeModule.compile at node.js position 55464
              (anon) as NativeModule.require at node.js position 53454
              (anon) as (anon) at assert.js position 2
              << adaptor >>
              (anon) as NativeModule.compile at node.js position 55464
              (anon) as NativeModule.require at node.js position 53454
failed to print aggregations: Resource temporarily unavailable

Monitoring another process which I ran in another terminal.

$ pfexec dtrace -n 'profile-97/execname == "node" && arg1/{@[jstack(100, 8000)] = count(); } tick-60s { exit(0); }'
dtrace: description 'profile-97' matched 2 probes
^C


              0xfffffd7ffec5ff40
              0xfffffd7ffec5c4b0
              0xfffffd7ffec5e28b
              0xfffffd7ffec5a9ff
              0xfffffd7ffd6e11ce
              0xacdd93
              0x98a329
              0x7490a6
              0x7490dd
              0x6c08a3
                1

              0x97a556
              0x97b3d4
              0x97b78d
              0x1b69ee10618e
              0x1b69ee153a4f
              0x1b69ee1898ac
              0x1b69ee187454
              0x1b69ee177a0a
              0x1b69ee10a96e
              0x1b69ee1790e1
              0x1b69ee1779dd
              0x1b69ee17b4aa
              0x1b69ee17b3db
              0x1b69ee18608c
              0x1b69ee185ccd
              0x1b69ee1847c4
              0x1b69ee1245e7
              0x1b69ee1118b7
              0x90ac27
              0x90c468
              0x8d2cfa
              0x7506bf
              0x7638ea
              0x8b36ab
              0x8b3b77
              0x8b86e5
              0x8ac9f4
              0x752138
              0x6c08ac
                1

              0xfffffd7ffebe1283
              0x97abb2
              0x97b3d4
              0x97b78d
              0x1b69ee10618e
              0x1b69ee141185
              0x1b69ee152295
              0x1b69ee151431
              0x1b69ee10a96e
              0x1b69ee15115e
              0x1b69ee12d05d
              0x1b69ee12c425
              0x1b69ee1245e7
              0x1b69ee1118b7
              0x90ac27
              0x90c468
              0x8d2cfa
              0x750c55
              0x752129
              0x6c08ac
                1

              0x9e7ed3
              0x9e86a5
              0x9e8c17
              0x9e8e9a
              0x9e9557
              0x9ea556
              0x9ea765
              0x9eba03
              0x9f1ac1
              0x9e4b58
              0x9e4ed5
              0x9e5bad
              0x9e7eb7
              0x9e86a5
              0x9e8c17
              0x9e9557
              0x9ea556
              0x9ea765
              0x9ea810
              0x9eba03
              0x9f1cdd
              0x9e4936
              0x9e4ed5
              0x9e5bad
              0x9e7eb7
              0x9e86a5
              0x9e8c17
              0x9e9557
              0x9ea556
              0x9ea765
              0x9eba03
              0x9e7ba3
              0x9e7edb
              0x9e86a5
              0x9e8c17
              0x9e9557
              0x9ea556
              0x9ea765
              0x9eba03
              0x9f1cdd
              0x9e4936
              0x9eda5a
              0x9e4e80
              0x9eeda1
              0x9ef201
              0x9ef6ac
              0x8f4c69
              0x8f5813
              0x8ca019
              0x8ca260
              0x8ca3ba
              0x6c6785
              0x760d99
              0x8eb6a5
              0x1b69ee10618e
              0x1b69ee12dc0c
              0x1b69ee12d468
              0x1b69ee132ef6
              0x1b69ee12c945
              0x1b69ee12c425
              0x1b69ee1245e7
              0x1b69ee1118b7
              0x90ac27
              0x90c468
              0x8d2cfa
              0x750c55
              0x752129
              0x6c08ac
                1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment