diff options
author | Gustavo Sverzut Barbieri <barbieri@profusion.mobi> | 2016-12-06 14:00:55 -0200 |
---|---|---|
committer | Gustavo Sverzut Barbieri <barbieri@profusion.mobi> | 2016-12-06 14:06:10 -0200 |
commit | 83425483569bb63528e0616f36006f6ec2cb14fe (patch) | |
tree | e34b939b6d93cdc15121b567653f14891d15a9c5 | |
parent | f0e13ccad9f3508ee994de8ec3018d70c7f21f15 (diff) | |
download | efl-83425483569bb63528e0616f36006f6ec2cb14fe.tar.gz |
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
-rw-r--r-- | src/bin/eina/eina_btlog.c | 11 |
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) return 1; } + repeat: while (fgets(buf, sizeof(buf) - 1, stdin)) { btl = bt_append(btl, buf); + if (show_compact) goto do_show; + bt = eina_list_last_data_get(btl); + if (bt && !bt->bin_dir) break; /* flush once first non-bt is found */ } + + /* compute columns for expanded display */ + for (i = 0; i < 6; i++) cols[i] = 0; EINA_LIST_FOREACH(btl, l, bt) { if (!bt->bin_dir) continue; @@ -456,6 +463,8 @@ main(int argc, char **argv) len = strlen(bt->func_name); if (len > cols[5]) cols[5] = len; } + + do_show: EINA_LIST_FOREACH(btl, l, bt) { if (bt->comment && show_comments) @@ -505,6 +514,8 @@ main(int argc, char **argv) free(bt->comment); free(bt); } + /* if not EOF, then we just flushed due non-bt line, try again */ + if (!feof(stdin)) goto repeat; eina_shutdown(); |