Use libbacktrace to generate better leak callstacks.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3986 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-09-24 20:54:54 +00:00
parent 8279ec5e9e
commit eadda41518
77 changed files with 79134 additions and 15 deletions

View File

@ -9,6 +9,7 @@
#include "tests.h"
#include "util.js.h"
#include <backtrace.h>
#include <memcheck.h>
#include <quickjs-libc.h>
#include <quickjs.h>
@ -83,6 +84,8 @@ const command_t k_commands[] = {
{ "private", _tf_command_private, "Check for private messages the SSB database (just an experiment)." },
};
struct backtrace_state* g_backtrace_state;
void shedPrivileges()
{
#if !defined(_WIN32)
@ -684,8 +687,19 @@ static void _do_leak_checks(int sig)
}
#endif
static void _backtrace_error(void* data, const char* message, int errnum)
{
printf("libbacktrace error %d: %s\n", errnum, message);
}
int main(int argc, char* argv[])
{
g_backtrace_state = backtrace_create_state(
argv[0],
0,
_backtrace_error,
NULL);
#if !defined(_WIN32)
prctl(PR_SET_PDEATHSIG, SIGKILL);
#endif