Track and expose hitches in some suspect callbacks.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4261 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-04-19 23:05:59 +00:00
parent 30014040e7
commit 956ea0df56
6 changed files with 116 additions and 0 deletions

View File

@ -462,6 +462,30 @@ const char* tf_util_backtrace_to_string(void* const* buffer, int count)
return string;
}
static int _tf_util_backtrace_single_callback(void* data, uintptr_t pc, const char* filename, int line_number, const char* function)
{
char** stack = data;
char line[256];
int length = snprintf(line, sizeof(line), "%s", function);
int current = *stack ? strlen(*stack) : 0;
*stack = tf_resize_vec(*stack, current + length + 1);
memcpy(*stack + current, line, length + 1);
return 0;
}
const char* tf_util_function_to_string(void* function)
{
extern struct backtrace_state* g_backtrace_state;
char* string = NULL;
backtrace_pcinfo(
g_backtrace_state,
(uintptr_t)function,
_tf_util_backtrace_single_callback,
_tf_util_backtrace_error,
&string);
return string;
}
const char* tf_util_backtrace_string()
{
void* buffer[32];