annotate libbacktrace/testlib.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* testlib.h -- Header for test functions for libbacktrace library
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3 Written by Ian Lance Taylor, Google.
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 Redistribution and use in source and binary forms, with or without
kono
parents:
diff changeset
6 modification, are permitted provided that the following conditions are
kono
parents:
diff changeset
7 met:
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 (1) Redistributions of source code must retain the above copyright
kono
parents:
diff changeset
10 notice, this list of conditions and the following disclaimer.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 (2) Redistributions in binary form must reproduce the above copyright
kono
parents:
diff changeset
13 notice, this list of conditions and the following disclaimer in
kono
parents:
diff changeset
14 the documentation and/or other materials provided with the
kono
parents:
diff changeset
15 distribution.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 (3) The name of the author may not be used to
kono
parents:
diff changeset
18 endorse or promote products derived from this software without
kono
parents:
diff changeset
19 specific prior written permission.
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
kono
parents:
diff changeset
22 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
kono
parents:
diff changeset
23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
kono
parents:
diff changeset
24 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
kono
parents:
diff changeset
25 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
kono
parents:
diff changeset
26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
kono
parents:
diff changeset
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
kono
parents:
diff changeset
28 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
kono
parents:
diff changeset
29 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
kono
parents:
diff changeset
30 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
kono
parents:
diff changeset
31 POSSIBILITY OF SUCH DAMAGE. */
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 #ifndef LIBBACKTRACE_TESTLIB_H
kono
parents:
diff changeset
34 #define LIBBACKTRACE_TESTLIB_H
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 /* Portable attribute syntax. Actually some of these tests probably
kono
parents:
diff changeset
37 won't work if the attributes are not recognized. */
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 #ifndef GCC_VERSION
kono
parents:
diff changeset
40 # define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
kono
parents:
diff changeset
41 #endif
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 #if (GCC_VERSION < 2007)
kono
parents:
diff changeset
44 # define __attribute__(x)
kono
parents:
diff changeset
45 #endif
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 #ifndef ATTRIBUTE_UNUSED
kono
parents:
diff changeset
48 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
kono
parents:
diff changeset
49 #endif
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 /* Used to collect backtrace info. */
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 struct info
kono
parents:
diff changeset
54 {
kono
parents:
diff changeset
55 char *filename;
kono
parents:
diff changeset
56 int lineno;
kono
parents:
diff changeset
57 char *function;
kono
parents:
diff changeset
58 };
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 /* Passed to backtrace callback function. */
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 struct bdata
kono
parents:
diff changeset
63 {
kono
parents:
diff changeset
64 struct info *all;
kono
parents:
diff changeset
65 size_t index;
kono
parents:
diff changeset
66 size_t max;
kono
parents:
diff changeset
67 int failed;
kono
parents:
diff changeset
68 };
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 /* Passed to backtrace_simple callback function. */
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 struct sdata
kono
parents:
diff changeset
73 {
kono
parents:
diff changeset
74 uintptr_t *addrs;
kono
parents:
diff changeset
75 size_t index;
kono
parents:
diff changeset
76 size_t max;
kono
parents:
diff changeset
77 int failed;
kono
parents:
diff changeset
78 };
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 /* Passed to backtrace_syminfo callback function. */
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 struct symdata
kono
parents:
diff changeset
83 {
kono
parents:
diff changeset
84 const char *name;
kono
parents:
diff changeset
85 uintptr_t val, size;
kono
parents:
diff changeset
86 int failed;
kono
parents:
diff changeset
87 };
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 /* The backtrace state. */
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 extern void *state;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 /* The number of failures. */
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 extern int failures;
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 extern const char *base (const char *p);
kono
parents:
diff changeset
98 extern void check (const char *name, int index, const struct info *all,
kono
parents:
diff changeset
99 int want_lineno, const char *want_function,
kono
parents:
diff changeset
100 const char *want_file, int *failed);
kono
parents:
diff changeset
101 extern int callback_one (void *, uintptr_t, const char *, int, const char *);
kono
parents:
diff changeset
102 extern void error_callback_one (void *, const char *, int);
kono
parents:
diff changeset
103 extern int callback_two (void *, uintptr_t);
kono
parents:
diff changeset
104 extern void error_callback_two (void *, const char *, int);
kono
parents:
diff changeset
105 extern void callback_three (void *, uintptr_t, const char *, uintptr_t,
kono
parents:
diff changeset
106 uintptr_t);
kono
parents:
diff changeset
107 extern void error_callback_three (void *, const char *, int);
kono
parents:
diff changeset
108 extern void error_callback_create (void *, const char *, int);
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 #endif /* !defined(LIBBACKTRACE_TESTLIB_H) */