]>
Commit | Line | Data |
---|---|---|
63a4b106 AB |
1 | /* testlib.h -- Header for test functions for libbacktrace 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 | #ifndef LIBBACKTRACE_TESTLIB_H | |
34 | #define LIBBACKTRACE_TESTLIB_H | |
35 | ||
36 | /* Portable attribute syntax. Actually some of these tests probably | |
37 | won't work if the attributes are not recognized. */ | |
38 | ||
39 | #ifndef GCC_VERSION | |
40 | # define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) | |
41 | #endif | |
42 | ||
43 | #if (GCC_VERSION < 2007) | |
44 | # define __attribute__(x) | |
45 | #endif | |
46 | ||
47 | #ifndef ATTRIBUTE_UNUSED | |
48 | # define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) | |
49 | #endif | |
50 | ||
51 | /* Used to collect backtrace info. */ | |
52 | ||
53 | struct info | |
54 | { | |
55 | char *filename; | |
56 | int lineno; | |
57 | char *function; | |
58 | }; | |
59 | ||
60 | /* Passed to backtrace callback function. */ | |
61 | ||
62 | struct bdata | |
63 | { | |
64 | struct info *all; | |
65 | size_t index; | |
66 | size_t max; | |
67 | int failed; | |
68 | }; | |
69 | ||
70 | /* Passed to backtrace_simple callback function. */ | |
71 | ||
72 | struct sdata | |
73 | { | |
74 | uintptr_t *addrs; | |
75 | size_t index; | |
76 | size_t max; | |
77 | int failed; | |
78 | }; | |
79 | ||
80 | /* Passed to backtrace_syminfo callback function. */ | |
81 | ||
82 | struct symdata | |
83 | { | |
84 | const char *name; | |
85 | uintptr_t val, size; | |
86 | int failed; | |
87 | }; | |
88 | ||
89 | /* The backtrace state. */ | |
90 | ||
91 | extern void *state; | |
92 | ||
93 | /* The number of failures. */ | |
94 | ||
95 | extern int failures; | |
96 | ||
97 | extern const char *base (const char *p); | |
98 | extern void check (const char *name, int index, const struct info *all, | |
99 | int want_lineno, const char *want_function, | |
100 | const char *want_file, int *failed); | |
101 | extern int callback_one (void *, uintptr_t, const char *, int, const char *); | |
102 | extern void error_callback_one (void *, const char *, int); | |
103 | extern int callback_two (void *, uintptr_t); | |
104 | extern void error_callback_two (void *, const char *, int); | |
105 | extern void callback_three (void *, uintptr_t, const char *, uintptr_t, | |
106 | uintptr_t); | |
107 | extern void error_callback_three (void *, const char *, int); | |
108 | extern void error_callback_create (void *, const char *, int); | |
109 | ||
110 | #endif /* !defined(LIBBACKTRACE_TESTLIB_H) */ |