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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d539146e2e9ea21dc04efcdf30e79191e6baa8b26df3404dce11caecce1f41c5
4
- data.tar.gz: a7fcc027f75a89674c33ae66b133c871d3d498de2730a512e62de1849ba81d6d
3
+ metadata.gz: f0f88831910e6d3f1204aa0ef915a11dc0da7602cd7e35cd1d6cf4d3f7d7628a
4
+ data.tar.gz: d7077a225ccfe99c6be0bdc3e85c3bdb69b75c443f2b69f1db48774271c364f7
5
5
  SHA512:
6
- metadata.gz: e5c3b59f152a01cbf066828b248ab10c5ec7453b4457fdd90cc5bf776fa0fb164e48a5c284bf6922bc9deb59f66db537ad17e80547dd567879b516e2592760a8
7
- data.tar.gz: 531f8f45254b8bab2171ebc40afee1395322ff64d7635094a52b25bb1e4dd6915768fbd4bc45ddc4003491cdce0659dfcb4700f398b6eb96f3d5f2069a9dd867
6
+ metadata.gz: ad0ea76443e3222e6638e48fb6c2db9274cb65ffabcbf85d56adc3f57c6638fc73aef8df6d18225932229523a2b476c98b62ce0c83ea988aa7729525a4c7dee9
7
+ data.tar.gz: 9e3287a4eaf2e4e40a7078dfd63463f5487784da13b2bf7dba3baf8340773d1e95817d979f71abd916fed6425b2117d4af915868e6c0b31b84f7b30936ed049f
@@ -1,6 +1,6 @@
1
1
 
2
2
  CC=gcc
3
- CFLAGS= -std=gnu11 $(CFLAGS_EXTRA)
3
+ CFLAGS= -std=gnu11
4
4
  LDFLAGS=-lelf -ldl -Wl,-z,noexecstack
5
5
  VERSION=0.1.0
6
6
 
@@ -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
- provider->_filename = tempElfPath(&fd, provider->name);
131
- #ifdef LIBSTAPSDT_MEMORY_BACKED_FD
132
- provider->_memfd = fd;
133
- #endif
134
- if (provider->_filename == NULL) {
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
- if (provider->_memfd == -1)
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, provider->_filename,
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, provider->_filename,
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
- if (provider->_memfd > 0) {
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;
@@ -47,7 +47,6 @@ typedef struct SDTProvider {
47
47
  // private
48
48
  void *_handle;
49
49
  char *_filename;
50
- int _memfd;
51
50
  } SDTProvider_t;
52
51
 
53
52
  SDTProvider_t *providerInit(const char *name);
@@ -2,5 +2,5 @@
2
2
 
3
3
  module StaticTracing
4
4
  # The current version of this gem
5
- VERSION = '0.0.16'
5
+ VERSION = '0.0.17'
6
6
  end
@@ -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} /app/vagrant/debugfs.sh")
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.16
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
@@ -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