From 5e4995f99521aa5b2d20ba63dca99893d93320b1 Mon Sep 17 00:00:00 2001 From: ArturX Kloniecki Date: Mon, 8 Oct 2018 14:18:08 +0200 Subject: [PATCH] logger: Implement possibility to read log data from stdin Signed-off-by: ArturX Kloniecki --- rmbox/convert.h | 1 + rmbox/logger_convert.c | 3 ++- rmbox/rmbox.c | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/rmbox/convert.h b/rmbox/convert.h index 19c296b..085ea5f 100644 --- a/rmbox/convert.h +++ b/rmbox/convert.h @@ -35,6 +35,7 @@ struct convert_config { #ifdef LOGGER_FORMAT const char *ldc_file; FILE* ldc_fd; + int input_std; #endif }; diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c index 84f8585..a859d49 100644 --- a/rmbox/logger_convert.c +++ b/rmbox/logger_convert.c @@ -70,6 +70,7 @@ static inline void print_table_header(FILE *out_fd) "DELTA", "FILE_NAME", "CONTENT"); + fflush(out_fd); } #define CASE(x) \ @@ -137,6 +138,7 @@ static void print_entry_params(FILE *out_fd, struct dma_log dma_log, break; } fprintf(out_fd, "\n"); + fflush(out_fd); } static int fetch_entry(struct convert_config *config, uint32_t base_address, @@ -241,7 +243,6 @@ static int logger_read(struct convert_config *config, { struct dma_log dma_log; int ret = 0; - print_table_header(config->out_fd); uint64_t last_timestamp = 0; diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 0e713b8..671a2d1 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -42,6 +42,7 @@ static void usage(void) fprintf(stdout, "%s:\t -i infile -o outfile\tDump infile contents to outfile\n", APP_NAME); #ifdef LOGGER_FORMAT fprintf(stdout, "%s:\t -l *.ldc_file\t-i in_file\n", APP_NAME); + fprintf(stdout, "%s:\t -p \tinput from stdin\n", APP_NAME); #endif fprintf(stdout, "%s:\t -c\t\t\tSet timestamp clock in MHz\n", APP_NAME); fprintf(stdout, "%s:\t -s\t\t\tTake a snapshot of state\n", APP_NAME); @@ -122,10 +123,11 @@ int main(int argc, char *argv[]) config.in_fd = NULL; #ifdef LOGGER_FORMAT config.ldc_file = NULL; + config.input_std = 0; #endif #ifdef LOGGER_FORMAT - while ((opt = getopt(argc, argv, "ho:i:l:s:m:c:t")) != -1) { + while ((opt = getopt(argc, argv, "ho:i:l:ps:m:c:t")) != -1) { #else while ((opt = getopt(argc, argv, "ho:i:s:m:c:t")) != -1) { #endif @@ -148,6 +150,9 @@ int main(int argc, char *argv[]) case 'l': config.ldc_file = optarg; break; + case 'p': + config.input_std = 1; + break; #endif case 'h': default: /* '?' */ @@ -190,7 +195,12 @@ int main(int argc, char *argv[]) if (!config.in_file) config.in_file = "/sys/kernel/debug/sof/etrace"; - if (config.in_file) { +#ifdef LOGGER_FORMAT + if (config.input_std) { + config.in_fd = stdin; + } else +#endif + { config.in_fd = fopen(config.in_file, "r"); if (!config.in_fd) { fprintf(stderr, "error: Unable to open in file %s\n",