raygun-apm 1.1.15.pre3-x86-linux → 1.1.15.pre4-x86-linux

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77fff51c296978612f71a47e08f06838e3ff28b1794cad9f79d241dca3c472b2
4
- data.tar.gz: 6d78de8022fabc1f0f5441fcdf178ae31f1eeaae2318510063e2164d60df8b3f
3
+ metadata.gz: bbf03bf530c0a8a8bb69514d4529cd700770da1cc9e3808003594f45d32d6f22
4
+ data.tar.gz: 9c2bf89093d4fd1d8e12934e92426c10dcb0a1ae913fbf7e365aab279f41b872
5
5
  SHA512:
6
- metadata.gz: 501e37b5bf10d7839b2155ce720d45258e90c3fb5d685d811c2fe302f7ffcb283b16cfe502b04d641e59ec637bf11f87f85564c038d4a935b9e8568fbe7419c4
7
- data.tar.gz: 4d64f0c99faa837abfb31d4f3e6e5f62ec26308cd241353a0f3d40e81699e339275d91658b752cf545c9d56b9ce06b829bed7fe6f5ef6c00ffb8b098e302de82
6
+ metadata.gz: 0b6dda7478eabbbe66b2d980ed5db45910ff671607dd6d6d76b7fd229744358e61dd4da3bd57cd996ce960a09fa68211b5fbaca9f5a1e818780b3faaea1a2cd4
7
+ data.tar.gz: 999da95dccdad910b2c6246d70bca3fcbda5f83938a2e6068a1d26180d2b5319c32c57d6c8bb3d97985a0a88a496969004101b39567025b1407d056dbd6b5209
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Copyright (c) 2011, Willem-Hendrik Thiart
3
+ * Use of this source code is governed by a BSD-style license that can be
4
+ * found in the LICENSE file.
5
+ *
6
+ * @file
7
+ * @author Willem Thiart himself@willemthiart.com
8
+ */
9
+
10
+ #include "stdio.h"
11
+ #include <stdlib.h>
12
+
13
+ /* for memcpy */
14
+ #include <string.h>
15
+
16
+ #include "bipbuffer.h"
17
+
18
+ size_t bipbuf_sizeof(const unsigned int size)
19
+ {
20
+ return sizeof(bipbuf_t) + size;
21
+ }
22
+
23
+ int bipbuf_unused(const bipbuf_t* me)
24
+ {
25
+ if (1 == me->b_inuse)
26
+ /* distance between region B and region A */
27
+ return (int)(me->a_start - me->b_end);
28
+ else
29
+ return (int)(me->size - me->a_end);
30
+ }
31
+
32
+ int bipbuf_size(const bipbuf_t* me)
33
+ {
34
+ return (int)me->size;
35
+ }
36
+
37
+ int bipbuf_used(const bipbuf_t* me)
38
+ {
39
+ return (int)((me->a_end - me->a_start) + me->b_end);
40
+ }
41
+
42
+ void bipbuf_init(bipbuf_t* me, const unsigned int size)
43
+ {
44
+ me->a_start = me->a_end = me->b_end = 0;
45
+ me->size = size;
46
+ me->b_inuse = 0;
47
+ }
48
+
49
+ bipbuf_t *bipbuf_new(const unsigned int size)
50
+ {
51
+ bipbuf_t *me = malloc(bipbuf_sizeof(size));
52
+ if (!me)
53
+ return NULL;
54
+ bipbuf_init(me, size);
55
+ return me;
56
+ }
57
+
58
+ void bipbuf_free(bipbuf_t* me)
59
+ {
60
+ free(me);
61
+ }
62
+
63
+ int bipbuf_is_empty(const bipbuf_t* me)
64
+ {
65
+ return me->a_start == me->a_end;
66
+ }
67
+
68
+ /* find out if we should turn on region B
69
+ * ie. is the distance from A to buffer's end less than B to A? */
70
+ static void __check_for_switch_to_b(bipbuf_t* me)
71
+ {
72
+ if (me->size - me->a_end < me->a_start - me->b_end)
73
+ me->b_inuse = 1;
74
+ }
75
+
76
+ int bipbuf_offer(bipbuf_t* me, const unsigned char *data, const int size)
77
+ {
78
+ /* not enough space */
79
+ if (bipbuf_unused(me) < size)
80
+ return 0;
81
+
82
+ if (1 == me->b_inuse)
83
+ {
84
+ memcpy(me->data + me->b_end, data, size);
85
+ me->b_end += size;
86
+ }
87
+ else
88
+ {
89
+ memcpy(me->data + me->a_end, data, size);
90
+ me->a_end += size;
91
+ }
92
+
93
+ __check_for_switch_to_b(me);
94
+ return size;
95
+ }
96
+
97
+ unsigned char *bipbuf_peek(const bipbuf_t* me, const unsigned int size)
98
+ {
99
+ /* make sure we can actually peek at this data */
100
+ if (me->size < me->a_start + size)
101
+ return NULL;
102
+
103
+ if (bipbuf_is_empty(me))
104
+ return NULL;
105
+
106
+ return (unsigned char*)me->data + me->a_start;
107
+ }
108
+
109
+ unsigned char *bipbuf_poll(bipbuf_t* me, const unsigned int size)
110
+ {
111
+ if (bipbuf_is_empty(me))
112
+ return NULL;
113
+
114
+ /* make sure we can actually poll this data */
115
+ if (me->size < me->a_start + size)
116
+ return NULL;
117
+
118
+ void *end = me->data + me->a_start;
119
+ me->a_start += size;
120
+
121
+ /* we seem to be empty.. */
122
+ if (me->a_start == me->a_end)
123
+ {
124
+ /* replace a with region b */
125
+ if (1 == me->b_inuse)
126
+ {
127
+ me->a_start = 0;
128
+ me->a_end = me->b_end;
129
+ me->b_end = me->b_inuse = 0;
130
+ }
131
+ else
132
+ /* safely move cursor back to the start because we are empty */
133
+ me->a_start = me->a_end = 0;
134
+ }
135
+
136
+ __check_for_switch_to_b(me);
137
+ return end;
138
+ }
@@ -0,0 +1,76 @@
1
+ #ifndef BIPBUFFER_H
2
+ #define BIPBUFFER_H
3
+
4
+ typedef struct
5
+ {
6
+ unsigned long int size;
7
+
8
+ /* region A */
9
+ unsigned int a_start, a_end;
10
+
11
+ /* region B */
12
+ unsigned int b_end;
13
+
14
+ /* is B inuse? */
15
+ int b_inuse;
16
+
17
+ unsigned char data[];
18
+ } bipbuf_t;
19
+
20
+ /**
21
+ * Create a new bip buffer.
22
+ *
23
+ * malloc()s space
24
+ *
25
+ * @param[in] size The size of the buffer */
26
+ bipbuf_t *bipbuf_new(const unsigned int size);
27
+
28
+ /**
29
+ * Initialise a bip buffer. Use memory provided by user.
30
+ *
31
+ * No malloc()s are performed.
32
+ *
33
+ * @param[in] size The size of the array */
34
+ void bipbuf_init(bipbuf_t* me, const unsigned int size);
35
+
36
+ /**
37
+ * Free the bip buffer */
38
+ void bipbuf_free(bipbuf_t *me);
39
+
40
+ /**
41
+ * @param[in] data The data to be offered to the buffer
42
+ * @param[in] size The size of the data to be offered
43
+ * @return number of bytes offered */
44
+ int bipbuf_offer(bipbuf_t *me, const unsigned char *data, const int size);
45
+
46
+ /**
47
+ * Look at data. Don't move cursor
48
+ *
49
+ * @param[in] len The length of the data to be peeked
50
+ * @return data on success, NULL if we can't peek at this much data */
51
+ unsigned char *bipbuf_peek(const bipbuf_t* me, const unsigned int len);
52
+
53
+ /**
54
+ * Get pointer to data to read. Move the cursor on.
55
+ *
56
+ * @param[in] len The length of the data to be polled
57
+ * @return pointer to data, NULL if we can't poll this much data */
58
+ unsigned char *bipbuf_poll(bipbuf_t* me, const unsigned int size);
59
+
60
+ /**
61
+ * @return the size of the bipbuffer */
62
+ int bipbuf_size(const bipbuf_t* me);
63
+
64
+ /**
65
+ * @return 1 if buffer is empty; 0 otherwise */
66
+ int bipbuf_is_empty(const bipbuf_t* me);
67
+
68
+ /**
69
+ * @return how much space we have assigned */
70
+ int bipbuf_used(const bipbuf_t* cb);
71
+
72
+ /**
73
+ * @return bytes of unused space */
74
+ int bipbuf_unused(const bipbuf_t* me);
75
+
76
+ #endif /* BIPBUFFER_H */
@@ -0,0 +1,114 @@
1
+ # encoding: utf-8
2
+
3
+ # Makefile generator helper - from standard library
4
+ require 'mkmf'
5
+
6
+ # References core headers extracted by Ruby minor version in https://github.com/os97673/debase-ruby_core_source
7
+ # Required for some of the lower level profiler features (vm_core.h, rb_thread_t, etc.)
8
+ begin
9
+ require 'debase/ruby_core_source'
10
+ rescue LoadError => e
11
+ STDERR.puts "=" * 70
12
+ STDERR.puts "Raygun APM: Failed to load debase-ruby_core_source"
13
+ STDERR.puts ""
14
+ STDERR.puts "This gem is required to compile the native extension against Ruby VM internals."
15
+ STDERR.puts "Please ensure debase-ruby_core_source >= 3.3.6 is installed:"
16
+ STDERR.puts ""
17
+ STDERR.puts " gem install debase-ruby_core_source"
18
+ STDERR.puts ""
19
+ STDERR.puts "Error: #{e.message}"
20
+ STDERR.puts "=" * 70
21
+ exit(1)
22
+ end
23
+
24
+ # Verify we have headers for the current Ruby version
25
+ ruby_version = "#{RUBY_VERSION}"
26
+ STDERR.puts "[Raygun APM] Building native extension for Ruby #{ruby_version}"
27
+
28
+ headers = proc do
29
+ have_header('ruby.h') &&
30
+ have_header('ruby/debug.h') &&
31
+ have_header("vm_core.h")
32
+ end
33
+
34
+ dir_config('raygun')
35
+
36
+ # To allow for swapping out the compiler - clang in favour of gcc for example
37
+ RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
38
+
39
+ # Pedantic about all the things
40
+ append_cflags '-pedantic'
41
+ append_cflags '-Wall'
42
+ append_cflags '-std=c99'
43
+ append_cflags '-std=gnu99'
44
+ append_cflags '-fdeclspec'
45
+ append_cflags '-fms-extensions'
46
+ append_cflags '-ggdb3'
47
+
48
+ # Check if using clang (supports more warning flags)
49
+ is_clang = RbConfig::CONFIG['CC'] =~ /clang/ || `#{RbConfig::CONFIG['CC']} --version 2>/dev/null`.include?('clang')
50
+
51
+ if is_clang
52
+ # Clang-specific warning suppressions
53
+ append_cflags '-Wno-shorten-64-to-32'
54
+ append_cflags '-Wno-unknown-warning-option'
55
+ append_cflags '-Wno-incompatible-pointer-types-discards-qualifiers'
56
+ append_cflags '-Wno-self-assign'
57
+ append_cflags '-Wno-parentheses-equality'
58
+ append_cflags '-Wno-constant-logical-operand'
59
+ else
60
+ # GCC 12+ use-after-free false positive in third-party rax.c
61
+ append_cflags '-Wno-use-after-free'
62
+ end
63
+
64
+ # Only use -Werror in CI/development, not in production builds
65
+ if ENV['WERROR'] || ENV['CI']
66
+ append_cflags '-Werror'
67
+ end
68
+
69
+ # Enables additional flags, stack protection and debug symbols
70
+ if ENV['DEBUG']
71
+ have_library 'ssp'
72
+ have_func '__stack_chk_guard'
73
+ have_func '__stack_chk_fail'
74
+ append_cflags '-ggdb3'
75
+ # Needed reduced -On levels for SSP to do its job.
76
+ # Used to be -O0 but switched to -Og since -O0 disables
77
+ # some optimizations that debug tools need.
78
+ # https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
79
+ append_cflags '-Og'
80
+ append_cflags '-fstack-protector-all'
81
+ append_cflags '-DRB_RG_DEBUG'
82
+ else
83
+ append_cflags '-O3'
84
+ end
85
+
86
+ # Renders an ASCII presentation of the shadow stack at runtime
87
+ if ENV['DEBUG_SHADOW_STACK']
88
+ append_cflags '-DRB_RG_DEBUG_SHADOW_STACK'
89
+ end
90
+
91
+ unless create_header
92
+ STDERR.print("extconf.h creation failed\n")
93
+ exit(1)
94
+ end
95
+
96
+ # Check for the presence of headers in ruby_core_headers for the version currently compiled for
97
+ unless Debase::RubyCoreSource.create_makefile_with_core(headers, 'raygun_ext')
98
+ STDERR.puts "=" * 70
99
+ STDERR.puts "Raygun APM: Makefile creation failed"
100
+ STDERR.puts ""
101
+ STDERR.puts "One or more Ruby VM headers (vm_core.h) were not found for Ruby #{ruby_version}."
102
+ STDERR.puts ""
103
+ STDERR.puts "This usually means debase-ruby_core_source does not yet have headers"
104
+ STDERR.puts "for your Ruby version. Please try updating the gem:"
105
+ STDERR.puts ""
106
+ STDERR.puts " gem update debase-ruby_core_source"
107
+ STDERR.puts ""
108
+ STDERR.puts "If the problem persists, please report this issue at:"
109
+ STDERR.puts " https://github.com/MindscapeHQ/raygun-apm-ruby/issues"
110
+ STDERR.puts "=" * 70
111
+ exit(1)
112
+ end
113
+
114
+ STDERR.puts "[Raygun APM] Native extension configured successfully"