pf2 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -2
  3. data/Cargo.lock +650 -0
  4. data/Cargo.toml +3 -0
  5. data/README.md +110 -13
  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 +25 -0
  87. data/ext/pf2/build.rs +3 -0
  88. data/ext/pf2/extconf.rb +6 -1
  89. data/ext/pf2/src/backtrace.rs +126 -0
  90. data/ext/pf2/src/lib.rs +15 -0
  91. data/ext/pf2/src/profile.rs +65 -0
  92. data/ext/pf2/src/profile_serializer.rs +204 -0
  93. data/ext/pf2/src/ringbuffer.rs +152 -0
  94. data/ext/pf2/src/ruby_init.rs +74 -0
  95. data/ext/pf2/src/sample.rs +66 -0
  96. data/ext/pf2/src/siginfo_t.c +5 -0
  97. data/ext/pf2/src/signal_scheduler/configuration.rs +31 -0
  98. data/ext/pf2/src/signal_scheduler/timer_installer.rs +199 -0
  99. data/ext/pf2/src/signal_scheduler.rs +311 -0
  100. data/ext/pf2/src/timer_thread_scheduler.rs +319 -0
  101. data/ext/pf2/src/util.rs +30 -0
  102. data/lib/pf2/cli.rb +1 -1
  103. data/lib/pf2/reporter.rb +48 -16
  104. data/lib/pf2/version.rb +1 -1
  105. data/lib/pf2.rb +20 -5
  106. metadata +128 -5
  107. data/ext/pf2/pf2.c +0 -246
