summaryrefslogtreecommitdiff
path: root/src/bin/eina
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-03 12:57:24 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-03 13:01:36 -0200
commit84a0f047db9fcd0efd2c29c85ba41fd8f624de3d (patch)
treef93598099884bfb6b819644efef281f911fe472d /src/bin/eina
parent683a508c204197a843e13d4c64c94474332eb04d (diff)
eina_btlog: compact output and keep non-bt information.
Now we keep all non-bt prefixes as well, in conjunction with compact mode it looks like we resolved the address to lines in the output. Example: ``` $ cat bt-new.txt ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000004e401ca: libeo_dbg.so+0x91ca (in src/lib/eo/.libs/libeo_dbg.so 0x4e37000) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000004e3fb42: _efl_add_internal_start+0x1c2 (in src/lib/eo/.libs/libeo_dbg.so 0x4e37000) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x0000000010a85f: lt-efl_net_dialer_simple_example+0x285f (in /home/gustavo/Development/git/efl/src/examples/ecore/.libs/lt-efl_net_dialer_simple_example 0x108000) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000005c7c291: __libc_start_main+0xf1 (in /usr/lib/libc.so.6 0x5c5c000) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x0000000010a38a: _start+0x2a (in /home/gustavo/Development/git/efl/src/examples/ecore/.libs/lt-efl_net_dialer_simple_example 0x108000) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() obj_id=0x400000007feb55b9 deleted obj=0x97870b0, class=0x9785850 (Efl_Net_Dialer_Simple) [0.9045s, 0.0198 ago]: ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000004e409aa: libeo_dbg.so+0x99aa (in src/lib/eo/.libs/libeo_dbg.so 0x4e37000) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000004e407f1: libeo_dbg.so+0x97f1 (in src/lib/eo/.libs/libeo_dbg.so 0x4e37000) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000004e3eee8: libeo_dbg.so+0x7ee8 (in src/lib/eo/.libs/libeo_dbg.so 0x4e37000) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000004e3f09e: _efl_object_call_end+0x4e (in src/lib/eo/.libs/libeo_dbg.so 0x4e37000) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000004e48a65: efl_del+0x105 (in src/lib/eo/.libs/libeo_dbg.so 0x4e37000) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x0000000010ac2c: lt-efl_net_dialer_simple_example+0x2c2c (in /home/gustavo/Development/git/efl/src/examples/ecore/.libs/lt-efl_net_dialer_simple_example 0x108000) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000005c7c291: __libc_start_main+0xf1 (in /usr/lib/libc.so.6 0x5c5c000) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x0000000010a38a: _start+0x2a (in /home/gustavo/Development/git/efl/src/examples/ecore/.libs/lt-efl_net_dialer_simple_example 0x108000) ERR<24641>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() obj_id=0x400000007c9a1109 was already deleted 0.0287 seconds ago! ``` Results in: ``` $ cat /tmp/bt-new.txt | eina_btlog -c ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() _eo_log_obj_new (in eo.c:2691) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() _efl_add_internal_start (in eo.c:844) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() main (in efl_net_dialer_simple_example.c:375) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() __libc_start_main (in ??:375) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() _start (in ??:375) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() obj_id=0x400000007feb55b9 deleted obj=0x97870b0, class=0x9785850 (Efl_Net_Dialer_Simple) [0.9045s, 0.0198 ago]: ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() _eo_log_obj_free (in eo.c:2714) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() _eo_free (in eo.c:974) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() _efl_unref_internal (in eo_private.h:342) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() _efl_object_call_end (in eo.c:620) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() efl_del (in efl_object.eo.c:78) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() main (in efl_net_dialer_simple_example.c:447) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() __libc_start_main (in ??:447) ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() _start (in ??:447) ERR<24641>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() obj_id=0x400000007c9a1109 was already deleted 0.0287 seconds ago! ``` which is similar to valgrind's log and is MUCH nicer to read :-) This commit also simplifies alignment and color display by using a single printf().
Diffstat (limited to 'src/bin/eina')
-rw-r--r--src/bin/eina/eina_btlog.c170
1 files changed, 98 insertions, 72 deletions
diff --git a/src/bin/eina/eina_btlog.c b/src/bin/eina/eina_btlog.c
index b69927efd9..a0a5ab107d 100644
--- a/src/bin/eina/eina_btlog.c
+++ b/src/bin/eina/eina_btlog.c
@@ -75,6 +75,7 @@ static Translate_Func _translate = NULL;
75static const char *_prog = NULL; 75static const char *_prog = NULL;
76static Eina_Bool color = EINA_TRUE; 76static Eina_Bool color = EINA_TRUE;
77static Eina_Bool show_comments = EINA_TRUE; 77static Eina_Bool show_comments = EINA_TRUE;
78static Eina_Bool show_compact = EINA_FALSE;
78 79
79static void 80static void
80path_split(const char *path, char **dir, char **file) 81path_split(const char *path, char **dir, char **file)
@@ -230,14 +231,59 @@ end:
230} 231}
231#endif 232#endif
232 233
234static const char *
235bt_input_translate(const char *line, char **comment)
236{
237 static char local[PATH_MAX + sizeof(" 0x1234567890123456789 0x1234567890123456789\n")];
238 const char *addrstart, *addrend, *filestart, *fileend, *basestart, *baseend;
239
240 /* new bt format is more human readable, but needs some cleanup before we bt_append()
241 *
242 * Example:
243 * ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000005c7c291: __libc_start_main+0xf1 (in /usr/lib/libc.so.6 0x5c5c000)
244 * ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000004e409aa: libeo_dbg.so+0x99aa (in src/lib/eo/.libs/libeo_dbg.so 0x4e37000)
245 */
246 *comment = NULL;
247
248 addrstart = strstr(line, "0x");
249 if (!addrstart) return NULL;
250
251 addrend = strchr(addrstart, ':');
252 if (!addrend) return NULL;
253
254 filestart = strstr(addrend, "(in ");
255 if (!filestart) return NULL;
256
257 filestart += strlen("(in ");
258 basestart = strstr(filestart, " 0x");
259 if (!basestart) return NULL;
260 fileend = basestart;
261 basestart += strlen(" ");
262 baseend = strchr(basestart, ')');
263 if (!baseend) return NULL;
264
265 snprintf(local, sizeof(local), "%.*s %.*s %.*s\n",
266 (int)(fileend - filestart), filestart,
267 (int)(addrend - addrstart), addrstart,
268 (int)(baseend - basestart), basestart);
269 *comment = strndup(line, addrstart - line);
270 return local;
271}
272
233static Eina_List * 273static Eina_List *
234bt_append(Eina_List *btl, const char *btline) 274bt_append(Eina_List *btl, const char *btline)
235{ 275{
236 Bt *bt = calloc(1, sizeof(Bt)); 276 Bt *bt = calloc(1, sizeof(Bt));
237 if (!bt) return btl; 277 if (!bt) return btl;
278 const char *translation;
279 char *comment = NULL;
238 char *bin = strdup(btline); 280 char *bin = strdup(btline);
239 unsigned long long offset = 0, base = 0; 281 unsigned long long offset = 0, base = 0;
240 282
283 translation = bt_input_translate(btline, &comment);
284 if (translation)
285 btline = translation;
286
241 // parse: 287 // parse:
242 // /usr/local/lib/libeina.so.1 0x1ec88 288 // /usr/local/lib/libeina.so.1 0x1ec88
243 // /usr/local/lib/libelementary.so.1 0x10f695 289 // /usr/local/lib/libelementary.so.1 0x10f695
@@ -263,10 +309,12 @@ bt_append(Eina_List *btl, const char *btline)
263 bt->func_name = strdup(""); 309 bt->func_name = strdup("");
264 } 310 }
265 } 311 }
312 bt->comment = comment;
266 btl = eina_list_append(btl, bt); 313 btl = eina_list_append(btl, bt);
267 } 314 }
268 else 315 else
269 { 316 {
317 free(comment);
270 bt->comment = strdup(btline); 318 bt->comment = strdup(btline);
271 btl = eina_list_append(btl, bt); 319 btl = eina_list_append(btl, bt);
272 } 320 }
@@ -275,43 +323,6 @@ bt_append(Eina_List *btl, const char *btline)
275 return btl; 323 return btl;
276} 324}
277 325
278static const char *
279bt_input_translate(char *line)
280{
281 static char local[PATH_MAX + sizeof(" 0x1234567890123456789 0x1234567890123456789\n")];
282 const char *addrstart, *addrend, *filestart, *fileend, *basestart, *baseend;
283
284 /* new bt format is more human readable, but needs some cleanup before we bt_append()
285 *
286 * Example:
287 * ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000005c7c291: __libc_start_main+0xf1 (in /usr/lib/libc.so.6 0x5c5c000)
288 * ERR<23314>:eo_lifecycle ../src/lib/eo/efl_object.eo.c:78 efl_del() 0x00000004e409aa: libeo_dbg.so+0x99aa (in src/lib/eo/.libs/libeo_dbg.so 0x4e37000)
289 */
290
291 addrstart = strstr(line, "0x");
292 if (!addrstart) return line;
293
294 addrend = strchr(addrstart, ':');
295 if (!addrend) return line;
296
297 filestart = strstr(addrend, "(in ");
298 if (!filestart) return line;
299
300 filestart += strlen("(in ");
301 basestart = strstr(filestart, " 0x");
302 if (!basestart) return line;
303 fileend = basestart;
304 basestart += strlen(" ");
305 baseend = strchr(basestart, ')');
306 if (!baseend) return line;
307
308 snprintf(local, sizeof(local), "%.*s %.*s %.*s\n",
309 (int)(fileend - filestart), filestart,
310 (int)(addrend - addrstart), addrstart,
311 (int)(baseend - basestart), basestart);
312 return local;
313}
314
315static Eina_Bool 326static Eina_Bool
316_translation_function_detect(const Translation_Desc *desc) 327_translation_function_detect(const Translation_Desc *desc)
317{ 328{
@@ -345,6 +356,12 @@ main(int argc, char **argv)
345 char buf[4096]; 356 char buf[4096];
346 Bt *bt; 357 Bt *bt;
347 int cols[6] = { 0 }, len, i; 358 int cols[6] = { 0 }, len, i;
359 const char *func_color = "";
360 const char *dir_color = "";
361 const char *sep_color = "";
362 const char *file_color = "";
363 const char *line_color = "";
364 const char *reset_color = "";
348 const Translation_Desc desc[] = { 365 const Translation_Desc desc[] = {
349#ifdef ATOS_COMPATIBLE 366#ifdef ATOS_COMPATIBLE
350 { /* Mac OS X */ 367 { /* Mac OS X */
@@ -383,7 +400,8 @@ main(int argc, char **argv)
383 { 400 {
384 printf("Usage: eina_btlog [-n]\n" 401 printf("Usage: eina_btlog [-n]\n"
385 " -n Do not use color escape codes\n" 402 " -n Do not use color escape codes\n"
386 " -C Do not show comments (non-bt lines)\n" 403 " -C Do not show comments (non-bt fragments)\n"
404 " -c Show compact output format\n"
387 "\n" 405 "\n"
388 "Provide addresses logged from EFL applications to stdin.\n" 406 "Provide addresses logged from EFL applications to stdin.\n"
389 "Example:\n\n" 407 "Example:\n\n"
@@ -394,6 +412,17 @@ main(int argc, char **argv)
394 } 412 }
395 else if (!strcmp(argv[i], "-n")) color = EINA_FALSE; 413 else if (!strcmp(argv[i], "-n")) color = EINA_FALSE;
396 else if (!strcmp(argv[i], "-C")) show_comments = EINA_FALSE; 414 else if (!strcmp(argv[i], "-C")) show_comments = EINA_FALSE;
415 else if (!strcmp(argv[i], "-c")) show_compact = EINA_TRUE;
416 }
417
418 if (color)
419 {
420 func_color = EINA_COLOR_GREEN;
421 dir_color = EINA_COLOR_BLUE;
422 sep_color = EINA_COLOR_CYAN;
423 file_color = EINA_COLOR_WHITE;
424 line_color = EINA_COLOR_YELLOW;
425 reset_color = EINA_COLOR_RESET;
397 } 426 }
398 427
399 if (!_translation_function_detect(desc)) 428 if (!_translation_function_detect(desc))
@@ -405,7 +434,7 @@ main(int argc, char **argv)
405 434
406 while (fgets(buf, sizeof(buf) - 1, stdin)) 435 while (fgets(buf, sizeof(buf) - 1, stdin))
407 { 436 {
408 btl = bt_append(btl, bt_input_translate(buf)); 437 btl = bt_append(btl, buf);
409 } 438 }
410 EINA_LIST_FOREACH(btl, l, bt) 439 EINA_LIST_FOREACH(btl, l, bt)
411 { 440 {
@@ -432,42 +461,39 @@ main(int argc, char **argv)
432 if (bt->comment && show_comments) 461 if (bt->comment && show_comments)
433 fputs(bt->comment, stdout); 462 fputs(bt->comment, stdout);
434 if (!bt->bin_dir) continue; 463 if (!bt->bin_dir) continue;
435 len = strlen(bt->bin_dir);
436 for (i = 0; i < (cols[0] - len); i++) printf(" ");
437 if (color)
438 printf(" \033[34m%s\033[01m\033[36m/\033[37m%s\033[0m",
439 bt->bin_dir, bt->bin_name);
440 else
441 printf(" %s/%s",
442 bt->bin_dir, bt->bin_name);
443 len = strlen(bt->bin_name);
444 for (i = 0; i < (cols[1] - len); i++) printf(" ");
445 printf(" | ");
446 len = strlen(bt->file_dir);
447 for (i = 0; i < (cols[2] - len); i++) printf(" ");
448 if (color)
449 printf("\033[34m%s\033[01m\033[36m/\033[37m%s\033[0m",
450 bt->file_dir, bt->file_name);
451 else
452 printf("%s/%s",
453 bt->file_dir, bt->file_name);
454 len = strlen(bt->file_name);
455 for (i = 0; i < (cols[3] - len); i++) printf(" ");
456 464
457 printf(" : "); 465 if (show_compact)
458 snprintf(buf, sizeof(buf), "%i", bt->line);
459 len = strlen(buf);
460 for (i = 0; i < (cols[4] - len); i++) printf(" ");
461 if (color)
462 { 466 {
463 printf("\033[01m\033[33m%s\033[0m @ \033[32m%s\033[36m()", buf, bt->func_name); 467 printf("%s%s%s (in %s%s%s:%s%d%s)\n",
464 printf("\033[0m\n"); 468 func_color, bt->func_name, reset_color,
469 file_color, bt->file_name, reset_color,
470 line_color, bt->line, reset_color);
471 continue;
465 } 472 }
466 else 473
467 { 474 printf(" "
468 printf("%s @ %s()", buf, bt->func_name); 475 "%s%*s%s/%s%-*s%s" /* bin info */
469 printf("\n"); 476 "| "
470 } 477 "%s%*s%s/%s%-*s%s" /* file info */
478 ": "
479 "%s%*i%s" /* line info */
480 " @ "
481 "%s%s%s()%s\n", /* func info */
482 /* bin info */
483 dir_color, cols[0], bt->bin_dir, sep_color,
484 file_color, cols[1], bt->bin_name,
485 reset_color,
486 /* file info */
487 dir_color, cols[2], bt->file_dir, sep_color,
488 file_color, cols[3], bt->file_name,
489 reset_color,
490 /* line info */
491 line_color, cols[4], bt->line,
492 reset_color,
493 /* func info */
494 func_color, bt->func_name,
495 sep_color,
496 reset_color);
471 } 497 }
472 return 0; 498 return 0;
473} 499}