ruby-usdt 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/libusdt/LICENCE +21 -0
- data/ext/libusdt/{README → README.md} +25 -3
- data/ext/libusdt/test.pl +53 -24
- data/ext/libusdt/test_usdt.c +27 -7
- data/ext/libusdt/usdt.c +44 -61
- data/ext/libusdt/usdt.h +11 -4
- data/ext/libusdt/usdt_dof.c +5 -1
- data/ext/libusdt/usdt_dof_file.c +7 -0
- data/ext/libusdt/usdt_dof_sections.c +33 -18
- data/ext/libusdt/usdt_internal.h +4 -10
- data/ext/libusdt/usdt_probe.c +4 -0
- data/ext/libusdt/usdt_tracepoints_i386.s +5 -1
- data/ext/libusdt/usdt_tracepoints_x86_64.s +50 -11
- data/ext/usdt/Makefile +74 -42
- data/ext/usdt/usdt.h +11 -4
- data/lib/usdt/version.rb +1 -1
- metadata +21 -39
data/ext/libusdt/LICENCE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright 2012 Chris Andrews. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are
|
4
|
+
permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this list of
|
7
|
+
conditions and the following disclaimer.
|
8
|
+
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
10
|
+
of conditions and the following disclaimer in the documentation and/or other materials
|
11
|
+
provided with the distribution.
|
12
|
+
|
13
|
+
THIS SOFTWARE IS PROVIDED BY CHRIS ANDREWS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
14
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CHRIS ANDREWS OR
|
16
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
17
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
18
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
19
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
20
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
21
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -1,3 +1,6 @@
|
|
1
|
+
libusdt
|
2
|
+
=======
|
3
|
+
|
1
4
|
This is "libusdt", an extraction into a C library of the common parts
|
2
5
|
of ruby-dtrace[1], perl-dtrace[2] and node-dtrace-provider[3].
|
3
6
|
|
@@ -19,7 +22,8 @@ the provider and indicating these stub functions as the tracepoints,
|
|
19
22
|
then submitted to the kernel, creating the provider. The API then
|
20
23
|
exposes the stubs, through which the probes may be fired.
|
21
24
|
|
22
|
-
Status
|
25
|
+
Status
|
26
|
+
------
|
23
27
|
|
24
28
|
The implementation here works as shown in test_usdt.c on Mac OS X,
|
25
29
|
i386 and x86_64, on Solaris-like systems, i386 and x86_64 and on
|
@@ -40,7 +44,22 @@ first four arguments work reliably. See:
|
|
40
44
|
|
41
45
|
http://wiki.freebsd.org/DTraceTODO
|
42
46
|
|
43
|
-
|
47
|
+
See Also
|
48
|
+
--------
|
49
|
+
|
50
|
+
There are experimental Lua bindings available, which are a thin
|
51
|
+
layer over this library, and should serve as an example of typical use
|
52
|
+
as a dynamic language extension:
|
53
|
+
|
54
|
+
https://github.com/chrisa/lua-usdt
|
55
|
+
|
56
|
+
There are also Ruby bindings by Kevin Chan, replacing the provider
|
57
|
+
implementation in ruby-dtrace:
|
58
|
+
|
59
|
+
https://github.com/kevinykchan/ruby-usdt
|
60
|
+
|
61
|
+
To Do
|
62
|
+
-----
|
44
63
|
|
45
64
|
Platform support:
|
46
65
|
|
@@ -53,7 +72,10 @@ Features:
|
|
53
72
|
* add a "low level" API, allowing alternative provision of
|
54
73
|
tracepoints for closer integration with language VMs.
|
55
74
|
|
75
|
+
* support structured types, with close integration with the host
|
76
|
+
DTrace system.
|
77
|
+
|
78
|
+
|
56
79
|
[1] https://github.com/chrisa/ruby-dtrace
|
57
80
|
[2] https://github.com/chrisa/perl-dtrace
|
58
81
|
[3] https://github.com/chrisa/node-dtrace-provider
|
59
|
-
|
data/ext/libusdt/test.pl
CHANGED
@@ -6,26 +6,36 @@ use Symbol 'gensym';
|
|
6
6
|
use IO::Handle;
|
7
7
|
use Test::More qw/ no_plan /;
|
8
8
|
|
9
|
+
my $USDT_ARG_MAX = 32;
|
10
|
+
|
9
11
|
my $arch;
|
10
12
|
if (scalar @ARGV == 1) {
|
11
13
|
$arch = $ARGV[0];
|
12
14
|
}
|
13
15
|
|
14
|
-
|
16
|
+
my $user_t = ($^O eq 'solaris') ? 'uintptr_t' : 'user_addr_t';
|
17
|
+
|
18
|
+
run_tests('c', 'A');
|
15
19
|
run_tests('i', 1);
|
16
20
|
|
17
21
|
sub run_tests {
|
18
22
|
my ($type, $start_arg) = @_;
|
19
23
|
|
20
|
-
for my $i (0
|
21
|
-
my ($
|
22
|
-
is($
|
24
|
+
for my $i (0..$USDT_ARG_MAX) {
|
25
|
+
my ($t_status, $d_status, $output) = run_dtrace('func', 'name', split(//, $type x $i));
|
26
|
+
is($t_status, 0, 'test exit status is 0');
|
27
|
+
is($d_status, 0, 'dtrace exit status is 0');
|
23
28
|
like($output, qr/func:name/, 'function and name match');
|
24
|
-
|
29
|
+
|
25
30
|
my $arg = $start_arg;
|
26
31
|
for my $j (0..$i - 1) {
|
27
|
-
like($output, qr/arg$j:'$arg'/, "type '$type' arg $j is $arg");
|
28
|
-
$
|
32
|
+
like($output, qr/arg$j:'\Q$arg\E'/, "type '$type' arg $j is $arg");
|
33
|
+
if ($type eq 'i') {
|
34
|
+
$arg++;
|
35
|
+
}
|
36
|
+
else {
|
37
|
+
$arg = chr(ord($arg) + 1);
|
38
|
+
}
|
29
39
|
}
|
30
40
|
}
|
31
41
|
}
|
@@ -39,10 +49,10 @@ sub gen_d {
|
|
39
49
|
my $i = 0;
|
40
50
|
for my $type (@types) {
|
41
51
|
if ($type eq 'i') {
|
42
|
-
$d .= "printf(\"arg$i:'%i' \",
|
52
|
+
$d .= "printf(\"arg$i:'%i' \", args[$i]); ";
|
43
53
|
}
|
44
54
|
if ($type eq 'c') {
|
45
|
-
$d .= "printf(\"arg$i:'%s' \", copyinstr(
|
55
|
+
$d .= "printf(\"arg$i:'%s' \", copyinstr(($user_t)args[$i])); ";
|
46
56
|
}
|
47
57
|
$i++;
|
48
58
|
}
|
@@ -55,29 +65,48 @@ sub run_dtrace {
|
|
55
65
|
my ($func, $name, @types) = @_;
|
56
66
|
my $d = gen_d(@types);
|
57
67
|
|
58
|
-
my
|
68
|
+
my @t_cmd;
|
59
69
|
if (defined $arch) {
|
60
|
-
|
70
|
+
@t_cmd = ("./test_usdt$arch", $func, $name, @types);
|
61
71
|
}
|
62
72
|
else {
|
63
|
-
|
73
|
+
@t_cmd = ("./test_usdt", $func, $name, @types);
|
64
74
|
}
|
65
75
|
|
66
|
-
my
|
76
|
+
my ($d_wtr, $d_rdr, $d_err);
|
77
|
+
my ($t_wtr, $t_rdr, $t_err);
|
67
78
|
|
68
|
-
|
69
|
-
$
|
70
|
-
my $pid = open3($wtr, $rdr, $err, @cmd);
|
79
|
+
$d_err = gensym;
|
80
|
+
$t_err = gensym;
|
71
81
|
|
72
|
-
|
73
|
-
my $
|
82
|
+
#diag(join(' ', @t_cmd));
|
83
|
+
my $t_pid = open3($t_wtr, $t_rdr, $t_err, @t_cmd);
|
84
|
+
my $enabled = $t_rdr->getline;
|
74
85
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
86
|
+
my @d_cmd = ('dtrace', '-p', $t_pid, '-n', $d);
|
87
|
+
|
88
|
+
#diag(join(' ', @d_cmd));
|
89
|
+
my $d_pid = open3($d_wtr, $d_rdr, $d_err, @d_cmd);
|
90
|
+
my $matched = $d_err->getline; # expect "matched 1 probe"
|
91
|
+
|
92
|
+
$t_wtr->print("go\n");
|
93
|
+
$t_wtr->flush;
|
94
|
+
waitpid( $t_pid, 0 );
|
95
|
+
my $t_status = $? >> 8;
|
96
|
+
|
97
|
+
my ($header, $output) = ($d_rdr->getline, $d_rdr->getline);
|
98
|
+
chomp $header;
|
99
|
+
chomp $output;
|
100
|
+
#diag("DTrace header: $header\n");
|
101
|
+
#diag("DTrace output: $output\n");
|
102
|
+
waitpid( $d_pid, 0 );
|
103
|
+
|
104
|
+
my $d_status = $? >> 8;
|
105
|
+
while (!$d_err->eof) {
|
106
|
+
my $error = $d_err->getline;
|
107
|
+
chomp $error;
|
108
|
+
#diag "DTrace error: $error";
|
79
109
|
}
|
80
110
|
|
81
|
-
|
82
|
-
return ($status, $output || '');
|
111
|
+
return ($t_status, $d_status, $output || '');
|
83
112
|
}
|
data/ext/libusdt/test_usdt.c
CHANGED
@@ -1,16 +1,34 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2012, Chris Andrews. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
1
5
|
#include "usdt.h"
|
2
6
|
|
3
7
|
#include <stdio.h>
|
4
8
|
#include <stdlib.h>
|
5
9
|
#include <string.h>
|
6
10
|
|
11
|
+
static void
|
12
|
+
fire_probe(usdt_probedef_t *probedef, int argc, void **argv)
|
13
|
+
{
|
14
|
+
if (usdt_is_enabled(probedef->probe)) {
|
15
|
+
usdt_fire_probe(probedef->probe, argc, argv);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
7
19
|
int main(int argc, char **argv) {
|
8
20
|
usdt_provider_t *provider;
|
9
21
|
usdt_probedef_t *probedef;
|
10
|
-
char
|
11
|
-
int int_argv[
|
22
|
+
char char_argv[USDT_ARG_MAX];
|
23
|
+
int int_argv[USDT_ARG_MAX * 2];
|
12
24
|
void **args;
|
13
25
|
int i;
|
26
|
+
char buf[255];
|
27
|
+
|
28
|
+
for (i = 0; i < USDT_ARG_MAX; i++)
|
29
|
+
int_argv[i] = i + 1;
|
30
|
+
for (i = 0; i < USDT_ARG_MAX; i++)
|
31
|
+
char_argv[i] = (char) i + 65;
|
14
32
|
|
15
33
|
if (argc < 3) {
|
16
34
|
fprintf(stderr, "usage: %s func name [types ...]\n", argv[0]);
|
@@ -21,10 +39,10 @@ int main(int argc, char **argv) {
|
|
21
39
|
args = malloc((argc-3) * sizeof(void *));
|
22
40
|
}
|
23
41
|
|
24
|
-
for (i = 0; i <
|
42
|
+
for (i = 0; i < USDT_ARG_MAX; i++) {
|
25
43
|
if (argv[i+3] != NULL && i+3 < argc) {
|
26
44
|
if (strncmp("c", argv[i+3], 1) == 0) {
|
27
|
-
args[i] = (void *)char_argv[i];
|
45
|
+
args[i] = (void *)strndup(&char_argv[i], 1);
|
28
46
|
argv[i+3] = strdup("char *");
|
29
47
|
}
|
30
48
|
if (strncmp("i", argv[i+3], 1) == 0) {
|
@@ -52,9 +70,11 @@ int main(int argc, char **argv) {
|
|
52
70
|
exit (1);
|
53
71
|
}
|
54
72
|
|
55
|
-
|
56
|
-
|
57
|
-
|
73
|
+
fprintf(stdout, "enabled\n");
|
74
|
+
fflush(stdout);
|
75
|
+
fgets(buf, 255, stdin);
|
76
|
+
|
77
|
+
fire_probe(probedef, (argc-3), (void **)args);
|
58
78
|
|
59
79
|
return 0;
|
60
80
|
}
|
data/ext/libusdt/usdt.c
CHANGED
@@ -1,13 +1,21 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2012, Chris Andrews. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
1
5
|
#include "usdt_internal.h"
|
2
6
|
|
3
7
|
#include <stdlib.h>
|
4
8
|
#include <stdarg.h>
|
9
|
+
#include <string.h>
|
10
|
+
#include <errno.h>
|
11
|
+
#include <stdio.h>
|
5
12
|
|
6
13
|
char *usdt_errors[] = {
|
7
14
|
"failed to allocate memory",
|
8
15
|
"failed to allocate page-aligned memory",
|
9
16
|
"no probes defined",
|
10
|
-
"failed to load DOF"
|
17
|
+
"failed to load DOF: %s",
|
18
|
+
"provider is already enabled"
|
11
19
|
};
|
12
20
|
|
13
21
|
usdt_provider_t *
|
@@ -21,66 +29,33 @@ usdt_create_provider(const char *name, const char *module)
|
|
21
29
|
provider->name = strdup(name);
|
22
30
|
provider->module = strdup(module);
|
23
31
|
provider->probedefs = NULL;
|
32
|
+
provider->enabled = 0;
|
24
33
|
|
25
34
|
return provider;
|
26
35
|
}
|
27
36
|
|
28
|
-
usdt_probedef_t *
|
29
|
-
usdt_create_probe_varargs(const char *func, const char *name, ...)
|
30
|
-
{
|
31
|
-
va_list ap;
|
32
|
-
int i;
|
33
|
-
const char *type;
|
34
|
-
usdt_probedef_t *p;
|
35
|
-
|
36
|
-
if ((p = malloc(sizeof *p)) == NULL)
|
37
|
-
return (NULL);
|
38
|
-
|
39
|
-
p->function = strdup(func);
|
40
|
-
p->name = strdup(name);
|
41
|
-
|
42
|
-
va_start(ap, name);
|
43
|
-
|
44
|
-
for (i = 0; i < 6; i++) {
|
45
|
-
if ((type = va_arg(ap, const char *)) != NULL) {
|
46
|
-
if (strncmp("char *", type, 6)) {
|
47
|
-
p->types[i] = USDT_ARGTYPE_STRING;
|
48
|
-
}
|
49
|
-
if (strncmp("int", type, 3)) {
|
50
|
-
p->types[i] = USDT_ARGTYPE_INTEGER;
|
51
|
-
}
|
52
|
-
}
|
53
|
-
else {
|
54
|
-
p->types[i] = USDT_ARGTYPE_NONE;
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
return (p);
|
59
|
-
}
|
60
|
-
|
61
37
|
usdt_probedef_t *
|
62
38
|
usdt_create_probe(const char *func, const char *name, size_t argc, const char **types)
|
63
39
|
{
|
64
40
|
int i;
|
65
41
|
usdt_probedef_t *p;
|
66
42
|
|
43
|
+
if (argc > USDT_ARG_MAX)
|
44
|
+
argc = USDT_ARG_MAX;
|
45
|
+
|
67
46
|
if ((p = malloc(sizeof *p)) == NULL)
|
68
47
|
return (NULL);
|
69
48
|
|
70
49
|
p->function = strdup(func);
|
71
50
|
p->name = strdup(name);
|
72
51
|
p->argc = argc;
|
52
|
+
p->probe = NULL;
|
73
53
|
|
74
|
-
for (i = 0; i <
|
75
|
-
if (
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
p->types[i] = USDT_ARGTYPE_INTEGER;
|
80
|
-
}
|
81
|
-
else {
|
82
|
-
p->types[i] = USDT_ARGTYPE_NONE;
|
83
|
-
}
|
54
|
+
for (i = 0; i < argc; i++) {
|
55
|
+
if (strncmp("char *", types[i], 6) == 0)
|
56
|
+
p->types[i] = USDT_ARGTYPE_STRING;
|
57
|
+
if (strncmp("int", types[i], 3) == 0)
|
58
|
+
p->types[i] = USDT_ARGTYPE_INTEGER;
|
84
59
|
}
|
85
60
|
|
86
61
|
return (p);
|
@@ -100,18 +75,6 @@ usdt_provider_add_probe(usdt_provider_t *provider, usdt_probedef_t *probedef)
|
|
100
75
|
}
|
101
76
|
}
|
102
77
|
|
103
|
-
uint8_t
|
104
|
-
usdt_probedef_argc(usdt_probedef_t *probedef)
|
105
|
-
{
|
106
|
-
uint8_t args = 0;
|
107
|
-
uint8_t i;
|
108
|
-
|
109
|
-
for (i = 0; probedef->types[i] != USDT_ARGTYPE_NONE && i < 6; i++)
|
110
|
-
args++;
|
111
|
-
|
112
|
-
return args;
|
113
|
-
}
|
114
|
-
|
115
78
|
int
|
116
79
|
usdt_provider_enable(usdt_provider_t *provider)
|
117
80
|
{
|
@@ -122,6 +85,11 @@ usdt_provider_enable(usdt_provider_t *provider)
|
|
122
85
|
size_t size;
|
123
86
|
usdt_dof_section_t sects[5];
|
124
87
|
|
88
|
+
if (provider->enabled == 1) {
|
89
|
+
usdt_error(provider, USDT_ERROR_ALREADYENABLED);
|
90
|
+
return (0); // not fatal
|
91
|
+
}
|
92
|
+
|
125
93
|
if (provider->probedefs == NULL) {
|
126
94
|
usdt_error(provider, USDT_ERROR_NOPROBES);
|
127
95
|
return (-1);
|
@@ -166,29 +134,44 @@ usdt_provider_enable(usdt_provider_t *provider)
|
|
166
134
|
usdt_dof_file_generate(file, &strtab);
|
167
135
|
|
168
136
|
if ((usdt_dof_file_load(file, provider->module)) < 0) {
|
169
|
-
usdt_error(provider, USDT_ERROR_LOADDOF);
|
137
|
+
usdt_error(provider, USDT_ERROR_LOADDOF, strerror(errno));
|
170
138
|
return (-1);
|
171
139
|
}
|
172
140
|
|
141
|
+
provider->enabled = 1;
|
173
142
|
return (0);
|
174
143
|
}
|
175
144
|
|
176
145
|
int
|
177
146
|
usdt_is_enabled(usdt_probe_t *probe)
|
178
147
|
{
|
179
|
-
|
148
|
+
if (probe != NULL)
|
149
|
+
return (*probe->isenabled_addr)();
|
150
|
+
else
|
151
|
+
return 0;
|
180
152
|
}
|
181
153
|
|
182
154
|
void
|
183
155
|
usdt_fire_probe(usdt_probe_t *probe, size_t argc, void **nargv)
|
184
156
|
{
|
185
|
-
|
157
|
+
if (probe != NULL)
|
158
|
+
usdt_probe_args(probe->probe_addr, argc, nargv);
|
159
|
+
}
|
160
|
+
|
161
|
+
static void
|
162
|
+
usdt_verror(usdt_provider_t *provider, usdt_error_t error, va_list argp)
|
163
|
+
{
|
164
|
+
vasprintf(&provider->error, usdt_errors[error], argp);
|
186
165
|
}
|
187
166
|
|
188
167
|
void
|
189
|
-
usdt_error(usdt_provider_t *provider, usdt_error_t error)
|
168
|
+
usdt_error(usdt_provider_t *provider, usdt_error_t error, ...)
|
190
169
|
{
|
191
|
-
|
170
|
+
va_list argp;
|
171
|
+
|
172
|
+
va_start(argp, error);
|
173
|
+
usdt_verror(provider, error, argp);
|
174
|
+
va_end(argp);
|
192
175
|
}
|
193
176
|
|
194
177
|
char *
|
data/ext/libusdt/usdt.h
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2012, Chris Andrews. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
1
5
|
#include <stdint.h>
|
2
6
|
#include <unistd.h>
|
3
7
|
|
@@ -6,11 +10,14 @@ typedef uint8_t usdt_argtype_t;
|
|
6
10
|
#define USDT_ARGTYPE_STRING 1
|
7
11
|
#define USDT_ARGTYPE_INTEGER 2
|
8
12
|
|
13
|
+
#define USDT_ARG_MAX 32
|
14
|
+
|
9
15
|
typedef enum usdt_error {
|
10
16
|
USDT_ERROR_MALLOC = 0,
|
11
17
|
USDT_ERROR_VALLOC,
|
12
18
|
USDT_ERROR_NOPROBES,
|
13
|
-
USDT_ERROR_LOADDOF
|
19
|
+
USDT_ERROR_LOADDOF,
|
20
|
+
USDT_ERROR_ALREADYENABLED
|
14
21
|
} usdt_error_t;
|
15
22
|
|
16
23
|
typedef struct usdt_probe {
|
@@ -25,12 +32,11 @@ typedef struct usdt_probedef {
|
|
25
32
|
const char *name;
|
26
33
|
const char *function;
|
27
34
|
size_t argc;
|
28
|
-
usdt_argtype_t types[
|
35
|
+
usdt_argtype_t types[USDT_ARG_MAX];
|
29
36
|
struct usdt_probe *probe;
|
30
37
|
struct usdt_probedef *next;
|
31
38
|
} usdt_probedef_t;
|
32
39
|
|
33
|
-
usdt_probedef_t *usdt_create_probe_varargs(const char *func, const char *name, ...);
|
34
40
|
usdt_probedef_t *usdt_create_probe(const char *func, const char *name,
|
35
41
|
size_t argc, const char **types);
|
36
42
|
|
@@ -39,12 +45,13 @@ typedef struct usdt_provider {
|
|
39
45
|
const char *module;
|
40
46
|
usdt_probedef_t *probedefs;
|
41
47
|
char *error;
|
48
|
+
int enabled;
|
42
49
|
} usdt_provider_t;
|
43
50
|
|
44
51
|
usdt_provider_t *usdt_create_provider(const char *name, const char *module);
|
45
52
|
void usdt_provider_add_probe(usdt_provider_t *provider, usdt_probedef_t *probedef);
|
46
53
|
int usdt_provider_enable(usdt_provider_t *provider);
|
47
54
|
|
48
|
-
void usdt_error(usdt_provider_t *provider, usdt_error_t error);
|
55
|
+
void usdt_error(usdt_provider_t *provider, usdt_error_t error, ...);
|
49
56
|
char *usdt_errstr(usdt_provider_t *provider);
|
50
57
|
|
data/ext/libusdt/usdt_dof.c
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2012, Chris Andrews. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
1
5
|
#include "usdt_internal.h"
|
2
6
|
|
3
7
|
#include <stdlib.h>
|
@@ -26,7 +30,7 @@ usdt_provider_dof_size(usdt_provider_t *provider, usdt_strtab_t *strtab)
|
|
26
30
|
size_t sections[8];
|
27
31
|
|
28
32
|
for (pd = provider->probedefs; pd != NULL; pd = pd->next) {
|
29
|
-
args +=
|
33
|
+
args += pd->argc;
|
30
34
|
probes++;
|
31
35
|
}
|
32
36
|
|
data/ext/libusdt/usdt_dof_file.c
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2012, Chris Andrews. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
1
5
|
#include "usdt_internal.h"
|
2
6
|
|
3
7
|
#include <stdio.h>
|
@@ -154,6 +158,9 @@ usdt_dof_file_load(usdt_dof_file_t *file, const char *module)
|
|
154
158
|
if ((close(fd)) < 0)
|
155
159
|
return (-1);
|
156
160
|
|
161
|
+
if (file->gen < 0)
|
162
|
+
return (-1);
|
163
|
+
|
157
164
|
return (0);
|
158
165
|
}
|
159
166
|
|
@@ -1,3 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2012, Chris Andrews. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
1
5
|
#include "usdt_internal.h"
|
2
6
|
|
3
7
|
int
|
@@ -17,7 +21,7 @@ usdt_dof_probes_sect(usdt_dof_section_t *probes,
|
|
17
21
|
argc = 0;
|
18
22
|
argv = 0;
|
19
23
|
|
20
|
-
for (i = 0;
|
24
|
+
for (i = 0; i < pd->argc; i++) {
|
21
25
|
switch(pd->types[i]) {
|
22
26
|
case USDT_ARGTYPE_INTEGER:
|
23
27
|
type = usdt_strtab_add(strtab, "int");
|
@@ -78,7 +82,7 @@ usdt_dof_prargs_sect(usdt_dof_section_t *prargs, usdt_provider_t *provider)
|
|
78
82
|
prargs->entsize = 1;
|
79
83
|
|
80
84
|
for (pd = provider->probedefs; pd != NULL; pd = pd->next) {
|
81
|
-
for (i = 0;
|
85
|
+
for (i = 0; i < pd->argc; i++)
|
82
86
|
usdt_dof_section_add_data(prargs, &i, 1);
|
83
87
|
}
|
84
88
|
if (prargs->size == 0) {
|
@@ -103,7 +107,7 @@ usdt_dof_proffs_sect(usdt_dof_section_t *proffs,
|
|
103
107
|
proffs->entsize = 4;
|
104
108
|
|
105
109
|
for (pd = provider->probedefs; pd != NULL; pd = pd->next) {
|
106
|
-
off = usdt_probe_offset(pd->probe, dof,
|
110
|
+
off = usdt_probe_offset(pd->probe, dof, pd->argc);
|
107
111
|
if (usdt_dof_section_add_data(proffs, &off, 4) < 0) {
|
108
112
|
usdt_error(provider, USDT_ERROR_MALLOC);
|
109
113
|
return (-1);
|
@@ -147,21 +151,32 @@ usdt_dof_provider_sect(usdt_dof_section_t *provider_s, usdt_provider_t *provider
|
|
147
151
|
p.dofpv_proffs = 3;
|
148
152
|
p.dofpv_prenoffs = 4;
|
149
153
|
p.dofpv_name = 1; // provider name always first strtab entry.
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
154
|
+
|
155
|
+
/*
|
156
|
+
* Stability is something of a hack. Everything is marked *
|
157
|
+
* "stable" here to permit use of the "args" array, which is *
|
158
|
+
* needed to access arguments past "arg9".
|
159
|
+
*
|
160
|
+
* It should be up to the creator of the provider to decide
|
161
|
+
* this, though, and it should be possible to set the
|
162
|
+
* appropriate stability at creation time.
|
163
|
+
*/
|
164
|
+
|
165
|
+
p.dofpv_provattr = DOF_ATTR(DTRACE_STABILITY_STABLE,
|
166
|
+
DTRACE_STABILITY_STABLE,
|
167
|
+
DTRACE_STABILITY_STABLE);
|
168
|
+
p.dofpv_modattr = DOF_ATTR(DTRACE_STABILITY_STABLE,
|
169
|
+
DTRACE_STABILITY_STABLE,
|
170
|
+
DTRACE_STABILITY_STABLE);
|
171
|
+
p.dofpv_funcattr = DOF_ATTR(DTRACE_STABILITY_STABLE,
|
172
|
+
DTRACE_STABILITY_STABLE,
|
173
|
+
DTRACE_STABILITY_STABLE);
|
174
|
+
p.dofpv_nameattr = DOF_ATTR(DTRACE_STABILITY_STABLE,
|
175
|
+
DTRACE_STABILITY_STABLE,
|
176
|
+
DTRACE_STABILITY_STABLE);
|
177
|
+
p.dofpv_argsattr = DOF_ATTR(DTRACE_STABILITY_STABLE,
|
178
|
+
DTRACE_STABILITY_STABLE,
|
179
|
+
DTRACE_STABILITY_STABLE);
|
165
180
|
|
166
181
|
if ((usdt_dof_section_add_data(provider_s, &p, sizeof(p))) < 0) {
|
167
182
|
usdt_error(provider, USDT_ERROR_MALLOC);
|
data/ext/libusdt/usdt_internal.h
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2012, Chris Andrews. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
1
5
|
#include <sys/dtrace.h>
|
2
6
|
#include <sys/types.h>
|
3
7
|
#include <sys/mman.h>
|
@@ -23,20 +27,10 @@ extern void usdt_tracepoint_probe(void);
|
|
23
27
|
extern void usdt_tracepoint_end(void);
|
24
28
|
extern void usdt_probe_args(void *, int, void**);
|
25
29
|
|
26
|
-
/*
|
27
|
-
typedef enum usdt_argtype {
|
28
|
-
USDT_ARGTYPE_NONE = 0,
|
29
|
-
USDT_ARGTYPE_STRING,
|
30
|
-
USDT_ARGTYPE_INTEGER
|
31
|
-
} usdt_argtype_t;
|
32
|
-
*/
|
33
|
-
|
34
30
|
uint32_t usdt_probe_offset(usdt_probe_t *probe, char *dof, uint8_t argc);
|
35
31
|
uint32_t usdt_is_enabled_offset(usdt_probe_t *probe, char *dof);
|
36
32
|
int usdt_create_tracepoints(usdt_probe_t *probe);
|
37
33
|
|
38
|
-
uint8_t usdt_probedef_argc(usdt_probedef_t *probedef);
|
39
|
-
|
40
34
|
typedef struct usdt_dof_section {
|
41
35
|
dof_secidx_t index;
|
42
36
|
uint32_t type;
|
data/ext/libusdt/usdt_probe.c
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2012, Chris Andrews. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
1
5
|
/*
|
2
6
|
* Stub functions containing DTrace tracepoints for probes and
|
3
7
|
* is-enabled probes. These functions are copied for each probe
|
@@ -39,7 +43,7 @@ usdt_tracepoint_end:
|
|
39
43
|
_usdt_tracepoint_end:
|
40
44
|
ret
|
41
45
|
|
42
|
-
|
46
|
+
/*
|
43
47
|
* Probe argument marshalling, i386 style
|
44
48
|
*
|
45
49
|
*/
|
@@ -1,3 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2012, Chris Andrews. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
1
5
|
/*
|
2
6
|
* Stub functions containing DTrace tracepoints for probes and
|
3
7
|
* is-enabled probes. These functions are copied for each probe
|
@@ -32,10 +36,11 @@ _usdt_tracepoint_probe:
|
|
32
36
|
nop
|
33
37
|
nop
|
34
38
|
nop
|
35
|
-
|
36
|
-
popq
|
37
|
-
popq
|
38
|
-
|
39
|
+
addq %r14,%rsp
|
40
|
+
popq %rbx
|
41
|
+
popq %r14
|
42
|
+
popq %r13
|
43
|
+
popq %r12
|
39
44
|
leave
|
40
45
|
usdt_tracepoint_end:
|
41
46
|
_usdt_tracepoint_end:
|
@@ -50,34 +55,68 @@ usdt_probe_args:
|
|
50
55
|
_usdt_probe_args:
|
51
56
|
pushq %rbp
|
52
57
|
movq %rsp,%rbp
|
53
|
-
subq $0x18,%rsp
|
54
58
|
pushq %r12
|
59
|
+
pushq %r13
|
60
|
+
pushq %r14
|
55
61
|
pushq %rbx
|
56
|
-
|
62
|
+
|
57
63
|
movq %rdi,%r12
|
58
64
|
movq %rsi,%rbx
|
59
65
|
movq %rdx,%r11
|
66
|
+
movq $0,%r14
|
67
|
+
|
60
68
|
test %rbx,%rbx
|
61
69
|
je fire
|
62
70
|
movq (%r11),%rdi
|
63
71
|
dec %rbx
|
64
72
|
test %rbx,%rbx
|
65
73
|
je fire
|
66
|
-
|
74
|
+
addq $8,%r11
|
75
|
+
movq (%r11),%rsi
|
67
76
|
dec %rbx
|
68
77
|
test %rbx,%rbx
|
69
78
|
je fire
|
70
|
-
|
79
|
+
addq $8,%r11
|
80
|
+
movq (%r11),%rdx
|
71
81
|
dec %rbx
|
72
82
|
test %rbx,%rbx
|
73
83
|
je fire
|
74
|
-
|
84
|
+
addq $8,%r11
|
85
|
+
movq (%r11),%rcx
|
75
86
|
dec %rbx
|
76
87
|
test %rbx,%rbx
|
77
88
|
je fire
|
78
|
-
|
89
|
+
addq $8,%r11
|
90
|
+
movq (%r11),%r8
|
79
91
|
dec %rbx
|
80
92
|
test %rbx,%rbx
|
81
93
|
je fire
|
82
|
-
|
94
|
+
addq $8,%r11
|
95
|
+
movq (%r11),%r9
|
96
|
+
|
97
|
+
movq %rbx,%r13
|
98
|
+
morestack:
|
99
|
+
dec %rbx
|
100
|
+
test %rbx,%rbx
|
101
|
+
je args
|
102
|
+
subq $16,%rsp
|
103
|
+
addq $16,%r14
|
104
|
+
dec %rbx
|
105
|
+
test %rbx,%rbx
|
106
|
+
je args
|
107
|
+
jmp morestack
|
108
|
+
|
109
|
+
args:
|
110
|
+
movq %r13,%rbx
|
111
|
+
movq $0,%r13
|
112
|
+
moreargs:
|
113
|
+
dec %rbx
|
114
|
+
test %rbx,%rbx
|
115
|
+
je fire
|
116
|
+
addq $8,%r11
|
117
|
+
movq (%r11),%rax
|
118
|
+
movq %rax,(%rsp,%r13)
|
119
|
+
addq $8,%r13
|
120
|
+
jmp moreargs
|
121
|
+
|
83
122
|
fire: jmp *%r12
|
data/ext/usdt/Makefile
CHANGED
@@ -1,20 +1,30 @@
|
|
1
1
|
|
2
2
|
SHELL = /bin/sh
|
3
3
|
|
4
|
+
# V=0 quiet, V=1 verbose. other values don't work.
|
5
|
+
V = 0
|
6
|
+
Q1 = $(V:1=)
|
7
|
+
Q = $(Q1:0=@)
|
8
|
+
n=$(NULLCMD)
|
9
|
+
ECHO1 = $(V:1=@$n)
|
10
|
+
ECHO = $(ECHO1:0=@echo)
|
11
|
+
|
4
12
|
#### Start of system configuration section. ####
|
5
13
|
|
6
14
|
srcdir = .
|
7
|
-
topdir = /Users/kevin/.rvm/rubies/ruby-1.9.
|
8
|
-
hdrdir = /Users/kevin/.rvm/rubies/ruby-1.9.
|
9
|
-
arch_hdrdir = /Users/kevin/.rvm/rubies/ruby-1.9.
|
15
|
+
topdir = /Users/kevin/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1
|
16
|
+
hdrdir = /Users/kevin/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1
|
17
|
+
arch_hdrdir = /Users/kevin/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/$(arch)
|
10
18
|
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
|
11
|
-
prefix = $(DESTDIR)/Users/kevin/.rvm/rubies/ruby-1.9.
|
19
|
+
prefix = $(DESTDIR)/Users/kevin/.rvm/rubies/ruby-1.9.3-p125
|
20
|
+
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
12
21
|
exec_prefix = $(prefix)
|
13
22
|
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
|
14
23
|
sitehdrdir = $(rubyhdrdir)/site_ruby
|
15
|
-
rubyhdrdir = $(includedir)/$(
|
16
|
-
vendordir = $(
|
17
|
-
sitedir = $(
|
24
|
+
rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
|
25
|
+
vendordir = $(rubylibprefix)/vendor_ruby
|
26
|
+
sitedir = $(rubylibprefix)/site_ruby
|
27
|
+
ridir = $(datarootdir)/$(RI_BASE_NAME)
|
18
28
|
mandir = $(datarootdir)/man
|
19
29
|
localedir = $(datarootdir)/locale
|
20
30
|
libdir = $(exec_prefix)/lib
|
@@ -34,16 +44,18 @@ datarootdir = $(prefix)/share
|
|
34
44
|
libexecdir = $(exec_prefix)/libexec
|
35
45
|
sbindir = $(exec_prefix)/sbin
|
36
46
|
bindir = $(exec_prefix)/bin
|
37
|
-
rubylibdir = $(
|
47
|
+
rubylibdir = $(rubylibprefix)/$(ruby_version)
|
38
48
|
archdir = $(rubylibdir)/$(arch)
|
39
49
|
sitelibdir = $(sitedir)/$(ruby_version)
|
40
50
|
sitearchdir = $(sitelibdir)/$(sitearch)
|
41
51
|
vendorlibdir = $(vendordir)/$(ruby_version)
|
42
52
|
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
43
53
|
|
44
|
-
|
45
|
-
|
46
|
-
|
54
|
+
NULLCMD = :
|
55
|
+
|
56
|
+
CC = /usr/bin/gcc-4.2
|
57
|
+
CXX = g++-4.2
|
58
|
+
LIBRUBY = $(LIBRUBY_SO)
|
47
59
|
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
48
60
|
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
49
61
|
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
@@ -51,34 +63,35 @@ OUTFLAG = -o
|
|
51
63
|
COUTFLAG = -o
|
52
64
|
|
53
65
|
RUBY_EXTCONF_H =
|
54
|
-
cflags =
|
55
|
-
optflags = -
|
56
|
-
debugflags = -
|
57
|
-
warnflags = -
|
58
|
-
CFLAGS =
|
66
|
+
cflags = $(optflags) $(debugflags) $(warnflags)
|
67
|
+
optflags = -O3
|
68
|
+
debugflags = -ggdb
|
69
|
+
warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration
|
70
|
+
CFLAGS = -fno-common $(cflags) -fno-common -pipe $(ARCH_FLAG)
|
59
71
|
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
|
60
72
|
DEFS =
|
61
|
-
CPPFLAGS = -DHAVE_USDT_H
|
62
|
-
CXXFLAGS = $(CFLAGS)
|
63
|
-
ldflags = -L.
|
64
|
-
dldflags =
|
65
|
-
|
66
|
-
DLDFLAGS = $(ldflags) $(dldflags) $(
|
67
|
-
LDSHARED =
|
68
|
-
LDSHAREDXX = $(
|
73
|
+
CPPFLAGS = -DHAVE_USDT_H -I/Users/kevin/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
|
74
|
+
CXXFLAGS = $(CFLAGS) $(cxxflags)
|
75
|
+
ldflags = -L. -L/usr/local/lib
|
76
|
+
dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
|
77
|
+
ARCH_FLAG =
|
78
|
+
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
|
79
|
+
LDSHARED = $(CC) -dynamic -bundle
|
80
|
+
LDSHAREDXX = $(CXX) -dynamic -bundle
|
69
81
|
AR = ar
|
70
82
|
EXEEXT =
|
71
83
|
|
84
|
+
RUBY_BASE_NAME = ruby
|
72
85
|
RUBY_INSTALL_NAME = ruby
|
73
|
-
RUBY_SO_NAME = ruby
|
74
|
-
arch =
|
75
|
-
sitearch =
|
86
|
+
RUBY_SO_NAME = ruby.1.9.1
|
87
|
+
arch = x86_64-darwin11.3.0
|
88
|
+
sitearch = $(arch)
|
76
89
|
ruby_version = 1.9.1
|
77
|
-
ruby = /Users/kevin/.rvm/rubies/ruby-1.9.
|
90
|
+
ruby = /Users/kevin/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
|
78
91
|
RUBY = $(ruby)
|
79
92
|
RM = rm -f
|
80
93
|
RM_RF = $(RUBY) -run -e rm -- -rf
|
81
|
-
RMDIRS =
|
94
|
+
RMDIRS = rmdir -p
|
82
95
|
MAKEDIRS = mkdir -p
|
83
96
|
INSTALL = /usr/bin/install -c
|
84
97
|
INSTALL_PROG = $(INSTALL) -m 0755
|
@@ -89,8 +102,8 @@ COPY = cp
|
|
89
102
|
|
90
103
|
preload =
|
91
104
|
|
92
|
-
libpath = . $(libdir)
|
93
|
-
LIBPATH = -L. -L$(libdir)
|
105
|
+
libpath = . $(libdir) /Users/kevin/.rvm/usr/lib
|
106
|
+
LIBPATH = -L. -L$(libdir) -L/Users/kevin/.rvm/usr/lib
|
94
107
|
DEFFILE =
|
95
108
|
|
96
109
|
CLEANFILES = mkmf.log
|
@@ -101,7 +114,7 @@ extout =
|
|
101
114
|
extout_prefix =
|
102
115
|
target_prefix =
|
103
116
|
LOCAL_LIBS =
|
104
|
-
LIBS =
|
117
|
+
LIBS = $(LIBRUBYARG_SHARED) -lusdt -ldtrace -lpthread -ldl -lobjc
|
105
118
|
SRCS = usdt.c
|
106
119
|
OBJS = usdt.o
|
107
120
|
TARGET = usdt
|
@@ -122,6 +135,8 @@ CLEANOBJS = *.o *.bak
|
|
122
135
|
|
123
136
|
all: $(DLLIB)
|
124
137
|
static: $(STATIC_LIB)
|
138
|
+
.PHONY: all install static install-so install-rb
|
139
|
+
.PHONY: clean clean-so clean-rb
|
125
140
|
|
126
141
|
clean-rb-default::
|
127
142
|
clean-rb::
|
@@ -135,7 +150,7 @@ distclean-so::
|
|
135
150
|
distclean: clean distclean-so distclean-rb-default distclean-rb
|
136
151
|
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
137
152
|
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
138
|
-
@-$(RMDIRS) $(DISTCLEANDIRS)
|
153
|
+
@-$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
|
139
154
|
|
140
155
|
realclean: distclean
|
141
156
|
install: install-so install-rb
|
@@ -143,38 +158,55 @@ install: install-so install-rb
|
|
143
158
|
install-so: $(RUBYARCHDIR)
|
144
159
|
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
145
160
|
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
146
|
-
|
161
|
+
@-$(MAKEDIRS) $(@D)
|
162
|
+
$(INSTALL_PROG) $(DLLIB) $(@D)
|
147
163
|
install-rb: pre-install-rb install-rb-default
|
148
164
|
install-rb-default: pre-install-rb-default
|
149
165
|
pre-install-rb: Makefile
|
150
166
|
pre-install-rb-default: Makefile
|
167
|
+
pre-install-rb-default:
|
168
|
+
$(ECHO) installing default usdt libraries
|
151
169
|
$(RUBYARCHDIR):
|
152
|
-
$(MAKEDIRS) $@
|
170
|
+
$(Q) $(MAKEDIRS) $@
|
153
171
|
|
154
172
|
site-install: site-install-so site-install-rb
|
155
173
|
site-install-so: install-so
|
156
174
|
site-install-rb: install-rb
|
157
175
|
|
158
|
-
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
176
|
+
.SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
|
159
177
|
|
160
178
|
.cc.o:
|
161
|
-
$(
|
179
|
+
$(ECHO) compiling $(<)
|
180
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
181
|
+
|
182
|
+
.mm.o:
|
183
|
+
$(ECHO) compiling $(<)
|
184
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
162
185
|
|
163
186
|
.cxx.o:
|
164
|
-
$(
|
187
|
+
$(ECHO) compiling $(<)
|
188
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
165
189
|
|
166
190
|
.cpp.o:
|
167
|
-
$(
|
191
|
+
$(ECHO) compiling $(<)
|
192
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
168
193
|
|
169
194
|
.C.o:
|
170
|
-
$(
|
195
|
+
$(ECHO) compiling $(<)
|
196
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
171
197
|
|
172
198
|
.c.o:
|
173
|
-
$(
|
199
|
+
$(ECHO) compiling $(<)
|
200
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
201
|
+
|
202
|
+
.m.o:
|
203
|
+
$(ECHO) compiling $(<)
|
204
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
174
205
|
|
175
206
|
$(DLLIB): $(OBJS) Makefile
|
207
|
+
$(ECHO) linking shared-object $(DLLIB)
|
176
208
|
@-$(RM) $(@)
|
177
|
-
$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
209
|
+
$(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
178
210
|
|
179
211
|
|
180
212
|
|
data/ext/usdt/usdt.h
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2012, Chris Andrews. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
1
5
|
#include <stdint.h>
|
2
6
|
#include <unistd.h>
|
3
7
|
|
@@ -6,11 +10,14 @@ typedef uint8_t usdt_argtype_t;
|
|
6
10
|
#define USDT_ARGTYPE_STRING 1
|
7
11
|
#define USDT_ARGTYPE_INTEGER 2
|
8
12
|
|
13
|
+
#define USDT_ARG_MAX 32
|
14
|
+
|
9
15
|
typedef enum usdt_error {
|
10
16
|
USDT_ERROR_MALLOC = 0,
|
11
17
|
USDT_ERROR_VALLOC,
|
12
18
|
USDT_ERROR_NOPROBES,
|
13
|
-
USDT_ERROR_LOADDOF
|
19
|
+
USDT_ERROR_LOADDOF,
|
20
|
+
USDT_ERROR_ALREADYENABLED
|
14
21
|
} usdt_error_t;
|
15
22
|
|
16
23
|
typedef struct usdt_probe {
|
@@ -25,12 +32,11 @@ typedef struct usdt_probedef {
|
|
25
32
|
const char *name;
|
26
33
|
const char *function;
|
27
34
|
size_t argc;
|
28
|
-
usdt_argtype_t types[
|
35
|
+
usdt_argtype_t types[USDT_ARG_MAX];
|
29
36
|
struct usdt_probe *probe;
|
30
37
|
struct usdt_probedef *next;
|
31
38
|
} usdt_probedef_t;
|
32
39
|
|
33
|
-
usdt_probedef_t *usdt_create_probe_varargs(const char *func, const char *name, ...);
|
34
40
|
usdt_probedef_t *usdt_create_probe(const char *func, const char *name,
|
35
41
|
size_t argc, const char **types);
|
36
42
|
|
@@ -39,12 +45,13 @@ typedef struct usdt_provider {
|
|
39
45
|
const char *module;
|
40
46
|
usdt_probedef_t *probedefs;
|
41
47
|
char *error;
|
48
|
+
int enabled;
|
42
49
|
} usdt_provider_t;
|
43
50
|
|
44
51
|
usdt_provider_t *usdt_create_provider(const char *name, const char *module);
|
45
52
|
void usdt_provider_add_probe(usdt_provider_t *provider, usdt_probedef_t *probedef);
|
46
53
|
int usdt_provider_enable(usdt_provider_t *provider);
|
47
54
|
|
48
|
-
void usdt_error(usdt_provider_t *provider, usdt_error_t error);
|
55
|
+
void usdt_error(usdt_provider_t *provider, usdt_error_t error, ...);
|
49
56
|
char *usdt_errstr(usdt_provider_t *provider);
|
50
57
|
|
data/lib/usdt/version.rb
CHANGED
metadata
CHANGED
@@ -1,37 +1,29 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-usdt
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 3
|
10
|
-
version: 0.0.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Kevin Chan
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2012-04-24 00:00:00 Z
|
12
|
+
date: 2012-05-02 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
14
|
description:
|
22
|
-
email:
|
15
|
+
email:
|
23
16
|
- kevin@yinkei.com
|
24
17
|
executables: []
|
25
|
-
|
26
|
-
extensions:
|
18
|
+
extensions:
|
27
19
|
- ext/usdt/extconf.rb
|
28
20
|
extra_rdoc_files: []
|
29
|
-
|
30
|
-
files:
|
21
|
+
files:
|
31
22
|
- lib/usdt/version.rb
|
32
23
|
- lib/usdt.rb
|
24
|
+
- ext/libusdt/LICENCE
|
33
25
|
- ext/libusdt/Makefile
|
34
|
-
- ext/libusdt/README
|
26
|
+
- ext/libusdt/README.md
|
35
27
|
- ext/libusdt/test.pl
|
36
28
|
- ext/libusdt/test_usdt.c
|
37
29
|
- ext/libusdt/usdt.c
|
@@ -52,37 +44,27 @@ files:
|
|
52
44
|
- LICENSE.md
|
53
45
|
homepage: http://github.com/kevinykchan/ruby-usdt
|
54
46
|
licenses: []
|
55
|
-
|
56
47
|
post_install_message:
|
57
48
|
rdoc_options: []
|
58
|
-
|
59
|
-
require_paths:
|
49
|
+
require_paths:
|
60
50
|
- lib
|
61
51
|
- ext
|
62
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
53
|
none: false
|
64
|
-
requirements:
|
65
|
-
- -
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
|
68
|
-
|
69
|
-
- 0
|
70
|
-
version: "0"
|
71
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
59
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
version: "0"
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
80
64
|
requirements: []
|
81
|
-
|
82
65
|
rubyforge_project:
|
83
66
|
rubygems_version: 1.8.21
|
84
67
|
signing_key:
|
85
68
|
specification_version: 3
|
86
69
|
summary: Native DTrace probes for ruby.
|
87
70
|
test_files: []
|
88
|
-
|