@@ -0,0 +1,83 @@
1
+ #!/bin/sh
2
+ # Like mv $1 $2, but if the files are the same, just delete $1.
3
+ # Status is zero if successful, nonzero otherwise.
4
+
5
+ VERSION='2012-01-06 07:23'; # UTC
6
+ # The definition above must lie within the first 8 lines in order
7
+ # for the Emacs time-stamp write hook (at end) to update it.
8
+ # If you change this file with Emacs, please let the write hook
9
+ # do its job. Otherwise, update this string manually.
10
+
11
+ # Copyright (C) 2002-2014 Free Software Foundation, Inc.
12
+
13
+ # This program is free software: you can redistribute it and/or modify
14
+ # it under the terms of the GNU General Public License as published by
15
+ # the Free Software Foundation, either version 3 of the License, or
16
+ # (at your option) any later version.
17
+
18
+ # This program is distributed in the hope that it will be useful,
19
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ # GNU General Public License for more details.
22
+
23
+ # You should have received a copy of the GNU General Public License
24
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
25
+
26
+ usage="usage: $0 SOURCE DEST"
27
+
28
+ help="$usage
29
+ or: $0 OPTION
30
+ If SOURCE is different than DEST, then move it to DEST; else remove SOURCE.
31
+
32
+ --help display this help and exit
33
+ --version output version information and exit
34
+
35
+ The variable CMPPROG can be used to specify an alternative to 'cmp'.
36
+
37
+ Report bugs to <bug-gnulib@gnu.org>."
38
+
39
+ version=`expr "$VERSION" : '\([^ ]*\)'`
40
+ version="move-if-change (gnulib) $version
41
+ Copyright (C) 2011 Free Software Foundation, Inc.
42
+ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
43
+ This is free software: you are free to change and redistribute it.
44
+ There is NO WARRANTY, to the extent permitted by law."
45
+
46
+ cmpprog=${CMPPROG-cmp}
47
+
48
+ for arg
49
+ do
50
+ case $arg in
51
+ --help | --hel | --he | --h)
52
+ exec echo "$help" ;;
53
+ --version | --versio | --versi | --vers | --ver | --ve | --v)
54
+ exec echo "$version" ;;
55
+ --)
56
+ shift
57
+ break ;;
58
+ -*)
59
+ echo "$0: invalid option: $arg" >&2
60
+ exit 1 ;;
61
+ *)
62
+ break ;;
63
+ esac
64
+ done
65
+
66
+ test $# -eq 2 || { echo "$0: $usage" >&2; exit 1; }
67
+
68
+ if test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then
69
+ rm -f -- "$1"
70
+ else
71
+ if mv -f -- "$1" "$2"; then :; else
72
+ # Ignore failure due to a concurrent move-if-change.
73
+ test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1"
74
+ fi
75
+ fi
76
+
77
+ ## Local Variables:
78
+ ## eval: (add-hook 'write-file-hooks 'time-stamp)
79
+ ## time-stamp-start: "VERSION='"
80
+ ## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
81
+ ## time-stamp-time-zone: "UTC"
82
+ ## time-stamp-end: "'; # UTC"
83
+ ## End:
@@ -0,0 +1,410 @@
1
+ /* mtest.c -- Minidebug test for libbacktrace library
2
+ Copyright (C) 2020-2021 Free Software Foundation, Inc.
3
+ Written by Ian Lance Taylor, Google.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are
7
+ met:
8
+
9
+ (1) Redistributions of source code must retain the above copyright
10
+ notice, this list of conditions and the following disclaimer.
11
+
12
+ (2) Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in
14
+ the documentation and/or other materials provided with the
15
+ distribution.
16
+
17
+ (3) The name of the author may not be used to
18
+ endorse or promote products derived from this software without
19
+ specific prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
25
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
+ POSSIBILITY OF SUCH DAMAGE. */
32
+
33
+ /* This program tests using libbacktrace with a program that uses the
34
+ minidebuginfo format in a .gnu_debugdata section. See
35
+ https://sourceware.org/gdb/current/onlinedocs/gdb/MiniDebugInfo.html
36
+ for a bit more information about minidebuginfo. What is relevant
37
+ for libbacktrace is that we have just a symbol table, with no debug
38
+ info, so we should be able to do a function backtrace, but we can't
39
+ do a file/line backtrace. */
40
+
41
+ #include <assert.h>
42
+ #include <stdlib.h>
43
+ #include <string.h>
44
+
45
+ #include "backtrace.h"
46
+ #include "backtrace-supported.h"
47
+
48
+ #include "testlib.h"
49
+
50
+ static int test1 (void) __attribute__ ((noinline, noclone, unused));
51
+ static int f2 (int) __attribute__ ((noinline, noclone));
52
+ static int f3 (int, int) __attribute__ ((noinline, noclone));
53
+
54
+ /* Collected PC values. */
55
+
56
+ static uintptr_t addrs[20];
57
+
58
+ /* The backtrace callback function. This is like callback_one in
59
+ testlib.c, but it saves the PC also. */
60
+
61
+ static int
62
+ callback_mtest (void *vdata, uintptr_t pc, const char *filename, int lineno,
63
+ const char *function)
64
+ {
65
+ struct bdata *data = (struct bdata *) vdata;
66
+
67
+ if (data->index >= sizeof addrs / sizeof addrs[0])
68
+ {
69
+ fprintf (stderr, "callback_mtest: callback called too many times\n");
70
+ data->failed = 1;
71
+ return 1;
72
+ }
73
+
74
+ addrs[data->index] = pc;
75
+
76
+ return callback_one (vdata, pc, filename, lineno, function);
77
+ }
78
+
79
+ /* Test the backtrace function with non-inlined functions. (We don't
80
+ test with inlined functions because they won't work with minidebug
81
+ anyhow.) */
82
+
83
+ static int
84
+ test1 (void)
85
+ {
86
+ /* Returning a value here and elsewhere avoids a tailcall which
87
+ would mess up the backtrace. */
88
+ return f2 (__LINE__) + 1;
89
+ }
90
+
91
+ static int
92
+ f2 (int f1line)
93
+ {
94
+ return f3 (f1line, __LINE__) + 2;
95
+ }
96
+
97
+ static int
98
+ f3 (int f1line __attribute__ ((unused)), int f2line __attribute__ ((unused)))
99
+ {
100
+ struct info all[20];
101
+ struct bdata data;
102
+ int i;
103
+ size_t j;
104
+
105
+ data.all = &all[0];
106
+ data.index = 0;
107
+ data.max = 20;
108
+ data.failed = 0;
109
+
110
+ i = backtrace_full (state, 0, callback_mtest, error_callback_one, &data);
111
+
112
+ if (i != 0)
113
+ {
114
+ fprintf (stderr, "test1: unexpected return value %d\n", i);
115
+ data.failed = 1;
116
+ }
117
+
118
+ if (data.index < 3)
119
+ {
120
+ fprintf (stderr,
121
+ "test1: not enough frames; got %zu, expected at least 3\n",
122
+ data.index);
123
+ data.failed = 1;
124
+ }
125
+
126
+ /* When using minidebug we don't expect the function name here. */
127
+
128
+ for (j = 0; j < 3 && j < data.index; j++)
129
+ {
130
+ if (all[j].function == NULL)
131
+ {
132
+ struct symdata symdata;
133
+
134
+ symdata.name = NULL;
135
+ symdata.val = 0;
136
+ symdata.size = 0;
137
+ symdata.failed = 0;
138
+
139
+ i = backtrace_syminfo (state, addrs[j], callback_three,
140
+ error_callback_three, &symdata);
141
+ if (i == 0)
142
+ {
143
+ fprintf (stderr,
144
+ ("test1: [%zu], unexpected return value from "
145
+ "backtrace_syminfo %d\n"),
146
+ j, i);
147
+ data.failed = 1;
148
+ }
149
+ else if (symdata.name == NULL)
150
+ {
151
+ fprintf (stderr, "test1: [%zu]: syminfo did not find name\n", j);
152
+ data.failed = 1;
153
+ }
154
+ else
155
+ all[j].function = strdup (symdata.name);
156
+ }
157
+ }
158
+
159
+ if (data.index > 0)
160
+ {
161
+ if (all[0].function == NULL)
162
+ {
163
+ fprintf (stderr, "test1: [0]: missing function name\n");
164
+ data.failed = 1;
165
+ }
166
+ else if (strcmp (all[0].function, "f3") != 0)
167
+ {
168
+ fprintf (stderr, "test1: [0]: got %s expected %s\n",
169
+ all[0].function, "f3");
170
+ data.failed = 1;
171
+ }
172
+ }
173
+
174
+ if (data.index > 1)
175
+ {
176
+ if (all[1].function == NULL)
177
+ {
178
+ fprintf (stderr, "test1: [1]: missing function name\n");
179
+ data.failed = 1;
180
+ }
181
+ else if (strcmp (all[1].function, "f2") != 0)
182
+ {
183
+ fprintf (stderr, "test1: [1]: got %s expected %s\n",
184
+ all[0].function, "f2");
185
+ data.failed = 1;
186
+ }
187
+ }
188
+
189
+ if (data.index > 2)
190
+ {
191
+ if (all[2].function == NULL)
192
+ {
193
+ fprintf (stderr, "test1: [2]: missing function name\n");
194
+ data.failed = 1;
195
+ }
196
+ else if (strcmp (all[2].function, "test1") != 0)
197
+ {
198
+ fprintf (stderr, "test1: [2]: got %s expected %s\n",
199
+ all[0].function, "test1");
200
+ data.failed = 1;
201
+ }
202
+ }
203
+
204
+ printf ("%s: backtrace_full noinline\n", data.failed ? "FAIL" : "PASS");
205
+
206
+ if (data.failed)
207
+ ++failures;
208
+
209
+ return failures;
210
+ }
211
+
212
+ /* Test the backtrace_simple function with non-inlined functions. */
213
+
214
+ static int test3 (void) __attribute__ ((noinline, noclone, unused));
215
+ static int f22 (int) __attribute__ ((noinline, noclone));
216
+ static int f23 (int, int) __attribute__ ((noinline, noclone));
217
+
218
+ static int
219
+ test3 (void)
220
+ {
221
+ return f22 (__LINE__) + 1;
222
+ }
223
+
224
+ static int
225
+ f22 (int f1line)
226
+ {
227
+ return f23 (f1line, __LINE__) + 2;
228
+ }
229
+
230
+ static int
231
+ f23 (int f1line __attribute__ ((unused)), int f2line __attribute__ ((unused)))
232
+ {
233
+ uintptr_t addrs[20];
234
+ struct sdata data;
235
+ int i;
236
+
237
+ data.addrs = &addrs[0];
238
+ data.index = 0;
239
+ data.max = 20;
240
+ data.failed = 0;
241
+
242
+ i = backtrace_simple (state, 0, callback_two, error_callback_two, &data);
243
+
244
+ if (i != 0)
245
+ {
246
+ fprintf (stderr, "test3: unexpected return value %d\n", i);
247
+ data.failed = 1;
248
+ }
249
+
250
+ if (!data.failed)
251
+ {
252
+ int j;
253
+
254
+ for (j = 0; j < 3; ++j)
255
+ {
256
+ struct symdata symdata;
257
+
258
+ symdata.name = NULL;
259
+ symdata.val = 0;
260
+ symdata.size = 0;
261
+ symdata.failed = 0;
262
+
263
+ i = backtrace_syminfo (state, addrs[j], callback_three,
264
+ error_callback_three, &symdata);
265
+ if (i == 0)
266
+ {
267
+ fprintf (stderr,
268
+ ("test3: [%d]: unexpected return value "
269
+ "from backtrace_syminfo %d\n"),
270
+ j, i);
271
+ symdata.failed = 1;
272
+ }
273
+
274
+ if (!symdata.failed)
275
+ {
276
+ const char *expected;
277
+
278
+ switch (j)
279
+ {
280
+ case 0:
281
+ expected = "f23";
282
+ break;
283
+ case 1:
284
+ expected = "f22";
285
+ break;
286
+ case 2:
287
+ expected = "test3";
288
+ break;
289
+ default:
290
+ assert (0);
291
+ }
292
+
293
+ if (symdata.name == NULL)
294
+ {
295
+ fprintf (stderr, "test3: [%d]: NULL syminfo name\n", j);
296
+ symdata.failed = 1;
297
+ }
298
+ /* Use strncmp, not strcmp, because GCC might create a
299
+ clone. */
300
+ else if (strncmp (symdata.name, expected, strlen (expected))
301
+ != 0)
302
+ {
303
+ fprintf (stderr,
304
+ ("test3: [%d]: unexpected syminfo name "
305
+ "got %s expected %s\n"),
306
+ j, symdata.name, expected);
307
+ symdata.failed = 1;
308
+ }
309
+ }
310
+
311
+ if (symdata.failed)
312
+ data.failed = 1;
313
+ }
314
+ }
315
+
316
+ printf ("%s: backtrace_simple noinline\n", data.failed ? "FAIL" : "PASS");
317
+
318
+ if (data.failed)
319
+ ++failures;
320
+
321
+ return failures;
322
+ }
323
+
324
+ int test5 (void) __attribute__ ((unused));
325
+
326
+ int global = 1;
327
+
328
+ int
329
+ test5 (void)
330
+ {
331
+ struct symdata symdata;
332
+ int i;
333
+ uintptr_t addr = (uintptr_t) &global;
334
+
335
+ if (sizeof (global) > 1)
336
+ addr += 1;
337
+
338
+ symdata.name = NULL;
339
+ symdata.val = 0;
340
+ symdata.size = 0;
341
+ symdata.failed = 0;
342
+
343
+ i = backtrace_syminfo (state, addr, callback_three,
344
+ error_callback_three, &symdata);
345
+ if (i == 0)
346
+ {
347
+ fprintf (stderr,
348
+ "test5: unexpected return value from backtrace_syminfo %d\n",
349
+ i);
350
+ symdata.failed = 1;
351
+ }
352
+
353
+ if (!symdata.failed)
354
+ {
355
+ if (symdata.name == NULL)
356
+ {
357
+ fprintf (stderr, "test5: NULL syminfo name\n");
358
+ symdata.failed = 1;
359
+ }
360
+ else if (!(strncmp (symdata.name, "global", 6) == 0
361
+ && (symdata.name[6] == '\0'|| symdata.name[6] == '.')))
362
+ {
363
+ fprintf (stderr,
364
+ "test5: unexpected syminfo name got %s expected %s\n",
365
+ symdata.name, "global");
366
+ symdata.failed = 1;
367
+ }
368
+ else if (symdata.val != (uintptr_t) &global)
369
+ {
370
+ fprintf (stderr,
371
+ "test5: unexpected syminfo value got %lx expected %lx\n",
372
+ (unsigned long) symdata.val,
373
+ (unsigned long) (uintptr_t) &global);
374
+ symdata.failed = 1;
375
+ }
376
+ else if (symdata.size != sizeof (global))
377
+ {
378
+ fprintf (stderr,
379
+ "test5: unexpected syminfo size got %lx expected %lx\n",
380
+ (unsigned long) symdata.size,
381
+ (unsigned long) sizeof (global));
382
+ symdata.failed = 1;
383
+ }
384
+ }
385
+
386
+ printf ("%s: backtrace_syminfo variable\n",
387
+ symdata.failed ? "FAIL" : "PASS");
388
+
389
+ if (symdata.failed)
390
+ ++failures;
391
+
392
+ return failures;
393
+ }
394
+
395
+ int
396
+ main (int argc ATTRIBUTE_UNUSED, char **argv)
397
+ {
398
+ state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
399
+ error_callback_create, NULL);
400
+
401
+ #if BACKTRACE_SUPPORTED
402
+ test1 ();
403
+ test3 ();
404
+ #if BACKTRACE_SUPPORTS_DATA
405
+ test5 ();
406
+ #endif
407
+ #endif
408
+
409
+ exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
410
+ }
@@ -0,0 +1,66 @@
1
+ /* backtrace.c -- Entry point for stack backtrace library.
2
+ Copyright (C) 2012-2021 Free Software Foundation, Inc.
3
+ Written by Ian Lance Taylor, Google.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are
7
+ met:
8
+
9
+ (1) Redistributions of source code must retain the above copyright
10
+ notice, this list of conditions and the following disclaimer.
11
+
12
+ (2) Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in
14
+ the documentation and/or other materials provided with the
15
+ distribution.
16
+
17
+ (3) The name of the author may not be used to
18
+ endorse or promote products derived from this software without
19
+ specific prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
25
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
+ POSSIBILITY OF SUCH DAMAGE. */
32
+
33
+ #include "config.h"
34
+
35
+ #include <sys/types.h>
36
+
37
+ #include "backtrace.h"
38
+
39
+ #include "internal.h"
40
+
41
+ /* This source file is compiled if the unwind library is not
42
+ available. */
43
+
44
+ int
45
+ backtrace_full (struct backtrace_state *state ATTRIBUTE_UNUSED,
46
+ int skip ATTRIBUTE_UNUSED,
47
+ backtrace_full_callback callback ATTRIBUTE_UNUSED,
48
+ backtrace_error_callback error_callback, void *data)
49
+ {
50
+ error_callback (data,
51
+ "no stack trace because unwind library not available",
52
+ 0);
53
+ return 0;
54
+ }
55
+
56
+ int
57
+ backtrace_simple (struct backtrace_state *state ATTRIBUTE_UNUSED,
58
+ int skip ATTRIBUTE_UNUSED,
59
+ backtrace_simple_callback callback ATTRIBUTE_UNUSED,
60
+ backtrace_error_callback error_callback, void *data)
61
+ {
62
+ error_callback (data,
63
+ "no stack trace because unwind library not available",
64
+ 0);
65
+ return 0;
66
+ }