pf2 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -2
  3. data/Cargo.lock +186 -17
  4. data/Cargo.toml +1 -1
  5. data/README.md +18 -6
  6. data/Rakefile +8 -0
  7. data/crates/backtrace-sys2/.gitignore +1 -0
  8. data/crates/backtrace-sys2/Cargo.toml +9 -0
  9. data/crates/backtrace-sys2/build.rs +48 -0
  10. data/crates/backtrace-sys2/src/lib.rs +5 -0
  11. data/crates/backtrace-sys2/src/libbacktrace/.gitignore +15 -0
  12. data/crates/backtrace-sys2/src/libbacktrace/Isaac.Newton-Opticks.txt +9286 -0
  13. data/crates/backtrace-sys2/src/libbacktrace/LICENSE +29 -0
  14. data/crates/backtrace-sys2/src/libbacktrace/Makefile.am +623 -0
  15. data/crates/backtrace-sys2/src/libbacktrace/Makefile.in +2666 -0
  16. data/crates/backtrace-sys2/src/libbacktrace/README.md +36 -0
  17. data/crates/backtrace-sys2/src/libbacktrace/aclocal.m4 +864 -0
  18. data/crates/backtrace-sys2/src/libbacktrace/alloc.c +167 -0
  19. data/crates/backtrace-sys2/src/libbacktrace/allocfail.c +136 -0
  20. data/crates/backtrace-sys2/src/libbacktrace/allocfail.sh +104 -0
  21. data/crates/backtrace-sys2/src/libbacktrace/atomic.c +113 -0
  22. data/crates/backtrace-sys2/src/libbacktrace/backtrace-supported.h.in +66 -0
  23. data/crates/backtrace-sys2/src/libbacktrace/backtrace.c +129 -0
  24. data/crates/backtrace-sys2/src/libbacktrace/backtrace.h +189 -0
  25. data/crates/backtrace-sys2/src/libbacktrace/btest.c +501 -0
  26. data/crates/backtrace-sys2/src/libbacktrace/compile +348 -0
  27. data/crates/backtrace-sys2/src/libbacktrace/config/enable.m4 +38 -0
  28. data/crates/backtrace-sys2/src/libbacktrace/config/lead-dot.m4 +31 -0
  29. data/crates/backtrace-sys2/src/libbacktrace/config/libtool.m4 +7436 -0
  30. data/crates/backtrace-sys2/src/libbacktrace/config/ltoptions.m4 +369 -0
  31. data/crates/backtrace-sys2/src/libbacktrace/config/ltsugar.m4 +123 -0
  32. data/crates/backtrace-sys2/src/libbacktrace/config/ltversion.m4 +23 -0
  33. data/crates/backtrace-sys2/src/libbacktrace/config/lt~obsolete.m4 +98 -0
  34. data/crates/backtrace-sys2/src/libbacktrace/config/multi.m4 +68 -0
  35. data/crates/backtrace-sys2/src/libbacktrace/config/override.m4 +117 -0
  36. data/crates/backtrace-sys2/src/libbacktrace/config/unwind_ipinfo.m4 +37 -0
  37. data/crates/backtrace-sys2/src/libbacktrace/config/warnings.m4 +227 -0
  38. data/crates/backtrace-sys2/src/libbacktrace/config.guess +1700 -0
  39. data/crates/backtrace-sys2/src/libbacktrace/config.h.in +182 -0
  40. data/crates/backtrace-sys2/src/libbacktrace/config.sub +1885 -0
  41. data/crates/backtrace-sys2/src/libbacktrace/configure +15740 -0
  42. data/crates/backtrace-sys2/src/libbacktrace/configure.ac +613 -0
  43. data/crates/backtrace-sys2/src/libbacktrace/dwarf.c +4402 -0
  44. data/crates/backtrace-sys2/src/libbacktrace/edtest.c +120 -0
  45. data/crates/backtrace-sys2/src/libbacktrace/edtest2.c +43 -0
  46. data/crates/backtrace-sys2/src/libbacktrace/elf.c +7443 -0
  47. data/crates/backtrace-sys2/src/libbacktrace/fileline.c +407 -0
  48. data/crates/backtrace-sys2/src/libbacktrace/filenames.h +52 -0
  49. data/crates/backtrace-sys2/src/libbacktrace/filetype.awk +13 -0
  50. data/crates/backtrace-sys2/src/libbacktrace/install-debuginfo-for-buildid.sh.in +65 -0
  51. data/crates/backtrace-sys2/src/libbacktrace/install-sh +501 -0
  52. data/crates/backtrace-sys2/src/libbacktrace/instrumented_alloc.c +114 -0
  53. data/crates/backtrace-sys2/src/libbacktrace/internal.h +389 -0
  54. data/crates/backtrace-sys2/src/libbacktrace/libtool.m4 +7436 -0
  55. data/crates/backtrace-sys2/src/libbacktrace/ltmain.sh +8636 -0
  56. data/crates/backtrace-sys2/src/libbacktrace/ltoptions.m4 +369 -0
  57. data/crates/backtrace-sys2/src/libbacktrace/ltsugar.m4 +123 -0
  58. data/crates/backtrace-sys2/src/libbacktrace/ltversion.m4 +23 -0
  59. data/crates/backtrace-sys2/src/libbacktrace/lt~obsolete.m4 +98 -0
  60. data/crates/backtrace-sys2/src/libbacktrace/macho.c +1355 -0
  61. data/crates/backtrace-sys2/src/libbacktrace/missing +215 -0
  62. data/crates/backtrace-sys2/src/libbacktrace/mmap.c +331 -0
  63. data/crates/backtrace-sys2/src/libbacktrace/mmapio.c +110 -0
  64. data/crates/backtrace-sys2/src/libbacktrace/move-if-change +83 -0
  65. data/crates/backtrace-sys2/src/libbacktrace/mtest.c +410 -0
  66. data/crates/backtrace-sys2/src/libbacktrace/nounwind.c +66 -0
  67. data/crates/backtrace-sys2/src/libbacktrace/pecoff.c +957 -0
  68. data/crates/backtrace-sys2/src/libbacktrace/posix.c +104 -0
  69. data/crates/backtrace-sys2/src/libbacktrace/print.c +92 -0
  70. data/crates/backtrace-sys2/src/libbacktrace/read.c +110 -0
  71. data/crates/backtrace-sys2/src/libbacktrace/simple.c +108 -0
  72. data/crates/backtrace-sys2/src/libbacktrace/sort.c +108 -0
  73. data/crates/backtrace-sys2/src/libbacktrace/state.c +72 -0
  74. data/crates/backtrace-sys2/src/libbacktrace/stest.c +137 -0
  75. data/crates/backtrace-sys2/src/libbacktrace/test-driver +148 -0
  76. data/crates/backtrace-sys2/src/libbacktrace/test_format.c +55 -0
  77. data/crates/backtrace-sys2/src/libbacktrace/testlib.c +234 -0
  78. data/crates/backtrace-sys2/src/libbacktrace/testlib.h +110 -0
  79. data/crates/backtrace-sys2/src/libbacktrace/ttest.c +161 -0
  80. data/crates/backtrace-sys2/src/libbacktrace/unittest.c +92 -0
  81. data/crates/backtrace-sys2/src/libbacktrace/unknown.c +65 -0
  82. data/crates/backtrace-sys2/src/libbacktrace/xcoff.c +1606 -0
  83. data/crates/backtrace-sys2/src/libbacktrace/xztest.c +508 -0
  84. data/crates/backtrace-sys2/src/libbacktrace/zstdtest.c +523 -0
  85. data/crates/backtrace-sys2/src/libbacktrace/ztest.c +541 -0
  86. data/ext/pf2/Cargo.toml +1 -0
  87. data/ext/pf2/src/backtrace.rs +127 -0
  88. data/ext/pf2/src/lib.rs +3 -0
  89. data/ext/pf2/src/profile.rs +16 -1
  90. data/ext/pf2/src/profile_serializer.rs +95 -21
  91. data/ext/pf2/src/ringbuffer.rs +7 -0
  92. data/ext/pf2/src/ruby_init.rs +18 -6
  93. data/ext/pf2/src/ruby_internal_apis.rs +47 -0
  94. data/ext/pf2/src/sample.rs +22 -1
  95. data/ext/pf2/src/signal_scheduler/configuration.rs +7 -0
  96. data/ext/pf2/src/signal_scheduler/timer_installer.rs +79 -126
  97. data/ext/pf2/src/signal_scheduler.rs +95 -26
  98. data/ext/pf2/src/timer_thread_scheduler.rs +88 -12
  99. data/ext/pf2/src/util.rs +2 -2
  100. data/lib/pf2/reporter.rb +12 -5
  101. data/lib/pf2/version.rb +1 -1
  102. data/lib/pf2.rb +3 -6
  103. metadata +97 -6
