summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-11-10 17:57:14 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-11-10 17:57:14 +0900
commitbcaba6c60501cc5d17ea25b419bd26c76c54075a (patch)
tree3bcbc8c4475f5ad3b892e82f66a115047874649a
parenta840cc0a5d08237063cff5d06f927566008f57db (diff)
mtrack - faster with less snprintfingHEADmaster
-rw-r--r--mtrack.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/mtrack.c b/mtrack.c
index 8eb867e..ee29c8d 100644
--- a/mtrack.c
+++ b/mtrack.c
@@ -337,25 +337,39 @@ _mhook_trace_log(const char *str)
337 } 337 }
338 inside = 1; 338 inside = 1;
339 tot = sizeof(buf); 339 tot = sizeof(buf);
340 n = backtrace(bt, 256);
341 strcpy(buf, str); 340 strcpy(buf, str);
342 p = buf + strlen(str); tot -= p - buf; 341 p = buf + strlen(str); tot -= p - buf;
342 n = backtrace(bt, 250);
343 strcpy(p, " =="); p += 3; tot -= 3; 343 strcpy(p, " =="); p += 3; tot -= 3;
344 if (n > 0) 344 if (n > 0)
345 { 345 {
346 skip = 3; 346 skip = 3;
347 347
348 for (i = skip; i < n; i++) 348 for (i = skip; i < n; i++)
349 { 349 {
350 int len = 0; 350 int len = 0;
351 Dl_info info; 351 Dl_info info;
352 352
353 if (dladdr(bt[i], &info)) 353 if (dladdr(bt[i], &info))
354 { 354 {
355 len = snprintf(p, tot, " %s", info.dli_sname); 355 if (info.dli_sname)
356 {
357 len = strlen(info.dli_sname);
358 p[0] = ' ';
359 strcpy(p + 1, info.dli_sname);
360 len = 1 + len;
361 }
362 else
363 {
364 strcpy(p, " #");
365 len = 2;
366 }
356 } 367 }
357 else 368 else
358 len = snprintf(p, tot, " ?"); 369 {
370 strcpy(p, " ?");
371 len = 2;
372 }
359 p += len; tot -= len; 373 p += len; tot -= len;
360 } 374 }
361 } 375 }