ruby-static-tracing 0.0.4 → 0.0.5

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: 4f7441c911ea06c6fdccfdf83260238d8fcc3c6bdcdfd5e609fa61ebaa278825
4
- data.tar.gz: 3a610594afdc4f9ce33243c070744552f8b4dbc23020f318d0ff1ae543b35963
3
+ metadata.gz: 679e4d3d6d6128445cc8049c76d86c3d9b05f73259f761779078870ce16338ce
4
+ data.tar.gz: 6c2b7fe3a5a1f7fe864e8fb7cec7a7ab9508a80d699f9f70f068259b84c2cbf0
5
5
  SHA512:
6
- metadata.gz: 0a71ffb983b5c994a5ea54260b989250188659eae757ce1a1740ace8be7c6fc526d0aaf68e9ed6a8a65421b8ad6598646a52e000bb4142118f6724d99b23067d
7
- data.tar.gz: 4e38e1cf660b97690d954e91ec9a228faff1695bf8c0fd6f8a8f4a445cef53107d2d6e3605407d0de6d6437ea91aa6c267781c64440735060e67656c89c3dc60
6
+ metadata.gz: c986dfb7d6632a8474108a7edb80101f80d907c608aeb16f6d380aa253b1da5558e2e5157107c0b485fb6d9bc9ca97fddea6186be3b35179b294aac2b119b185
7
+ data.tar.gz: 8a22dfdadc94b7817c35aefe94ca718b255713bac99c4d1998e0af0338a22d49cf2edcd5dc071788b8f765f447fa8f547df72e3d028ff361200edd3d93ff8a5b
@@ -15,6 +15,7 @@ all:
15
15
  cd #{File.join(BASE_DIR, 'libstapsdt')} && make
16
16
  touch deps.so # HACK
17
17
  cp #{File.join(BASE_DIR, 'libstapsdt', 'out/libstapsdt.so.0')} #{LIB_DIR}
18
+ cd #{LIB_DIR} && ln -sf libstapsdt.so.0 libstapsdt.so
18
19
  clean:
19
20
  cd #{File.join(BASE_DIR, 'libstapsdt')} && make clean
20
21
  install:
