Node.js  v8.x
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine
node_dtrace.h
Go to the documentation of this file.
1 // Copyright Joyent, Inc. and other Node contributors.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to permit
8 // persons to whom the Software is furnished to do so, subject to the
9 // following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 
22 #ifndef SRC_NODE_DTRACE_H_
23 #define SRC_NODE_DTRACE_H_
24 
25 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26 
27 #include "node.h"
28 #include "v8.h"
29 #include "env.h"
30 
31 extern "C" {
32 /*
33  * The following structures are passed directly to DTrace when probes are fired.
34  * Translators in node.d translate these structures into the corresponding D
35  * structures, taking care of dealing with the user process data model (32-bit
36  * or 64-bit) and structure versions (see node_dtrace_http_server_request_t
37  * below).
38  */
39 
40 typedef struct {
41  int32_t fd;
42  int32_t port;
43  char* remote;
44  int32_t buffered;
46 
47 typedef struct {
48  char* url;
49  char* method;
51 
52 /*
53  * The original version of this structure contained only a url and method, just
54  * like the client request above. To add the new forwardedFor field, the
55  * structure layout was changed to begin with an integer version. The
56  * translator knows whether it's looking at an old- or new-version structure
57  * based on whether the version field's value is a reasonable pointer (i.e.
58  * address greater than 4K). No doubt this is filthy, but there's not much else
59  * we can do, and it works reliably.
60  *
61  * This version of the structure also contains padding that should be zeroed out
62  * by the consumer so that future versions of the translator can simply check if
63  * a field is present by checking it against nullptr.
64  */
65 typedef struct {
66  union {
67  uint32_t version;
68  uintptr_t unused; /* for compat. with old 64-bit struct */
69  } _un;
70  char* url;
71  char* method;
72  char* forwardedFor;
73  char* _pad[8];
75 
76 } // extern "C"
77 
78 namespace node {
79 
80 void InitDTrace(Environment* env, v8::Local<v8::Object> target);
81 
82 } // namespace node
83 
84 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
85 
86 #endif // SRC_NODE_DTRACE_H_
void InitDTrace(Environment *env, Local< Object > target)
Definition: node_dtrace.cc:261
forwardedFor
Definition: node.d:212
method
Definition: node.d:195