annotate libbacktrace/backtrace.h @ 120:f93fa5091070

fix conv1.c
author mir3636
date Thu, 08 Mar 2018 14:53:42 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* backtrace.h -- Public header file for stack backtrace library.
kono
parents:
diff changeset
2 Copyright (C) 2012-2017 Free Software Foundation, Inc.
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 BACKTRACE_H
kono
parents:
diff changeset
34 #define BACKTRACE_H
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 #include <stddef.h>
kono
parents:
diff changeset
37 #include <stdio.h>
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 /* We want to get a definition for uintptr_t, but we still care about
kono
parents:
diff changeset
40 systems that don't have <stdint.h>. */
kono
parents:
diff changeset
41 #if defined(__GLIBC__) && __GLIBC__ >= 2
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 #include <stdint.h>
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 #elif defined(HAVE_STDINT_H)
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 #include <stdint.h>
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 #else
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 /* Systems that don't have <stdint.h> must provide gstdint.h, e.g.,
kono
parents:
diff changeset
52 from GCC_HEADER_STDINT in configure.ac. */
kono
parents:
diff changeset
53 #include "gstdint.h"
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 #endif
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 #ifdef __cplusplus
kono
parents:
diff changeset
58 extern "C" {
kono
parents:
diff changeset
59 #endif
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 /* The backtrace state. This struct is intentionally not defined in
kono
parents:
diff changeset
62 the public interface. */
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 struct backtrace_state;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 /* The type of the error callback argument to backtrace functions.
kono
parents:
diff changeset
67 This function, if not NULL, will be called for certain error cases.
kono
parents:
diff changeset
68 The DATA argument is passed to the function that calls this one.
kono
parents:
diff changeset
69 The MSG argument is an error message. The ERRNUM argument, if
kono
parents:
diff changeset
70 greater than 0, holds an errno value. The MSG buffer may become
kono
parents:
diff changeset
71 invalid after this function returns.
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 As a special case, the ERRNUM argument will be passed as -1 if no
kono
parents:
diff changeset
74 debug info can be found for the executable, but the function
kono
parents:
diff changeset
75 requires debug info (e.g., backtrace_full, backtrace_pcinfo). The
kono
parents:
diff changeset
76 MSG in this case will be something along the lines of "no debug
kono
parents:
diff changeset
77 info". Similarly, ERRNUM will be passed as -1 if there is no
kono
parents:
diff changeset
78 symbol table, but the function requires a symbol table (e.g.,
kono
parents:
diff changeset
79 backtrace_syminfo). This may be used as a signal that some other
kono
parents:
diff changeset
80 approach should be tried. */
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 typedef void (*backtrace_error_callback) (void *data, const char *msg,
kono
parents:
diff changeset
83 int errnum);
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 /* Create state information for the backtrace routines. This must be
kono
parents:
diff changeset
86 called before any of the other routines, and its return value must
kono
parents:
diff changeset
87 be passed to all of the other routines. FILENAME is the path name
kono
parents:
diff changeset
88 of the executable file; if it is NULL the library will try
kono
parents:
diff changeset
89 system-specific path names. If not NULL, FILENAME must point to a
kono
parents:
diff changeset
90 permanent buffer. If THREADED is non-zero the state may be
kono
parents:
diff changeset
91 accessed by multiple threads simultaneously, and the library will
kono
parents:
diff changeset
92 use appropriate atomic operations. If THREADED is zero the state
kono
parents:
diff changeset
93 may only be accessed by one thread at a time. This returns a state
kono
parents:
diff changeset
94 pointer on success, NULL on error. If an error occurs, this will
kono
parents:
diff changeset
95 call the ERROR_CALLBACK routine. */
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 extern struct backtrace_state *backtrace_create_state (
kono
parents:
diff changeset
98 const char *filename, int threaded,
kono
parents:
diff changeset
99 backtrace_error_callback error_callback, void *data);
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 /* The type of the callback argument to the backtrace_full function.
kono
parents:
diff changeset
102 DATA is the argument passed to backtrace_full. PC is the program
kono
parents:
diff changeset
103 counter. FILENAME is the name of the file containing PC, or NULL
kono
parents:
diff changeset
104 if not available. LINENO is the line number in FILENAME containing
kono
parents:
diff changeset
105 PC, or 0 if not available. FUNCTION is the name of the function
kono
parents:
diff changeset
106 containing PC, or NULL if not available. This should return 0 to
kono
parents:
diff changeset
107 continuing tracing. The FILENAME and FUNCTION buffers may become
kono
parents:
diff changeset
108 invalid after this function returns. */
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 typedef int (*backtrace_full_callback) (void *data, uintptr_t pc,
kono
parents:
diff changeset
111 const char *filename, int lineno,
kono
parents:
diff changeset
112 const char *function);
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 /* Get a full stack backtrace. SKIP is the number of frames to skip;
kono
parents:
diff changeset
115 passing 0 will start the trace with the function calling
kono
parents:
diff changeset
116 backtrace_full. DATA is passed to the callback routine. If any
kono
parents:
diff changeset
117 call to CALLBACK returns a non-zero value, the stack backtrace
kono
parents:
diff changeset
118 stops, and backtrace returns that value; this may be used to limit
kono
parents:
diff changeset
119 the number of stack frames desired. If all calls to CALLBACK
kono
parents:
diff changeset
120 return 0, backtrace returns 0. The backtrace_full function will
kono
parents:
diff changeset
121 make at least one call to either CALLBACK or ERROR_CALLBACK. This
kono
parents:
diff changeset
122 function requires debug info for the executable. */
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 extern int backtrace_full (struct backtrace_state *state, int skip,
kono
parents:
diff changeset
125 backtrace_full_callback callback,
kono
parents:
diff changeset
126 backtrace_error_callback error_callback,
kono
parents:
diff changeset
127 void *data);
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 /* The type of the callback argument to the backtrace_simple function.
kono
parents:
diff changeset
130 DATA is the argument passed to simple_backtrace. PC is the program
kono
parents:
diff changeset
131 counter. This should return 0 to continue tracing. */
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 typedef int (*backtrace_simple_callback) (void *data, uintptr_t pc);
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 /* Get a simple backtrace. SKIP is the number of frames to skip, as
kono
parents:
diff changeset
136 in backtrace. DATA is passed to the callback routine. If any call
kono
parents:
diff changeset
137 to CALLBACK returns a non-zero value, the stack backtrace stops,
kono
parents:
diff changeset
138 and backtrace_simple returns that value. Otherwise
kono
parents:
diff changeset
139 backtrace_simple returns 0. The backtrace_simple function will
kono
parents:
diff changeset
140 make at least one call to either CALLBACK or ERROR_CALLBACK. This
kono
parents:
diff changeset
141 function does not require any debug info for the executable. */
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 extern int backtrace_simple (struct backtrace_state *state, int skip,
kono
parents:
diff changeset
144 backtrace_simple_callback callback,
kono
parents:
diff changeset
145 backtrace_error_callback error_callback,
kono
parents:
diff changeset
146 void *data);
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 /* Print the current backtrace in a user readable format to a FILE.
kono
parents:
diff changeset
149 SKIP is the number of frames to skip, as in backtrace_full. Any
kono
parents:
diff changeset
150 error messages are printed to stderr. This function requires debug
kono
parents:
diff changeset
151 info for the executable. */
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 extern void backtrace_print (struct backtrace_state *state, int skip, FILE *);
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 /* Given PC, a program counter in the current program, call the
kono
parents:
diff changeset
156 callback function with filename, line number, and function name
kono
parents:
diff changeset
157 information. This will normally call the callback function exactly
kono
parents:
diff changeset
158 once. However, if the PC happens to describe an inlined call, and
kono
parents:
diff changeset
159 the debugging information contains the necessary information, then
kono
parents:
diff changeset
160 this may call the callback function multiple times. This will make
kono
parents:
diff changeset
161 at least one call to either CALLBACK or ERROR_CALLBACK. This
kono
parents:
diff changeset
162 returns the first non-zero value returned by CALLBACK, or 0. */
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 extern int backtrace_pcinfo (struct backtrace_state *state, uintptr_t pc,
kono
parents:
diff changeset
165 backtrace_full_callback callback,
kono
parents:
diff changeset
166 backtrace_error_callback error_callback,
kono
parents:
diff changeset
167 void *data);
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 /* The type of the callback argument to backtrace_syminfo. DATA and
kono
parents:
diff changeset
170 PC are the arguments passed to backtrace_syminfo. SYMNAME is the
kono
parents:
diff changeset
171 name of the symbol for the corresponding code. SYMVAL is the
kono
parents:
diff changeset
172 value and SYMSIZE is the size of the symbol. SYMNAME will be NULL
kono
parents:
diff changeset
173 if no error occurred but the symbol could not be found. */
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 typedef void (*backtrace_syminfo_callback) (void *data, uintptr_t pc,
kono
parents:
diff changeset
176 const char *symname,
kono
parents:
diff changeset
177 uintptr_t symval,
kono
parents:
diff changeset
178 uintptr_t symsize);
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 /* Given ADDR, an address or program counter in the current program,
kono
parents:
diff changeset
181 call the callback information with the symbol name and value
kono
parents:
diff changeset
182 describing the function or variable in which ADDR may be found.
kono
parents:
diff changeset
183 This will call either CALLBACK or ERROR_CALLBACK exactly once.
kono
parents:
diff changeset
184 This returns 1 on success, 0 on failure. This function requires
kono
parents:
diff changeset
185 the symbol table but does not require the debug info. Note that if
kono
parents:
diff changeset
186 the symbol table is present but ADDR could not be found in the
kono
parents:
diff changeset
187 table, CALLBACK will be called with a NULL SYMNAME argument.
kono
parents:
diff changeset
188 Returns 1 on success, 0 on error. */
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 extern int backtrace_syminfo (struct backtrace_state *state, uintptr_t addr,
kono
parents:
diff changeset
191 backtrace_syminfo_callback callback,
kono
parents:
diff changeset
192 backtrace_error_callback error_callback,
kono
parents:
diff changeset
193 void *data);
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 #ifdef __cplusplus
kono
parents:
diff changeset
196 } /* End extern "C". */
kono
parents:
diff changeset
197 #endif
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 #endif