mirror of https://github.com/AxioDL/logvisor.git
Better performance on backtrace generation
This commit is contained in:
parent
469bd97ce6
commit
31aea91ea3
|
@ -134,27 +134,34 @@ void logvisorAbort()
|
||||||
readlink("/proc/self/exe", exeNameBuffer, exeBufSize);
|
readlink("/proc/self/exe", exeNameBuffer, exeBufSize);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
char cmdLine[1024];
|
||||||
|
#if __APPLE__
|
||||||
|
snprintf(cmdLine, 1024, "atos -p %p", getpid());
|
||||||
|
#else
|
||||||
|
snprintf(cmdLine, 1024, "addr2line -C -f -e \"%s\"", exeNameBuffer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::string cmdLineStr = cmdLine;
|
||||||
for (size_t i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "- ");
|
snprintf(cmdLine, 128, " %p", array[i]);
|
||||||
|
cmdLineStr += cmdLine;
|
||||||
|
}
|
||||||
|
|
||||||
char cmdLine[512];
|
FILE* fp = popen(cmdLineStr.c_str(), "r");
|
||||||
#if __APPLE__
|
if (fp)
|
||||||
snprintf(cmdLine, 512, "atos -p %p %p", getpid(), array[i]);
|
{
|
||||||
#else
|
char readBuf[256];
|
||||||
snprintf(cmdLine, 512, "addr2line -C -f -e \"%s\" %p", exeNameBuffer, array[i]);
|
size_t readSz;
|
||||||
#endif
|
while ((readSz = fread(readBuf, 1, 256, fp)))
|
||||||
FILE* fp = popen(cmdLine, "r");
|
fwrite(readBuf, 1, readSz, stderr);
|
||||||
if (fp)
|
pclose(fp);
|
||||||
{
|
}
|
||||||
char readBuf[256];
|
else
|
||||||
size_t readSz;
|
{
|
||||||
while ((readSz = fread(readBuf, 1, 256, fp)))
|
for (size_t i = 0; i < size; i++)
|
||||||
fwrite(readBuf, 1, readSz, stderr);
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "- ");
|
||||||
Dl_info dlip;
|
Dl_info dlip;
|
||||||
if (dladdr(array[i], &dlip))
|
if (dladdr(array[i], &dlip))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue