1414#include <stddef.h>
1515#include <stdint.h>
1616
17- #ifdef __cplusplus
17+ #define MAX_CAPTURED_CALL_STACK_DEPTH 128
18+
19+ #if defined(__cplusplus )
1820extern "C" {
1921#endif
2022
23+ // This is a virtual type, only used as the type for parameters of public
24+ // functions.
2125typedef struct ten_backtrace_t ten_backtrace_t ;
2226
2327/**
@@ -38,7 +42,7 @@ typedef struct ten_backtrace_t ten_backtrace_t;
3842 * @note The @a filename and @a function buffers may become invalid after this
3943 * function returns.
4044 */
41- typedef int (* ten_backtrace_dump_file_line_func_t )(
45+ typedef int (* ten_backtrace_on_dump_file_line_func_t )(
4246 ten_backtrace_t * ten_backtrace , uintptr_t pc , const char * filename ,
4347 int lineno , const char * function , void * data );
4448
@@ -55,7 +59,7 @@ typedef int (*ten_backtrace_dump_file_line_func_t)(
5559 * @note @a symname will be NULL if no error occurred but the symbol could not
5660 * be found.
5761 */
58- typedef void (* ten_backtrace_dump_syminfo_func_t )(
62+ typedef void (* ten_backtrace_on_dump_syminfo_func_t )(
5963 ten_backtrace_t * ten_backtrace , uintptr_t pc , const char * sym_name ,
6064 uintptr_t sym_val , uintptr_t sym_size , void * data );
6165
@@ -78,52 +82,52 @@ typedef void (*ten_backtrace_dump_syminfo_func_t)(
7882 * but the function requires a symbol table (e.g., backtrace_syminfo). This may
7983 * be used as a signal that some other approach should be tried.
8084 */
81- typedef void (* ten_backtrace_error_func_t )(ten_backtrace_t * self ,
82- const char * msg , int errnum ,
83- void * data );
85+ typedef void (* ten_backtrace_on_error_func_t )(ten_backtrace_t * self ,
86+ const char * msg , int errnum ,
87+ void * data );
8488
8589/**
8690 * @brief Given @a pc, a program counter in the current program, call the
87- * @a dump_file_line_cb function with filename, line number, and function name
91+ * @a on_dump_file_line function with filename, line number, and function name
8892 * information. This will normally call the callback function exactly once.
8993 * However, if the @a pc happens to describe an inlined call, and the debugging
9094 * information contains the necessary information, then this may call the
9195 * callback function multiple times. This will make at least one call to either
92- * @a dump_file_line_cb or @a error_cb .
96+ * @a on_dump_file_line or @a on_error .
9397 *
94- * @return The first non-zero value returned by @a dump_file_line_cb or @a
95- * error_cb , or 0.
98+ * @return The first non-zero value returned by @a on_dump_file_line or @a
99+ * on_error , or 0.
96100 */
97- TEN_UTILS_API int ten_backtrace_get_file_line_info (
101+ TEN_UTILS_PRIVATE_API int ten_backtrace_get_file_line_info (
98102 ten_backtrace_t * self , uintptr_t pc ,
99- ten_backtrace_dump_file_line_func_t dump_file_line_cb ,
100- ten_backtrace_error_func_t error_cb , void * data );
103+ ten_backtrace_on_dump_file_line_func_t on_dump_file_line ,
104+ ten_backtrace_on_error_func_t on_error , void * data );
101105
102106/**
103107 * @brief Given @a pc, an address or program counter in the current program,
104108 * call the callback information with the symbol name and value describing the
105109 * function or variable in which @a pc may be found.
106- * This will call either @a dump_syminfo_cb or @a error_cb exactly once.
110+ * This will call either @a on_dump_syminfo or @a on_error exactly once.
107111 *
108112 * @return 1 on success, 0 on failure.
109113 *
110114 * @note This function requires the symbol table but does not require the debug
111115 * info. Note that if the symbol table is present but @a pc could not be found
112- * in the table, @a dump_syminfo_cb will be called with a NULL @a sym_name
116+ * in the table, @a on_dump_syminfo will be called with a NULL @a sym_name
113117 * argument. Returns 1 on success, 0 on error.
114118 */
115- TEN_UTILS_API int ten_backtrace_get_syminfo (
119+ TEN_UTILS_PRIVATE_API int ten_backtrace_get_syminfo (
116120 ten_backtrace_t * self , uintptr_t pc ,
117- ten_backtrace_dump_syminfo_func_t dump_syminfo_cb ,
118- ten_backtrace_error_func_t error_cb , void * data );
121+ ten_backtrace_on_dump_syminfo_func_t on_dump_syminfo ,
122+ ten_backtrace_on_error_func_t on_error , void * data );
119123
120124TEN_UTILS_API void ten_backtrace_create_global (void );
121125
122- TEN_UTILS_API ten_backtrace_t * ten_backtrace_create (void );
126+ TEN_UTILS_PRIVATE_API ten_backtrace_t * ten_backtrace_create (void );
123127
124128TEN_UTILS_API void ten_backtrace_destroy_global (void );
125129
126- TEN_UTILS_API void ten_backtrace_destroy (ten_backtrace_t * self );
130+ TEN_UTILS_PRIVATE_API void ten_backtrace_destroy (ten_backtrace_t * self );
127131
128132/**
129133 * @brief Get a full stack backtrace.
@@ -139,8 +143,9 @@ TEN_UTILS_API void ten_backtrace_destroy(ten_backtrace_t *self);
139143 * 'dump' callback or 'error' callback.
140144 * @note This function requires debug info for the executable.
141145 */
142- TEN_UTILS_API void ten_backtrace_dump (ten_backtrace_t * self , size_t skip );
146+ TEN_UTILS_PRIVATE_API void ten_backtrace_dump (ten_backtrace_t * self ,
147+ size_t skip );
143148
144- #ifdef __cplusplus
149+ #if defined( __cplusplus )
145150 } /* End extern "C". */
146151#endif
0 commit comments