ruby-static-tracing 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/ruby-static-tracing/lib/libstapsdt/Makefile +1 -1
- data/ext/ruby-static-tracing/lib/libstapsdt/src/errors.c +1 -1
- data/ext/ruby-static-tracing/lib/libstapsdt/src/libstapsdt.c +13 -63
- data/ext/ruby-static-tracing/lib/libstapsdt/src/libstapsdt.h +0 -1
- data/lib/ruby-static-tracing/version.rb +1 -1
- data/lib/tasks/docker.rb +2 -2
- metadata +1 -2
- data/lib/tasks/vagrant.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0f88831910e6d3f1204aa0ef915a11dc0da7602cd7e35cd1d6cf4d3f7d7628a
|
4
|
+
data.tar.gz: d7077a225ccfe99c6be0bdc3e85c3bdb69b75c443f2b69f1db48774271c364f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad0ea76443e3222e6638e48fb6c2db9274cb65ffabcbf85d56adc3f57c6638fc73aef8df6d18225932229523a2b476c98b62ce0c83ea988aa7729525a4c7dee9
|
7
|
+
data.tar.gz: 9e3287a4eaf2e4e40a7078dfd63463f5487784da13b2bf7dba3baf8340773d1e95817d979f71abd916fed6425b2117d4af915868e6c0b31b84f7b30936ed049f
|
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
const char *sdtErrors[] = {
|
10
10
|
"failed to create Elf shared library for provider '%s'",
|
11
|
-
"failed to create temporary file",
|
11
|
+
"failed to create temporary file '%s'",
|
12
12
|
"failed to open shared library '%s': %s",
|
13
13
|
"failed to load symbol '%s' for shared library '%s': %s",
|
14
14
|
"failed to close shared library '%s' for provider '%s': %s",
|
@@ -1,9 +1,8 @@
|
|
1
|
+
#include <stdarg.h>
|
1
2
|
#include <dlfcn.h>
|
2
3
|
#include <err.h>
|
3
4
|
#include <fcntl.h>
|
4
5
|
#include <libelf.h>
|
5
|
-
#include <limits.h>
|
6
|
-
#include <stdarg.h>
|
7
6
|
#include <stdio.h>
|
8
7
|
#include <stdlib.h>
|
9
8
|
#include <string.h>
|
@@ -19,19 +18,6 @@
|
|
19
18
|
#include "libstapsdt.h"
|
20
19
|
#include "errors.h"
|
21
20
|
|
22
|
-
#ifdef LIBSTAPSDT_MEMORY_BACKED_FD
|
23
|
-
#include <linux/memfd.h>
|
24
|
-
#include <sys/mman.h>
|
25
|
-
#include <sys/syscall.h>
|
26
|
-
|
27
|
-
#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
|
28
|
-
|
29
|
-
// Note that linux must be 3.17 or greater to support this
|
30
|
-
static inline int memfd_create(const char *name, unsigned int flags) {
|
31
|
-
return syscall(__NR_memfd_create, name, flags);
|
32
|
-
}
|
33
|
-
#endif
|
34
|
-
|
35
21
|
int createSharedLibrary(int fd, SDTProvider_t *provider) {
|
36
22
|
DynElf *dynElf = dynElfInit(fd);
|
37
23
|
|
@@ -56,7 +42,6 @@ SDTProvider_t *providerInit(const char *name) {
|
|
56
42
|
provider->probes = NULL;
|
57
43
|
provider->_handle = NULL;
|
58
44
|
provider->_filename = NULL;
|
59
|
-
provider->_memfd = -1;
|
60
45
|
|
61
46
|
provider->name = (char *) calloc(sizeof(char), strlen(name) + 1);
|
62
47
|
memcpy(provider->name, name, sizeof(char) * strlen(name) + 1);
|
@@ -95,59 +80,30 @@ SDTProbe_t *providerAddProbe(SDTProvider_t *provider, const char *name, int argC
|
|
95
80
|
return &(probeList->probe);
|
96
81
|
}
|
97
82
|
|
98
|
-
static char *tempElfPath(int *fd, const char *name) {
|
99
|
-
char *filename = NULL;
|
100
|
-
|
101
|
-
#ifdef LIBSTAPSDT_MEMORY_BACKED_FD
|
102
|
-
char path_buffer[PATH_MAX + 1];
|
103
|
-
snprintf(path_buffer, (PATH_MAX + 1), "libstapsdt:%s", name);
|
104
|
-
|
105
|
-
*fd = memfd_create(path_buffer, F_SEAL_SEAL);
|
106
|
-
if (*fd < 0)
|
107
|
-
return NULL;
|
108
|
-
snprintf(path_buffer, (PATH_MAX + 1), "/proc/%d/fd/%d", getpid(), *fd);
|
109
|
-
|
110
|
-
filename = calloc(sizeof(char), (strlen(path_buffer) + 1));
|
111
|
-
strcpy(filename, path_buffer);
|
112
|
-
#else
|
113
|
-
filename = calloc(sizeof(char), strlen("/tmp/-XXXXXX.so") + strlen(name) + 1);
|
114
|
-
|
115
|
-
sprintf(filename, "/tmp/%s-XXXXXX.so", name);
|
116
|
-
|
117
|
-
if ((*fd = mkstemps(filename, 3)) < 0) {
|
118
|
-
free(filename);
|
119
|
-
return NULL;
|
120
|
-
}
|
121
|
-
#endif
|
122
|
-
return filename;
|
123
|
-
}
|
124
|
-
|
125
83
|
int providerLoad(SDTProvider_t *provider) {
|
126
84
|
int fd;
|
127
85
|
void *fireProbe;
|
86
|
+
char *filename = calloc(sizeof(char), strlen("/tmp/-XXXXXX.so") + strlen(provider->name) + 1);
|
128
87
|
char *error;
|
129
88
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
sdtSetError(provider, tmpCreationError);
|
89
|
+
sprintf(filename, "/tmp/%s-XXXXXX.so", provider->name);
|
90
|
+
|
91
|
+
if ((fd = mkstemps(filename, 3)) < 0) {
|
92
|
+
sdtSetError(provider, tmpCreationError, filename);
|
93
|
+
free(filename);
|
136
94
|
return -1;
|
137
95
|
}
|
96
|
+
provider->_filename = filename;
|
138
97
|
|
139
98
|
if(createSharedLibrary(fd, provider) != 0) {
|
140
99
|
(void)close(fd);
|
141
100
|
return -1;
|
142
101
|
}
|
102
|
+
(void)close(fd);
|
143
103
|
|
144
|
-
|
145
|
-
(void)close(fd);
|
146
|
-
|
147
|
-
provider->_handle = dlopen(provider->_filename, RTLD_LAZY);
|
104
|
+
provider->_handle = dlopen(filename, RTLD_LAZY);
|
148
105
|
if (!provider->_handle) {
|
149
|
-
sdtSetError(provider, sharedLibraryOpenError,
|
150
|
-
dlerror());
|
106
|
+
sdtSetError(provider, sharedLibraryOpenError, filename, dlerror());
|
151
107
|
return -1;
|
152
108
|
}
|
153
109
|
|
@@ -156,8 +112,7 @@ int providerLoad(SDTProvider_t *provider) {
|
|
156
112
|
|
157
113
|
// TODO (mmarchini) handle errors better when a symbol fails to load
|
158
114
|
if ((error = dlerror()) != NULL) {
|
159
|
-
sdtSetError(provider, sharedLibraryOpenError,
|
160
|
-
node->probe.name, error);
|
115
|
+
sdtSetError(provider, sharedLibraryOpenError, filename, node->probe.name, error);
|
161
116
|
return -1;
|
162
117
|
}
|
163
118
|
|
@@ -182,12 +137,7 @@ int providerUnload(SDTProvider_t *provider) {
|
|
182
137
|
node->probe._fire = NULL;
|
183
138
|
}
|
184
139
|
|
185
|
-
|
186
|
-
(void)close(provider->_memfd);
|
187
|
-
provider->_memfd = -1;
|
188
|
-
} else {
|
189
|
-
unlink(provider->_filename);
|
190
|
-
}
|
140
|
+
unlink(provider->_filename);
|
191
141
|
free(provider->_filename);
|
192
142
|
|
193
143
|
return 0;
|
data/lib/tasks/docker.rb
CHANGED
@@ -10,7 +10,7 @@ namespace :docker do
|
|
10
10
|
desc 'Runs the development docker image'
|
11
11
|
task :run do
|
12
12
|
`docker run --privileged --name ruby-static-tracing-#{Time.now.getutc.to_i} -v $(pwd):/app -d quay.io/dalehamel/ruby-static-tracing:latest /bin/sh -c "sleep infinity"`.strip
|
13
|
-
system("docker exec -ti #{latest_running_container_id} /
|
13
|
+
system("docker exec -ti #{latest_running_container_id} mount -t debugfs debugfs /sys/kernel/debug")
|
14
14
|
end
|
15
15
|
|
16
16
|
desc 'Provides a shell within the development docker image'
|
@@ -22,11 +22,11 @@ namespace :docker do
|
|
22
22
|
task :install do
|
23
23
|
system("docker exec -ti #{latest_running_container_id} bash -c 'bundle install && bundle exec rake install'")
|
24
24
|
end
|
25
|
+
|
25
26
|
desc 'Runs integration tests within the development docker image'
|
26
27
|
task :integration do
|
27
28
|
system("docker exec -ti #{latest_running_container_id} bash -c 'bundle install && bundle exec rake clean && bundle exec rake build && bundle exec rake integration'")
|
28
29
|
end
|
29
|
-
|
30
30
|
desc 'Wrap running test in docker'
|
31
31
|
task :test do
|
32
32
|
exit system("docker exec -ti #{latest_running_container_id} \
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-static-tracing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dale Hamel
|
@@ -176,7 +176,6 @@ files:
|
|
176
176
|
- lib/ruby-static-tracing/tracepoint.rb
|
177
177
|
- lib/ruby-static-tracing/version.rb
|
178
178
|
- lib/tasks/docker.rb
|
179
|
-
- lib/tasks/vagrant.rb
|
180
179
|
homepage: https://github.com/dalehamel/ruby-static-tracing
|
181
180
|
licenses:
|
182
181
|
- MIT
|
data/lib/tasks/vagrant.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
namespace :vagrant do
|
4
|
-
desc 'Sets up a vagrant VM, needed for our development environment.'
|
5
|
-
task :up do
|
6
|
-
system('vagrant up')
|
7
|
-
end
|
8
|
-
|
9
|
-
desc 'Provides a shell within vagrant.'
|
10
|
-
task :ssh do
|
11
|
-
system('vagrant ssh')
|
12
|
-
end
|
13
|
-
|
14
|
-
desc 'Enters a shell within our development docker image, within vagrant.'
|
15
|
-
task :shell do
|
16
|
-
system("vagrant ssh -c 'cd /vagrant && bundle exec rake docker:shell'")
|
17
|
-
end
|
18
|
-
|
19
|
-
desc 'Runs tests within the development docker image, within vagrant'
|
20
|
-
task :tests do
|
21
|
-
system("vagrant ssh -c 'cd /vagrant && bundle exec rake docker:tests'")
|
22
|
-
end
|
23
|
-
|
24
|
-
desc 'Runs integration tests within the development docker image, within vagrant'
|
25
|
-
task :integration do
|
26
|
-
system("vagrant ssh -c 'cd /vagrant && bundle exec rake docker:integration'")
|
27
|
-
end
|
28
|
-
|
29
|
-
desc 'Cleans up the vagrant VM'
|
30
|
-
task :clean do
|
31
|
-
system('vagrant destroy')
|
32
|
-
end
|
33
|
-
end
|