@@ -0,0 +1,120 @@
1
+ /* edtest.c -- Test for libbacktrace storage allocation stress handling
2
+ Copyright (C) 2017-2021 Free Software Foundation, Inc.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are
6
+ met:
7
+
8
+ (1) Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ (2) Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in
13
+ the documentation and/or other materials provided with the
14
+ distribution.
15
+
16
+ (3) The name of the author may not be used to
17
+ endorse or promote products derived from this software without
18
+ specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ POSSIBILITY OF SUCH DAMAGE. */
31
+
32
+ #include "config.h"
33
+
34
+ #include <assert.h>
35
+ #include <stdio.h>
36
+ #include <stdlib.h>
37
+ #include <string.h>
38
+ #include <sys/types.h>
39
+
40
+ #include "backtrace.h"
41
+ #include "backtrace-supported.h"
42
+ #include "internal.h"
43
+
44
+ #include "testlib.h"
45
+
46
+ static int test1 (void) __attribute__ ((noinline, noclone, unused));
47
+ extern int f2 (int);
48
+ extern int f3 (int, int);
49
+
50
+ static int
51
+ test1 (void)
52
+ {
53
+ /* Returning a value here and elsewhere avoids a tailcall which
54
+ would mess up the backtrace. */
55
+ return f2 (__LINE__) + 1;
56
+ }
57
+
58
+ int
59
+ f3 (int f1line, int f2line)
60
+ {
61
+ struct info all[20];
62
+ struct bdata data;
63
+ int f3line;
64
+ int i;
65
+
66
+ data.all = &all[0];
67
+ data.index = 0;
68
+ data.max = 20;
69
+ data.failed = 0;
70
+
71
+ f3line = __LINE__ + 1;
72
+ i = backtrace_full (state, 0, callback_one, error_callback_one, &data);
73
+
74
+ if (i != 0)
75
+ {
76
+ fprintf (stderr, "test1: unexpected return value %d\n", i);
77
+ data.failed = 1;
78
+ }
79
+
80
+ if (data.index < 3)
81
+ {
82
+ fprintf (stderr,
83
+ "test1: not enough frames; got %zu, expected at least 3\n",
84
+ data.index);
85
+ data.failed = 1;
86
+ }
87
+
88
+ check ("test1", 0, all, f3line, "f3", "edtest.c", &data.failed);
89
+ check ("test1", 1, all, f2line, "f2", "edtest2_build.c", &data.failed);
90
+ check ("test1", 2, all, f1line, "test1", "edtest.c", &data.failed);
91
+
92
+ printf ("%s: backtrace_full alloc stress\n", data.failed ? "FAIL" : "PASS");
93
+
94
+ if (data.failed)
95
+ ++failures;
96
+
97
+ return failures;
98
+ }
99
+
100
+ int
101
+ main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
102
+ {
103
+ state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
104
+ error_callback_create, NULL);
105
+
106
+ // Grab the storage allocation lock prior to doing anything interesting.
107
+ // The intent here is to insure that the backtrace_alloc code is forced
108
+ // to always call mmap() for new memory as opposed to reusing previously
109
+ // allocated memory from the free list. Doing things this way helps
110
+ // simulate what you might see in a multithreaded program in which there
111
+ // are racing calls to the allocator.
112
+ struct backtrace_state *state_internal =
113
+ (struct backtrace_state *) state;
114
+ state_internal->lock_alloc = 1;
115
+
116
+ // Kick off the test
117
+ test1();
118
+
119
+ exit (failures > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
120
+ }
@@ -0,0 +1,43 @@
1
+ /* edtest2.c -- Test for libbacktrace storage allocation stress handling (p2)
2
+ Copyright (C) 2017-2021 Free Software Foundation, Inc.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are
6
+ met:
7
+
8
+ (1) Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ (2) Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in
13
+ the documentation and/or other materials provided with the
14
+ distribution.
15
+
16
+ (3) The name of the author may not be used to
17
+ endorse or promote products derived from this software without
18
+ specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ POSSIBILITY OF SUCH DAMAGE. */
31
+
32
+ /* This file intentionally written without any #include's
33
+ */
34
+
35
+ extern int f3(int, int);
36
+ extern int f2(int);
37
+
38
+ int f2(int x)
39
+ {
40
+ /* Returning a value here and elsewhere avoids a tailcall which
41
+ would mess up the backtrace. */
42
+ return f3(x, __LINE__) + 3;
43
+ }