mtrack - faster with less snprintfing
This commit is contained in:
parent
a840cc0a5d
commit
bcaba6c605
20
mtrack.c
20
mtrack.c
|
@ -337,9 +337,9 @@ _mhook_trace_log(const char *str)
|
||||||
}
|
}
|
||||||
inside = 1;
|
inside = 1;
|
||||||
tot = sizeof(buf);
|
tot = sizeof(buf);
|
||||||
n = backtrace(bt, 256);
|
|
||||||
strcpy(buf, str);
|
strcpy(buf, str);
|
||||||
p = buf + strlen(str); tot -= p - buf;
|
p = buf + strlen(str); tot -= p - buf;
|
||||||
|
n = backtrace(bt, 250);
|
||||||
strcpy(p, " =="); p += 3; tot -= 3;
|
strcpy(p, " =="); p += 3; tot -= 3;
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
{
|
||||||
|
@ -352,10 +352,24 @@ _mhook_trace_log(const char *str)
|
||||||
|
|
||||||
if (dladdr(bt[i], &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
|
else
|
||||||
len = snprintf(p, tot, " ?");
|
{
|
||||||
|
strcpy(p, " #");
|
||||||
|
len = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy(p, " ?");
|
||||||
|
len = 2;
|
||||||
|
}
|
||||||
p += len; tot -= len;
|
p += len; tot -= len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue