Skip to content

Commit

Permalink
Add comms pacing to orbtop
Browse files Browse the repository at this point in the history
  • Loading branch information
mubes committed Dec 20, 2024
1 parent 5111550 commit 4a13f87
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Src/itmDecoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include "itmDecoder.h"
#include "msgDecoder.h"

// Define this to get transitions printed out
#define DEBUG

#ifdef DEBUG
#include <stdio.h>
#include "generics.h"
Expand All @@ -28,7 +31,6 @@
#define MAX_PACKET (5)
#define DEFAULT_PAGE_REGISTER (0x07)

// Define this to get transitions printed out
// ====================================================================================================
struct ITMDecoder *ITMDecoderCreate( void )

Expand Down
32 changes: 30 additions & 2 deletions Src/orbtop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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? */
Expand Down Expand Up @@ -906,6 +907,7 @@ void _printHelp( const char *const progName )
genericsPrintf( " -o, --output-file: <filename> to be used for output live file" EOL );
genericsPrintf( " -O, --objdump-opts: <options> 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: <microseconds> delay in block of data transmission to clients" EOL );
genericsPrintf( " -r, --routines: <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: <Server>:<Port> to use" EOL );
Expand Down Expand Up @@ -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'},
Expand All @@ -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 )
{
// ------------------------------------
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1490,6 +1513,11 @@ int main( int argc, char *argv[] )
ITMDecoderGetStats( &_r.i )->tpiuSyncCount = 0;
}
}

if ( options.paceDelay )
{
usleep( options.paceDelay );
}
}

stream->close( stream );
Expand Down

0 comments on commit 4a13f87

Please sign in to comment.