mtrack - faster with less snprintfing
This commit is contained in:
parent
a840cc0a5d
commit
bcaba6c605
24
mtrack.c
24
mtrack.c
|
@ -337,25 +337,39 @@ _mhook_trace_log(const char *str)
|
|||
}
|
||||
inside = 1;
|
||||
tot = sizeof(buf);
|
||||
n = backtrace(bt, 256);
|
||||
strcpy(buf, str);
|
||||
p = buf + strlen(str); tot -= p - buf;
|
||||
n = backtrace(bt, 250);
|
||||
strcpy(p, " =="); p += 3; tot -= 3;
|
||||
if (n > 0)
|
||||
{
|
||||
skip = 3;
|
||||
|
||||
|
||||
for (i = skip; i < n; i++)
|
||||
{
|
||||
int len = 0;
|
||||
Dl_info info;
|
||||
|
||||
|
||||
if (dladdr(bt[i], &info))
|
||||
{
|
||||
len = snprintf(p, tot, " %s", info.dli_sname);
|
||||
if (info.dli_sname)
|
||||
{
|
||||
len = strlen(info.dli_sname);
|
||||
p[0] = ' ';
|
||||
strcpy(p + 1, info.dli_sname);
|
||||
len = 1 + len;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(p, " #");
|
||||
len = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
len = snprintf(p, tot, " ?");
|
||||
{
|
||||
strcpy(p, " ?");
|
||||
len = 2;
|
||||
}
|
||||
p += len; tot -= len;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue