Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

systemtap/dtrace support for nodejs #4164

Closed
wants to merge 12 commits into from
6 changes: 5 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,12 @@ def configure_node(o):
# SunOS, and we haven't implemented it.)
if sys.platform.startswith('sunos'):
o['variables']['node_use_dtrace'] = b(not options.without_dtrace)
elif sys.platform.startswith('linux'):
o['variables']['node_use_dtrace'] = 'false'
o['variables']['node_use_systemtap'] = b(not options.without_dtrace)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A --with-systemtap configure switch is preferable over piggybacking on the --with-dtrace switch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, skip that. I guess it doesn't matter much from an end user perspective.

elif b(options.with_dtrace) == 'true':
raise Exception('DTrace is currently only supported on SunOS systems.')
raise Exception(
'DTrace is currently only supported on SunOS or Linux systems.')
else:
o['variables']['node_use_dtrace'] = 'false'

Expand Down
50 changes: 47 additions & 3 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'node_shared_v8%': 'false',
'node_shared_zlib%': 'false',
'node_use_openssl%': 'true',
'node_use_systemtap%': 'false',
'node_shared_openssl%': 'false',
'library_files': [
'src/node.js',
Expand Down Expand Up @@ -146,7 +147,6 @@
}, {
'defines': [ 'HAVE_OPENSSL=0' ]
}],

[ 'node_use_dtrace=="true"', {
'defines': [ 'HAVE_DTRACE=1' ],
'dependencies': [ 'node_dtrace_header' ],
Expand All @@ -168,6 +168,17 @@
}
] ],
} ],
[ 'node_use_systemtap=="true"', {
'defines': [ 'HAVE_SYSTEMTAP=1', 'STAP_SDT_V1' ],
'dependencies': [ 'node_systemtap_header' ],
'dependencies': [ 'node_systemtap_object' ],
'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
'libraries': [ '<(PRODUCT_DIR)/obj.target/node/src/node_systemtap_sema.o' ],
'sources': [
'src/node_systemtap.cc',
'src/node_systemtap.h',
],
} ],
[ 'node_use_etw=="true"', {
'defines': [ 'HAVE_ETW=1' ],
'dependencies': [ 'node_etw' ],
Expand Down Expand Up @@ -282,7 +293,7 @@
# action?

'conditions': [
[ 'node_use_dtrace=="true" or node_use_etw=="true"', {
[ 'node_use_dtrace=="true" or node_use_etw=="true" or node_use_systemtap=="true"', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long line, wrap at 80 columns like this:

             [ 'node_use_dtrace=="true"'
               ' or node_use_etw=="true"'
               ' or node_use_systemtap=="true"',
             {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a diff:

diff --git a/node.gyp b/node.gyp
index f2f6255..07c89d3 100644
--- a/node.gyp
+++ b/node.gyp
@@ -293,7 +293,10 @@
           # action?

           'conditions': [
-            [ 'node_use_dtrace=="true" or node_use_etw=="true" or node_use_systemtap=="true"', {
+            [ 'node_use_dtrace=="true"'
+              ' or node_use_etw=="true"'
+              ' or node_use_systemtap=="true"',
+            {
               'action': [
                 'python',
                 'tools/js2c.py',

'action': [
'python',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this break sunos+dtrace builds?

'tools/js2c.py',
Expand All @@ -295,7 +306,6 @@
'tools/js2c.py',
'<@(_outputs)',
'<@(_inputs)',
'src/macros.py'
],
}]
],
Expand All @@ -319,6 +329,40 @@
} ]
]
},
{
'target_name': 'node_systemtap_header',
'type': 'none',
'conditions': [
[ 'node_use_systemtap=="true"', {
'actions': [
{
'action_name': 'node_systemtap_header',
'inputs': [ 'src/node_systemtap.d' ],
'outputs': [ 'src/node_systemtap.h' ],
'action': [ 'dtrace', '-h', '-C', '-s', '<@(_inputs)',
'-o', '<@(_outputs)' ]
}
]
} ]
]
},
{
'target_name': 'node_systemtap_object',
'type': 'none',
'conditions': [
[ 'node_use_systemtap=="true"', {
'actions': [
{
'action_name': 'node_systemtap_o',
'inputs': [ 'src/node_systemtap.d' ],
'outputs': [ '<(PRODUCT_DIR)/obj.target/node/src/node_systemtap_sema.o' ],
'action': [ 'dtrace', '-G', '-s', '<@(_inputs)',
'-o', '<@(_outputs)' ]
}
]
} ]
]
},
{
'target_name': 'node_dtrace_provider',
'type': 'none',
Expand Down
5 changes: 4 additions & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "uv.h"

#include "v8-debug.h"
#if defined HAVE_DTRACE || defined HAVE_ETW
#if defined HAVE_DTRACE || defined HAVE_ETW || defined HAVE_SYSTEMTAP
# include "node_dtrace.h"
#endif

Expand Down Expand Up @@ -72,6 +72,9 @@ typedef int mode_t;
#if HAVE_OPENSSL
# include "node_crypto.h"
#endif
#if HAVE_SYSTEMTAP
#include "node_systemtap.h"
#endif
#include "node_script.h"
#include "v8_typed_array.h"

Expand Down
Loading