From 4a13f878fbe33ec9f13ac4de034f2a83d146bc08 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Fri, 20 Dec 2024 22:26:58 +0000 Subject: [PATCH] Add comms pacing to orbtop --- Src/itmDecoder.c | 4 +++- Src/orbtop.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Src/itmDecoder.c b/Src/itmDecoder.c index 2543a647..853c8730 100644 --- a/Src/itmDecoder.c +++ b/Src/itmDecoder.c @@ -14,6 +14,9 @@ #include "itmDecoder.h" #include "msgDecoder.h" +// Define this to get transitions printed out +#define DEBUG + #ifdef DEBUG #include #include "generics.h" @@ -28,7 +31,6 @@ #define MAX_PACKET (5) #define DEFAULT_PAGE_REGISTER (0x07) -// Define this to get transitions printed out // ==================================================================================================== struct ITMDecoder *ITMDecoderCreate( void ) diff --git a/Src/orbtop.c b/Src/orbtop.c index 0be99d74..3f1b0b52 100644 --- a/Src/orbtop.c +++ b/Src/orbtop.c @@ -92,6 +92,7 @@ struct /* Record for options, either defau char *outfile; /* File to output current information */ char *logfile; /* File to output historic information */ bool mono; /* Supress colour in output */ + int paceDelay; /* Delay between blocks of data transmission in file readout */ uint32_t cutscreen; /* Cut screen output after specified number of lines */ uint32_t maxRoutines; /* Historic information to emit */ bool lineDisaggregation; /* Aggregate per line or per function? */ @@ -906,6 +907,7 @@ void _printHelp( const char *const progName ) genericsPrintf( " -o, --output-file: to be used for output live file" EOL ); genericsPrintf( " -O, --objdump-opts: Options to pass directly to objdump" EOL ); genericsPrintf( " -p, --protocol: Protocol to communicate. Defaults to OFLOW if -s is not set, otherwise ITM" EOL ); + genericsPrintf( " -P, --pace: delay in block of data transmission to clients" EOL ); genericsPrintf( " -r, --routines: to record in live file (default %d routines)" EOL, options.maxRoutines ); genericsPrintf( " -R, --report-files: Report filenames as part of function discriminator" EOL ); genericsPrintf( " -s, --server: : to use" EOL ); @@ -941,6 +943,7 @@ static struct option _longOptions[] = {"output-file", required_argument, NULL, 'o'}, {"objdump-opts", required_argument, NULL, 'O'}, {"protocol", required_argument, NULL, 'p'}, + {"pace", required_argument, NULL, 'P'}, {"routines", required_argument, NULL, 'r'}, {"report-files", no_argument, NULL, 'R'}, {"server", required_argument, NULL, 's'}, @@ -957,7 +960,7 @@ bool _processOptions( int argc, char *argv[] ) bool protExplicit = false; bool serverExplicit = false; - while ( ( c = getopt_long ( argc, argv, "c:d:DEe:f:g:hVI:j:lMnO:o:p:r:Rs:t:v:", _longOptions, &optionIndex ) ) != -1 ) + while ( ( c = getopt_long ( argc, argv, "c:d:DEe:f:g:hVI:j:lMnO:o:p:P:r:Rs:t:v:", _longOptions, &optionIndex ) ) != -1 ) switch ( c ) { // ------------------------------------ @@ -1057,6 +1060,19 @@ bool _processOptions( int argc, char *argv[] ) // ------------------------------------ + case 'P': + options.paceDelay = atoi( optarg ); + + if ( options.paceDelay <= 0 ) + { + genericsReport( V_ERROR, "paceDelay is out of range" EOL ); + return false; + } + + break; + + // ------------------------------------ + case 'O': options.odoptions = optarg; break; @@ -1154,6 +1170,7 @@ bool _processOptions( int argc, char *argv[] ) if ( options.file ) { + genericsReport( V_INFO, "Pace Delay : %dus" EOL, options.paceDelay ); genericsReport( V_INFO, "Input File : %s", options.file ); } else @@ -1181,7 +1198,13 @@ bool _processOptions( int argc, char *argv[] ) default: genericsReport( V_INFO, "Decoding unknown" EOL ); - break; + return false; + } + + if ( ( options.paceDelay ) && ( !options.file ) ) + { + genericsReport( V_ERROR, "Pace Delay only makes sense when input is from a file" EOL ); + return false; } return OK; @@ -1490,6 +1513,11 @@ int main( int argc, char *argv[] ) ITMDecoderGetStats( &_r.i )->tpiuSyncCount = 0; } } + + if ( options.paceDelay ) + { + usleep( options.paceDelay ); + } } stream->close( stream );