summaryrefslogtreecommitdiff
path: root/src/bin/eina/eina_btlog.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-06 14:00:55 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-06 14:06:10 -0200
commit83425483569bb63528e0616f36006f6ec2cb14fe (patch)
treee34b939b6d93cdc15121b567653f14891d15a9c5 /src/bin/eina/eina_btlog.c
parentf0e13ccad9f3508ee994de8ec3018d70c7f21f15 (diff)
eina_btlog: allows continuous running on input, flush when possible.
eina_btlog will make a table of the backtrace and then must compute columns length. However, if not running in such mode (ie: show_compact/-c), we don't need to queue lines or compute column lengths. Also, now that we accept non-backtrace lines, like other output interleaved, then flush the table once such line is found, this will restart the table columns for the next output, but at least allows eina_btlog to run on a live output, such as: myapp 2>&1 | eina_btlog
Diffstat (limited to '')
-rw-r--r--src/bin/eina/eina_btlog.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/bin/eina/eina_btlog.c b/src/bin/eina/eina_btlog.c
index fff97d8cdd..0be9301a5e 100644
--- a/src/bin/eina/eina_btlog.c
+++ b/src/bin/eina/eina_btlog.c
@@ -432,10 +432,17 @@ main(int argc, char **argv)
432 return 1; 432 return 1;
433 } 433 }
434 434
435 repeat:
435 while (fgets(buf, sizeof(buf) - 1, stdin)) 436 while (fgets(buf, sizeof(buf) - 1, stdin))
436 { 437 {
437 btl = bt_append(btl, buf); 438 btl = bt_append(btl, buf);
439 if (show_compact) goto do_show;
440 bt = eina_list_last_data_get(btl);
441 if (bt && !bt->bin_dir) break; /* flush once first non-bt is found */
438 } 442 }
443
444 /* compute columns for expanded display */
445 for (i = 0; i < 6; i++) cols[i] = 0;
439 EINA_LIST_FOREACH(btl, l, bt) 446 EINA_LIST_FOREACH(btl, l, bt)
440 { 447 {
441 if (!bt->bin_dir) continue; 448 if (!bt->bin_dir) continue;
@@ -456,6 +463,8 @@ main(int argc, char **argv)
456 len = strlen(bt->func_name); 463 len = strlen(bt->func_name);
457 if (len > cols[5]) cols[5] = len; 464 if (len > cols[5]) cols[5] = len;
458 } 465 }
466
467 do_show:
459 EINA_LIST_FOREACH(btl, l, bt) 468 EINA_LIST_FOREACH(btl, l, bt)
460 { 469 {
461 if (bt->comment && show_comments) 470 if (bt->comment && show_comments)
@@ -505,6 +514,8 @@ main(int argc, char **argv)
505 free(bt->comment); 514 free(bt->comment);
506 free(bt); 515 free(bt);
507 } 516 }
517 /* if not EOF, then we just flushed due non-bt line, try again */
518 if (!feof(stdin)) goto repeat;
508 519
509 eina_shutdown(); 520 eina_shutdown();
510 521