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:
Makefile
deps/libbacktrace
.gitignoreIsaac.Newton-Opticks.txtLICENSEMakefile.amMakefile.inREADME.mdaclocal.m4alloc.callocfail.callocfail.shatomic.cbacktrace-supported.h.inbacktrace.cbacktrace.hbtest.ccompileconfig.guessconfig.h.inconfig.sub
config
enable.m4lead-dot.m4libtool.m4ltoptions.m4ltsugar.m4ltversion.m4lt~obsolete.m4multi.m4override.m4unwind_ipinfo.m4warnings.m4
configureconfigure.acdwarf.cedtest.cedtest2.celf.cfileline.cfilenames.hfiletype.awkinstall-debuginfo-for-buildid.sh.ininstall-shinstrumented_alloc.cinternal.hlibtool.m4ltmain.shltoptions.m4ltsugar.m4ltversion.m4lt~obsolete.m4macho.cmissingmmap.cmmapio.cmove-if-changemtest.cnounwind.cpecoff.cposix.cprint.cread.csimple.csort.cstate.cstest.ctest-drivertest_format.ctestlib.ctestlib.httest.cunittest.cunknown.cxcoff.cxztest.cztest.csrc
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