forked from cory/tildefriends
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:
14
src/main.c
14
src/main.c
@ -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
|
||||
|
Reference in New Issue
Block a user