pf2 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -2
- data/Cargo.lock +650 -0
- data/Cargo.toml +3 -0
- data/README.md +110 -13
- data/Rakefile +8 -0
- data/crates/backtrace-sys2/.gitignore +1 -0
- data/crates/backtrace-sys2/Cargo.toml +9 -0
- data/crates/backtrace-sys2/build.rs +48 -0
- data/crates/backtrace-sys2/src/lib.rs +5 -0
- data/crates/backtrace-sys2/src/libbacktrace/.gitignore +15 -0
- data/crates/backtrace-sys2/src/libbacktrace/Isaac.Newton-Opticks.txt +9286 -0
- data/crates/backtrace-sys2/src/libbacktrace/LICENSE +29 -0
- data/crates/backtrace-sys2/src/libbacktrace/Makefile.am +623 -0
- data/crates/backtrace-sys2/src/libbacktrace/Makefile.in +2666 -0
- data/crates/backtrace-sys2/src/libbacktrace/README.md +36 -0
- data/crates/backtrace-sys2/src/libbacktrace/aclocal.m4 +864 -0
- data/crates/backtrace-sys2/src/libbacktrace/alloc.c +167 -0
- data/crates/backtrace-sys2/src/libbacktrace/allocfail.c +136 -0
- data/crates/backtrace-sys2/src/libbacktrace/allocfail.sh +104 -0
- data/crates/backtrace-sys2/src/libbacktrace/atomic.c +113 -0
- data/crates/backtrace-sys2/src/libbacktrace/backtrace-supported.h.in +66 -0
- data/crates/backtrace-sys2/src/libbacktrace/backtrace.c +129 -0
- data/crates/backtrace-sys2/src/libbacktrace/backtrace.h +189 -0
- data/crates/backtrace-sys2/src/libbacktrace/btest.c +501 -0
- data/crates/backtrace-sys2/src/libbacktrace/compile +348 -0
- data/crates/backtrace-sys2/src/libbacktrace/config/enable.m4 +38 -0
- data/crates/backtrace-sys2/src/libbacktrace/config/lead-dot.m4 +31 -0
- data/crates/backtrace-sys2/src/libbacktrace/config/libtool.m4 +7436 -0
- data/crates/backtrace-sys2/src/libbacktrace/config/ltoptions.m4 +369 -0
- data/crates/backtrace-sys2/src/libbacktrace/config/ltsugar.m4 +123 -0
- data/crates/backtrace-sys2/src/libbacktrace/config/ltversion.m4 +23 -0
- data/crates/backtrace-sys2/src/libbacktrace/config/lt~obsolete.m4 +98 -0
- data/crates/backtrace-sys2/src/libbacktrace/config/multi.m4 +68 -0
- data/crates/backtrace-sys2/src/libbacktrace/config/override.m4 +117 -0
- data/crates/backtrace-sys2/src/libbacktrace/config/unwind_ipinfo.m4 +37 -0
- data/crates/backtrace-sys2/src/libbacktrace/config/warnings.m4 +227 -0
- data/crates/backtrace-sys2/src/libbacktrace/config.guess +1700 -0
- data/crates/backtrace-sys2/src/libbacktrace/config.h.in +182 -0
- data/crates/backtrace-sys2/src/libbacktrace/config.sub +1885 -0
- data/crates/backtrace-sys2/src/libbacktrace/configure +15740 -0
- data/crates/backtrace-sys2/src/libbacktrace/configure.ac +613 -0
- data/crates/backtrace-sys2/src/libbacktrace/dwarf.c +4402 -0
- data/crates/backtrace-sys2/src/libbacktrace/edtest.c +120 -0
- data/crates/backtrace-sys2/src/libbacktrace/edtest2.c +43 -0
- data/crates/backtrace-sys2/src/libbacktrace/elf.c +7443 -0
- data/crates/backtrace-sys2/src/libbacktrace/fileline.c +407 -0
- data/crates/backtrace-sys2/src/libbacktrace/filenames.h +52 -0
- data/crates/backtrace-sys2/src/libbacktrace/filetype.awk +13 -0
- data/crates/backtrace-sys2/src/libbacktrace/install-debuginfo-for-buildid.sh.in +65 -0
- data/crates/backtrace-sys2/src/libbacktrace/install-sh +501 -0
- data/crates/backtrace-sys2/src/libbacktrace/instrumented_alloc.c +114 -0
- data/crates/backtrace-sys2/src/libbacktrace/internal.h +389 -0
- data/crates/backtrace-sys2/src/libbacktrace/libtool.m4 +7436 -0
- data/crates/backtrace-sys2/src/libbacktrace/ltmain.sh +8636 -0
- data/crates/backtrace-sys2/src/libbacktrace/ltoptions.m4 +369 -0
- data/crates/backtrace-sys2/src/libbacktrace/ltsugar.m4 +123 -0
- data/crates/backtrace-sys2/src/libbacktrace/ltversion.m4 +23 -0
- data/crates/backtrace-sys2/src/libbacktrace/lt~obsolete.m4 +98 -0
- data/crates/backtrace-sys2/src/libbacktrace/macho.c +1355 -0
- data/crates/backtrace-sys2/src/libbacktrace/missing +215 -0
- data/crates/backtrace-sys2/src/libbacktrace/mmap.c +331 -0
- data/crates/backtrace-sys2/src/libbacktrace/mmapio.c +110 -0
- data/crates/backtrace-sys2/src/libbacktrace/move-if-change +83 -0
- data/crates/backtrace-sys2/src/libbacktrace/mtest.c +410 -0
- data/crates/backtrace-sys2/src/libbacktrace/nounwind.c +66 -0
- data/crates/backtrace-sys2/src/libbacktrace/pecoff.c +957 -0
- data/crates/backtrace-sys2/src/libbacktrace/posix.c +104 -0
- data/crates/backtrace-sys2/src/libbacktrace/print.c +92 -0
- data/crates/backtrace-sys2/src/libbacktrace/read.c +110 -0
- data/crates/backtrace-sys2/src/libbacktrace/simple.c +108 -0
- data/crates/backtrace-sys2/src/libbacktrace/sort.c +108 -0
- data/crates/backtrace-sys2/src/libbacktrace/state.c +72 -0
- data/crates/backtrace-sys2/src/libbacktrace/stest.c +137 -0
- data/crates/backtrace-sys2/src/libbacktrace/test-driver +148 -0
- data/crates/backtrace-sys2/src/libbacktrace/test_format.c +55 -0
- data/crates/backtrace-sys2/src/libbacktrace/testlib.c +234 -0
- data/crates/backtrace-sys2/src/libbacktrace/testlib.h +110 -0
- data/crates/backtrace-sys2/src/libbacktrace/ttest.c +161 -0
- data/crates/backtrace-sys2/src/libbacktrace/unittest.c +92 -0
- data/crates/backtrace-sys2/src/libbacktrace/unknown.c +65 -0
- data/crates/backtrace-sys2/src/libbacktrace/xcoff.c +1606 -0
- data/crates/backtrace-sys2/src/libbacktrace/xztest.c +508 -0
- data/crates/backtrace-sys2/src/libbacktrace/zstdtest.c +523 -0
- data/crates/backtrace-sys2/src/libbacktrace/ztest.c +541 -0
- data/ext/pf2/Cargo.toml +25 -0
- data/ext/pf2/build.rs +3 -0
- data/ext/pf2/extconf.rb +6 -1
- data/ext/pf2/src/backtrace.rs +126 -0
- data/ext/pf2/src/lib.rs +15 -0
- data/ext/pf2/src/profile.rs +65 -0
- data/ext/pf2/src/profile_serializer.rs +204 -0
- data/ext/pf2/src/ringbuffer.rs +152 -0
- data/ext/pf2/src/ruby_init.rs +74 -0
- data/ext/pf2/src/sample.rs +66 -0
- data/ext/pf2/src/siginfo_t.c +5 -0
- data/ext/pf2/src/signal_scheduler/configuration.rs +31 -0
- data/ext/pf2/src/signal_scheduler/timer_installer.rs +199 -0
- data/ext/pf2/src/signal_scheduler.rs +311 -0
- data/ext/pf2/src/timer_thread_scheduler.rs +319 -0
- data/ext/pf2/src/util.rs +30 -0
- data/lib/pf2/cli.rb +1 -1
- data/lib/pf2/reporter.rb +48 -16
- data/lib/pf2/version.rb +1 -1
- data/lib/pf2.rb +20 -5
- metadata +128 -5
- 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
|
+
}
|