@@ -0,0 +1,76 @@
1
+
2
+ CC=gcc
3
+ CFLAGS= -std=gnu11
4
+ LDFLAGS=-lelf -ldl -Wl,-z,noexecstack
5
+ VERSION=0.1.0
6
+
7
+ PREFIX=/usr
8
+
9
+ OBJECTS = $(patsubst src/%.c, build/lib/%.o, $(wildcard src/*.c))
10
+ HEADERS = $(wildcard src/*.h)
11
+
12
+ SOLINK = libstapsdt.so
13
+ SONAME = libstapsdt.so.0
14
+
15
+ all: out/libstapsdt.a out/$(SONAME)
16
+
17
+ install:
18
+ mkdir -p $(DESTDIR)$(PREFIX)/lib
19
+ mkdir -p $(DESTDIR)$(PREFIX)/include
20
+ cp out/$(SONAME) $(DESTDIR)$(PREFIX)/lib/$(SONAME)
21
+ cp src/libstapsdt.h $(DESTDIR)$(PREFIX)/include/
22
+ ln -s $(DESTDIR)$(PREFIX)/lib/$(SONAME) $(DESTDIR)$(PREFIX)/lib/$(SOLINK)
23
+
24
+ uninstall:
25
+ rm -f $(DESTDIR)$(PREFIX)/lib/$(SONAME)
26
+ rm -f $(DESTDIR)$(PREFIX)/lib/$(SOLINK)
27
+ rm -f $(DESTDIR)$(PREFIX)/include/libstapsdt.h
28
+
29
+ build/lib/libstapsdt-x86_64.o: src/asm/libstapsdt-x86_64.s
30
+ mkdir -p build
31
+ $(CC) $(CFLAGS) -fPIC -c $^ -o $@
32
+
33
+ build/lib/%.o: src/%.c $(HEADERS)
34
+ mkdir -p build/lib/
35
+ $(CC) $(CFLAGS) -fPIC -c $< -o $@
36
+
37
+ out/libstapsdt.a: $(OBJECTS) build/lib/libstapsdt-x86_64.o
38
+ mkdir -p out
39
+ ar rcs $@ $^
40
+
41
+ out/$(SONAME): $(OBJECTS) build/lib/libstapsdt-x86_64.o
42
+ mkdir -p out
43
+ $(CC) $(CFLAGS) -shared -Wl,-soname=$(SONAME) -o $@ $^ $(LDFLAGS)
44
+
45
+ demo: all example/demo.c
46
+ $(CC) $(CFLAGS) example/demo.c out/libstapsdt.a -o demo -Isrc/ $(LDFLAGS)
47
+
48
+ test: all
49
+ make -C ./tests/
50
+
51
+ clean:
52
+ rm -rf build/*
53
+ rm -rf out/*
54
+ make clean -C ./tests/
55
+
56
+ lint:
57
+ clang-tidy src/*.h src/*.c -- -Isrc/
58
+
59
+ format:
60
+ clang-tidy src/*.h src/*.c -fix -- -Isrc/
61
+
62
+ docs:
63
+ make -C ./docs/ html
64
+
65
+ docs-server:
66
+ cd docs/_build/html; python3 -m http.server;
67
+
68
+ deb-pkg-setup:
69
+ mkdir -p dist/libstapsdt-$(VERSION)/;
70
+ git archive HEAD | gzip > dist/libstapsdt-$(VERSION).tar.gz;
71
+ tar xvzf dist/libstapsdt-$(VERSION).tar.gz -C dist/libstapsdt-$(VERSION)/;
72
+ cd dist/libstapsdt-$(VERSION); dh_make -l -c mit -y -f ../libstapsdt-$(VERSION).tar.gz;
73
+ rm -rf dist/libstapsdt-$(VERSION)/debian/*.ex dist/libstapsdt-$(VERSION)/debian/*.EX dist/libstapsdt-$(VERSION)/debian/README.*
74
+
75
+
76
+ .PHONY: all clear lint format build-tests docs install uninstall deb-pkg-setup
@@ -0,0 +1,14 @@
1
+ .text
2
+
3
+ .align 4, 0x90
4
+ .globl _funcStart
5
+ .globl _funcEnd
6
+
7
+ _funcStart:
8
+ nop
9
+ nop
10
+ nop
11
+ nop
12
+ ret
13
+ _funcEnd:
14
+ nop
@@ -0,0 +1,168 @@
1
+ CC = gcc
2
+ CFLAGS = -O2 -Wall
3
+
4
+ # MAC_BUILD - set this to "universal" to build a 2-way fat library
5
+ MAC_BUILD = universal
6
+
7
+ ARCH=x86_64
8
+
9
+ # if ARCH set, disable universal build on the mac
10
+ ifdef ARCH
11
+ MAC_BUILD =
12
+ else
13
+ ARCH = $(shell uname -m)
14
+ endif
15
+
16
+ UNAME = $(shell uname -s)
17
+
18
+ ifeq ($(UNAME), Linux)
19
+ RANLIB=ranlib
20
+ CFLAGS+=-D_GNU_SOURCE -fPIC
21
+ endif
22
+
23
+ ifeq ($(UNAME), SunOS)
24
+ RANLIB=/bin/true
25
+ PATH +=:/usr/perl5/5.10.0/bin:/usr/perl5/5.12/bin
26
+ CFLAGS += -fPIC
27
+ ifeq ($(ARCH), i86pc)
28
+ ARCH = $(shell isainfo -k)
29
+ ifeq ($(ARCH), amd64)
30
+ ARCH = x86_64
31
+ else
32
+ ARCH = i386
33
+ endif
34
+ endif
35
+ ifeq ($(ARCH), x86_64)
36
+ CFLAGS += -m64
37
+ else
38
+ CFLAGS += -m32
39
+ endif
40
+ endif
41
+
42
+ ifeq ($(UNAME), FreeBSD)
43
+ RANLIB=ranlib
44
+ CFLAGS += -Wno-error=unknown-pragmas -I/usr/src/sys/cddl/compat/opensolaris -I/usr/src/sys/cddl/contrib/opensolaris/uts/common
45
+ CFLAGS += -fPIC
46
+ ifeq ($(ARCH), i386)
47
+ CFLAGS += -m32
48
+ endif
49
+ ifeq ($(ARCH), amd64)
50
+ ARCH = x86_64
51
+ endif
52
+ endif
53
+
54
+ ifeq ($(UNAME), Darwin)
55
+ RANLIB=ranlib
56
+ ifeq ($(MAC_BUILD), universal)
57
+ CFLAGS += -arch i386 -arch x86_64
58
+ else
59
+ CFLAGS += -arch $(ARCH)
60
+ endif
61
+ endif
62
+
63
+ # main library build
64
+ objects = usdt.o usdt_dof_file.o usdt_tracepoints.o usdt_probe.o usdt_dof.o usdt_dof_sections.o
65
+ headers = usdt.h usdt_internal.h
66
+
67
+ .c.o: $(headers)
68
+
69
+ ifeq ($(UNAME), Darwin)
70
+ all: libusdt.a libusdt.dylib
71
+ else
72
+ all: libusdt.a
73
+ endif
74
+
75
+ libusdt.dylib: $(objects)
76
+ $(CC) $(CFLAGS) -dynamiclib -o $@ $^
77
+
78
+ libusdt.a: $(objects) $(headers)
79
+ rm -f libusdt.a
80
+ $(AR) cru libusdt.a $(objects)
81
+ $(RANLIB) libusdt.a
82
+
83
+ # Tracepoints build.
84
+ #
85
+ # If on Darwin and building a universal library, manually assemble a
86
+ # two-way fat object file from both the 32 and 64 bit tracepoint asm
87
+ # files.
88
+ #
89
+ # Otherwise, just choose the appropriate asm file based on the build
90
+ # architecture.
91
+
92
+ ifeq ($(UNAME), Darwin)
93
+ ifeq ($(MAC_BUILD), universal)
94
+
95
+ usdt_tracepoints_i386.o: usdt_tracepoints_i386.s
96
+ $(CC) -arch i386 -o usdt_tracepoints_i386.o -c usdt_tracepoints_i386.s
97
+
98
+ usdt_tracepoints_x86_64.o: usdt_tracepoints_x86_64.s
99
+ $(CC) -arch x86_64 -o usdt_tracepoints_x86_64.o -c usdt_tracepoints_x86_64.s
100
+
101
+ usdt_tracepoints.o: usdt_tracepoints_i386.o usdt_tracepoints_x86_64.o
102
+ lipo -create -output usdt_tracepoints.o usdt_tracepoints_i386.o \
103
+ usdt_tracepoints_x86_64.o
104
+
105
+ else # Darwin, not universal
106
+ usdt_tracepoints.o: usdt_tracepoints_$(ARCH).s
107
+ $(CC) -arch $(ARCH) -o usdt_tracepoints.o -c usdt_tracepoints_$(ARCH).s
108
+ endif
109
+
110
+ else # not Darwin; FreeBSD and Illumos
111
+
112
+ ifeq ($(ARCH), x86_64)
113
+ usdt_tracepoints.o: usdt_tracepoints_x86_64.s
114
+ $(CC) $(CFLAGS) -o usdt_tracepoints.o -c usdt_tracepoints_x86_64.s
115
+ endif
116
+ ifeq ($(ARCH), i386)
117
+ usdt_tracepoints.o: usdt_tracepoints_i386.s
118
+ $(CC) $(CFLAGS) -o usdt_tracepoints.o -c usdt_tracepoints_i386.s
119
+ endif
120
+
121
+ endif
122
+
123
+ clean:
124
+ rm -f *.gch
125
+ rm -f *.o
126
+ rm -f libusdt.a
127
+ rm -f libusdt.dylib
128
+ rm -f test_usdt
129
+ rm -f test_usdt32
130
+ rm -f test_usdt64
131
+ rm -f test_mem_usage
132
+
133
+ .PHONY: clean test
134
+
135
+ # testing
136
+
137
+ test_mem_usage: libusdt.a test_mem_usage.o
138
+ $(CC) $(CFLAGS) -o test_mem_usage test_mem_usage.o libusdt.a
139
+
140
+ ifeq ($(UNAME), Darwin)
141
+ ifeq ($(MAC_BUILD), universal)
142
+ test_usdt64: libusdt.a test_usdt.o
143
+ $(CC) -arch x86_64 -o test_usdt64 test_usdt.o libusdt.a
144
+ test_usdt32: libusdt.a test_usdt.o
145
+ $(CC) -arch i386 -o test_usdt32 test_usdt.o libusdt.a
146
+ else
147
+ test_usdt: libusdt.a test_usdt.o
148
+ $(CC) $(CFLAGS) -o test_usdt test_usdt.o libusdt.a
149
+ endif
150
+ else
151
+ test_usdt: libusdt.a test_usdt.o
152
+ $(CC) $(CFLAGS) -o test_usdt test_usdt.o libusdt.a
153
+ endif
154
+
155
+ ifeq ($(UNAME), Darwin)
156
+ ifeq ($(MAC_BUILD), universal)
157
+ test: test_usdt32 test_usdt64
158
+ sudo prove test.pl :: 64
159
+ sudo prove test.pl :: 32
160
+ else
161
+ test: test_usdt
162
+ sudo prove test.pl
163
+ endif
164
+ else
165
+ test: test_usdt
166
+ sudo prove test.pl
167
+ endif
168
+
@@ -0,0 +1,77 @@
1
+ /*
2
+ * Copyright (c) 2012, Chris Andrews. All rights reserved.
3
+ */
4
+
5
+ #include "usdt.h"
6
+
7
+ #include <stdio.h>
8
+ #include <stdlib.h>
9
+ #include <string.h>
10
+
11
+ static void
12
+ create_and_free_provider(int argc, char **argv)
13
+ {
14
+ usdt_provider_t *provider;
15
+ usdt_probedef_t *probedef;
16
+
17
+ if ((provider = usdt_create_provider("testlibusdt", "modname")) == NULL) {
18
+ fprintf(stderr, "unable to create provider\n");
19
+ exit (1);
20
+ }
21
+ if ((probedef = usdt_create_probe((const char *)argv[1],
22
+ (const char *)argv[2],
23
+ (argc-3), (const char **)&argv[3])) == NULL)
24
+ {
25
+ fprintf(stderr, "unable to create probe\n");
26
+ exit (1);
27
+ }
28
+ usdt_provider_add_probe(provider, probedef);
29
+
30
+ if ((usdt_provider_enable(provider)) < 0) {
31
+ fprintf(stderr, "unable to enable provider: %s\n", usdt_errstr(provider));
32
+ exit (1);
33
+ }
34
+
35
+ if ((usdt_provider_disable(provider)) < 0) {
36
+ fprintf(stderr, "unable to disable provider: %s\n", usdt_errstr(provider));
37
+ exit (1);
38
+ }
39
+
40
+ usdt_probe_release(probedef);
41
+ usdt_provider_free(provider);
42
+ }
43
+
44
+ int
45
+ main(int argc, char **argv)
46
+ {
47
+ char char_argv[USDT_ARG_MAX];
48
+ int int_argv[USDT_ARG_MAX * 2];
49
+ int i;
50
+ char buf[255];
51
+
52
+ for (i = 0; i < USDT_ARG_MAX; i++)
53
+ int_argv[i] = i + 1;
54
+ for (i = 0; i < USDT_ARG_MAX; i++)
55
+ char_argv[i] = (char) i + 65;
56
+
57
+ if (argc < 3) {
58
+ fprintf(stderr, "usage: %s func name [types ...]\n", argv[0]);
59
+ return(1);
60
+ }
61
+
62
+ for (i = 0; i < USDT_ARG_MAX; i++) {
63
+ if (argv[i+3] != NULL && i+3 < argc) {
64
+ if (strncmp("c", argv[i+3], 1) == 0) {
65
+ argv[i+3] = strdup("char *");
66
+ }
67
+ if (strncmp("i", argv[i+3], 1) == 0) {
68
+ argv[i+3] = strdup("int");
69
+ }
70
+ }
71
+ }
72
+
73
+ for (i = 0; i < 100000; i++)
74
+ create_and_free_provider(argc, argv);
75
+
76
+ return 0;
77
+ }
@@ -0,0 +1,87 @@
1
+ /*
2
+ * Copyright (c) 2012, Chris Andrews. All rights reserved.
3
+ */
4
+
5
+ #include "usdt.h"
6
+
7
+ #include <stdio.h>
8
+ #include <stdlib.h>
9
+ #include <string.h>
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
+ int main(int argc, char **argv) {
19
+ usdt_provider_t *provider;
20
+ usdt_probedef_t *probedef;
21
+ char char_argv[USDT_ARG_MAX];
22
+ int int_argv[USDT_ARG_MAX * 2];
23
+ void **args = NULL;
24
+ int i;
25
+ char buf[255];
26
+
27
+ for (i = 0; i < USDT_ARG_MAX; i++)
28
+ int_argv[i] = i + 1;
29
+ for (i = 0; i < USDT_ARG_MAX; i++)
30
+ char_argv[i] = (char) i + 65;
31
+
32
+ if (argc < 3) {
33
+ fprintf(stderr, "usage: %s func name [types ...]\n", argv[0]);
34
+ return(1);
35
+ }
36
+
37
+ if (argc > 3) {
38
+ args = malloc((argc-3) * sizeof(void *));
39
+ }
40
+
41
+ for (i = 0; i < USDT_ARG_MAX; i++) {
42
+ if (argv[i+3] != NULL && i+3 < argc) {
43
+ if (strncmp("c", argv[i+3], 1) == 0) {
44
+ args[i] = (void *)strndup(&char_argv[i], 1);
45
+ argv[i+3] = strdup("char *");
46
+ }
47
+ if (strncmp("i", argv[i+3], 1) == 0) {
48
+ args[i] = (void *)(long)int_argv[i];
49
+ argv[i+3] = strdup("int");
50
+ }
51
+ }
52
+ }
53
+
54
+ if ((provider = usdt_create_provider("testlibusdt", "modname")) == NULL) {
55
+ fprintf(stderr, "unable to create provider\n");
56
+ exit (1);
57
+ }
58
+ if ((probedef = usdt_create_probe((const char *)argv[1],
59
+ (const char *)argv[2],
60
+ (argc-3), (const char **)&argv[3])) == NULL)
61
+ {
62
+ fprintf(stderr, "unable to create probe\n");
63
+ exit (1);
64
+ }
65
+ usdt_provider_add_probe(provider, probedef);
66
+
67
+ if ((usdt_provider_enable(provider)) < 0) {
68
+ fprintf(stderr, "unable to enable provider: %s\n", usdt_errstr(provider));
69
+ exit (1);
70
+ }
71
+
72
+ fprintf(stdout, "enabled\n");
73
+ fflush(stdout);
74
+ fgets(buf, 255, stdin);
75
+
76
+ fire_probe(probedef, (argc-3), (void **)args);
77
+ usdt_probe_release(probedef);
78
+
79
+ if ((usdt_provider_disable(provider)) < 0) {
80
+ fprintf(stderr, "unable to disable provider: %s\n", usdt_errstr(provider));
81
+ exit (1);
82
+ }
83
+
84
+ usdt_provider_free(provider);
85
+
86
+ return 0;
87
+ }