Backtrace stuff ahoy!
* Properly detect and utilize libdl. * Set the backtrace method appropriately. * Remove an unused backtrace format. No references existed.
This commit is contained in:
@@ -42,7 +42,7 @@ void BacktraceNames::Demangle()
|
||||
/* demangle the name using __cxa_demangle() if needed */
|
||||
if( Symbol.substr(0, 2) != "_Z" )
|
||||
return;
|
||||
|
||||
|
||||
int status = 0;
|
||||
char *name = abi::__cxa_demangle( Symbol, NULL, NULL, &status );
|
||||
if( name )
|
||||
@@ -136,7 +136,7 @@ void BacktraceNames::FromAddr( const void *p )
|
||||
/*
|
||||
Copyright (c) 2002 Jorge Acereda <[email protected]> &
|
||||
Peter O'Gorman <[email protected]>
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
@@ -288,7 +288,7 @@ void BacktraceNames::FromAddr( const void *p )
|
||||
*/
|
||||
if( Symbol.Left(9) == "_GLOBAL__" )
|
||||
Symbol = Symbol.substr(11);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#elif defined(BACKTRACE_LOOKUP_METHOD_BACKTRACE_SYMBOLS)
|
||||
@@ -340,117 +340,6 @@ void BacktraceNames::FromString( RString s )
|
||||
}
|
||||
}
|
||||
}
|
||||
#elif defined(BACKTRACE_LOOKUP_METHOD_ATOS)
|
||||
void BacktraceNames::FromAddr( const void *p )
|
||||
{
|
||||
int fds[2];
|
||||
pid_t pid;
|
||||
pid_t ppid = getpid(); /* Do this before fork()ing! */
|
||||
|
||||
Offset = 0;
|
||||
Address = intptr_t(p);
|
||||
|
||||
if (pipe(fds) != 0)
|
||||
{
|
||||
fprintf(stderr, "FromAddr pipe() failed: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
if (pid == -1)
|
||||
{
|
||||
fprintf(stderr, "FromAddr fork() failed: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
if (pid == 0)
|
||||
{
|
||||
close(fds[0]);
|
||||
for (int fd = 3; fd < 1024; ++fd)
|
||||
if (fd != fds[1])
|
||||
close(fd);
|
||||
dup2(fds[1], fileno(stdout));
|
||||
close(fds[1]);
|
||||
|
||||
char *addy;
|
||||
asprintf(&addy, "0x%x", long(p));
|
||||
char *p;
|
||||
asprintf(&p, "%d", ppid);
|
||||
|
||||
execl("/usr/bin/atos", "/usr/bin/atos", "-p", p, addy, NULL);
|
||||
|
||||
fprintf(stderr, "execl(atos) failed: %s\n", strerror(errno));
|
||||
free(addy);
|
||||
free(p);
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
close(fds[1]);
|
||||
char f[1024];
|
||||
bzero(f, 1024);
|
||||
int len = read(fds[0], f, 1024);
|
||||
|
||||
Symbol = "";
|
||||
File = "";
|
||||
|
||||
if (len == -1)
|
||||
{
|
||||
fprintf(stderr, "FromAddr read() failed: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
vector<RString> mangledAndFile;
|
||||
|
||||
split(f, " ", mangledAndFile, true);
|
||||
if (mangledAndFile.size() == 0)
|
||||
return;
|
||||
Symbol = mangledAndFile[0];
|
||||
/* eg
|
||||
* -[NSApplication run]
|
||||
* +[SomeClass initialize]
|
||||
*/
|
||||
if (Symbol[0] == '-' || Symbol[0] == '+')
|
||||
{
|
||||
Symbol = mangledAndFile[0] + " " + mangledAndFile[1];
|
||||
/* eg
|
||||
* (crt.c:300)
|
||||
* (AppKit)
|
||||
*/
|
||||
if (mangledAndFile.size() == 3)
|
||||
{
|
||||
File = mangledAndFile[2];
|
||||
size_t pos = File.find('(');
|
||||
size_t start = (pos == File.npos ? 0 : pos+1);
|
||||
pos = File.rfind(')') - 1;
|
||||
File = File.substr(start, pos);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/* eg
|
||||
* __start -> _start
|
||||
* _SDL_main -> SDL_main
|
||||
*/
|
||||
if (Symbol[0] == '_')
|
||||
Symbol = Symbol.substr(1);
|
||||
|
||||
/* eg, the full line:
|
||||
* __Z1Ci (in a.out) (asmtest.cc:33)
|
||||
* _main (in a.out) (asmtest.cc:52)
|
||||
*/
|
||||
if (mangledAndFile.size() > 3)
|
||||
{
|
||||
File = mangledAndFile[3];
|
||||
size_t pos = File.find('(');
|
||||
size_t start = (pos == File.npos ? 0 : pos+1);
|
||||
pos = File.rfind(')') - 1;
|
||||
File = File.substr(start, pos);
|
||||
}
|
||||
/* eg, the full line:
|
||||
* _main (SDLMain.m:308)
|
||||
* __Z8GameLoopv (crt.c:300)
|
||||
*/
|
||||
else if (mangledAndFile.size() == 3)
|
||||
File = mangledAndFile[2].substr(0, mangledAndFile[2].rfind(')'));
|
||||
}
|
||||
#else
|
||||
#warning Undefined BACKTRACE_LOOKUP_METHOD_*
|
||||
void BacktraceNames::FromAddr( const void *p )
|
||||
@@ -465,7 +354,7 @@ void BacktraceNames::FromAddr( const void *p )
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -475,7 +364,7 @@ void BacktraceNames::FromAddr( const void *p )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
Reference in New Issue
Block a user