From 5f15887ceb8460aa5b5120b1fc4f90b6ebfd06cb Mon Sep 17 00:00:00 2001 From: Emmanuel Mogenet Date: Sat, 15 Apr 2017 20:12:26 +0200 Subject: Add mechanism to restrict signals dumped by ghwdump --- src/grt/ghwdump.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++- src/grt/ghwlib.c | 27 ++++++++++++- src/grt/ghwlib.h | 3 ++ 3 files changed, 138 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/grt/ghwdump.c b/src/grt/ghwdump.c index 00e1f683d..3c399cf92 100644 --- a/src/grt/ghwdump.c +++ b/src/grt/ghwdump.c @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -35,10 +36,100 @@ usage (void) " -h display hierarchy\n" " -T display time\n" " -s display signals (and time)\n" + " -f list of signals to display (default: all, example: -f 1,3,5-7,21-33)\n" " -l display list of sections\n" " -v verbose\n"); } +static void add_single_signal( + int **signalSet, + int *nbSignals, + int signal +) { + assert(NULL!=signalSet); + assert(NULL!=nbSignals); + assert(0<=nbSignals[0]); + assert(0<=signal); + + int newSize = (1 + nbSignals[0]); + /*printf("adding signal %6d set of signals to display\n", signal);*/ + signalSet[0] = (int*)realloc(signalSet[0], newSize*sizeof(int)); + signalSet[0][nbSignals[0]] = signal; + nbSignals[0] = newSize; +} + +static void add_signal_range( + int **signalSet, + int *nbSignals, + const char *s, + const char *e +) { + + int i; + int rangeSize; + int rangeEnd = -1; + int rangeStart = -1; + int bytesMatched = -1; + int expected = ((e - s) - 1); + int itemsMatched =sscanf( + s, + "%d-%d%n", + &rangeStart, + &rangeEnd, + &bytesMatched + ); + if(2==itemsMatched && expected==bytesMatched) { + if(rangeEndsnap_time); if (flag_disp_signals) - ghw_disp_values (hp); + { + if (!filter_done) + { + ghw_filter_values (hp, signal_set, nb_signals); + filter_done = 1; + } + ghw_disp_values (hp); + } break; case ghw_res_eof: eof = 1; diff --git a/src/grt/ghwlib.c b/src/grt/ghwlib.c index 996057ff6..4ac721ee0 100644 --- a/src/grt/ghwlib.c +++ b/src/grt/ghwlib.c @@ -1345,6 +1345,31 @@ ghw_get_value (char *buf, int len, union ghw_val *val, union ghw_type *type) } } +static int +is_skip_signal (int *signals_to_keep, int nb_signals_to_keep, int signal) +{ + int i; + + for (i = 0; i < nb_signals_to_keep; ++i) + { + if (signal==signals_to_keep[i]) + return 0; + } + return 1; +} + +void +ghw_filter_values (struct ghw_handler *h, int *signals_to_keep, int nb_signals_to_keep) +{ + int i; + + for (i = 0; i < h->nbr_sigs; ++i) + { + struct ghw_sig *s = &(h->sigs[i]); + s->skip = is_skip_signal (signals_to_keep, nb_signals_to_keep, i); + } +} + void ghw_disp_values (struct ghw_handler *h) { @@ -1353,7 +1378,7 @@ ghw_disp_values (struct ghw_handler *h) for (i = 0; i < h->nbr_sigs; i++) { struct ghw_sig *s = &h->sigs[i]; - if (s->type != NULL) + if (s->type != NULL && !(s->skip)) { printf ("#%d: ", i); ghw_disp_value (s->val, s->type); diff --git a/src/grt/ghwlib.h b/src/grt/ghwlib.h index 7e51376af..145e6c2dd 100644 --- a/src/grt/ghwlib.h +++ b/src/grt/ghwlib.h @@ -256,6 +256,7 @@ struct ghw_sig { union ghw_type *type; union ghw_val *val; + int skip; }; enum ghw_hie_kind { @@ -358,6 +359,8 @@ void ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top); int ghw_read_base (struct ghw_handler *h); +void ghw_filter_values (struct ghw_handler *h, int *signals_to_keep, int nb_signals_to_keep); + void ghw_disp_values (struct ghw_handler *h); int ghw_read_cycle_start (struct ghw_handler *h); -- cgit v1.2.3