From 6315e787d9d0dae87f3aed6bc4502de254a2c552 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Thu, 29 Aug 2024 18:29:33 +0100 Subject: [PATCH] Rebase of cobs on main and minor fixups --- Inc/nwclient.h | 2 +- Src/nwclient.c | 5 +---- Src/orbcat.c | 6 +++--- Src/orbdump.c | 6 +----- Src/orbfifo.c | 26 -------------------------- Src/orbmortem.c | 2 ++ Src/orbprofile.c | 17 ----------------- Src/orbtop.c | 4 ++-- Src/orbtraceIf.c | 3 ++- Src/orbuculum.c | 15 ++------------- Src/symbols.c | 1 - meson.build | 5 +++++ 12 files changed, 19 insertions(+), 73 deletions(-) diff --git a/Inc/nwclient.h b/Inc/nwclient.h index 38d74014..3b21ffbd 100644 --- a/Inc/nwclient.h +++ b/Inc/nwclient.h @@ -23,7 +23,7 @@ struct nwclientsHandle; // ==================================================================================================== -void nwclientSend( struct nwclientsHandle *h, uint32_t len, const uint8_t *ipbuffer, bool unlimWait ); +void nwclientSend( struct nwclientsHandle *h, uint32_t len, const uint8_t *ipbuffer ); void nwclientShutdown( struct nwclientsHandle *h ); struct nwclientsHandle *nwclientStart( int port ); diff --git a/Src/nwclient.c b/Src/nwclient.c index f666d862..085c7f21 100644 --- a/Src/nwclient.c +++ b/Src/nwclient.c @@ -52,7 +52,6 @@ struct nwclientsHandle { - volatile struct nwClient *firstClient; /* Head of linked list of network clients */ pthread_mutex_t clientList; /* Lock for list of network clients */ @@ -213,10 +212,9 @@ static void *_listenTask( void *arg ) // ==================================================================================================== // ==================================================================================================== // ==================================================================================================== -void nwclientSend( struct nwclientsHandle *h, uint32_t len, const uint8_t *ipbuffer, bool unlimWait ) +void nwclientSend( struct nwclientsHandle *h, uint32_t len, const uint8_t *ipbuffer ) { - ssize_t sent = 0; const struct timespec ts = {.tv_sec = 1, .tv_nsec = 0}; if ( h && h->firstClient ) @@ -257,7 +255,6 @@ void nwclientSend( struct nwclientsHandle *h, uint32_t len, const uint8_t *ipbuf pthread_mutex_unlock( &h->clientList ); } } - // ==================================================================================================== struct nwclientsHandle *nwclientStart( int port ) diff --git a/Src/orbcat.c b/Src/orbcat.c index 1f9d5fbc..0ec81c1a 100644 --- a/Src/orbcat.c +++ b/Src/orbcat.c @@ -38,7 +38,7 @@ #define ONE_SEC_IN_USEC (1000000) /* Used for time conversions...usec in one sec */ /* Formats for timestamping */ -#define REL_FORMAT "%6" PRIu64 ".%03" PRIu64 "|" +#define REL_FORMAT "%6" PRIu64 ".%01" PRIu64 "|" #define REL_FORMAT_INIT " Initial|" #define DEL_FORMAT "%3" PRIu64 ".%03" PRIu64 "|" #define DEL_FORMAT_CTD " +|" @@ -115,7 +115,7 @@ struct #define DWT_TO_US (100000L) // ==================================================================================================== -uint64_t _timestamp( void ) +int64_t _timestamp( void ) { struct timeval te; @@ -827,7 +827,7 @@ bool _processOptions( int argc, char *argv[] ) chan = atoi( optarg ); - if ( !chan || ( chan >= NUM_CHANNELS ) ) + if ( chan >= NUM_CHANNELS ) { genericsReport( V_ERROR, "Channel index out of range" EOL ); return false; diff --git a/Src/orbdump.c b/Src/orbdump.c index 9a5f8d70..ef810296 100644 --- a/Src/orbdump.c +++ b/Src/orbdump.c @@ -435,7 +435,7 @@ int main( int argc, char *argv[] ) TPIUDecoderInit( &_r.t ); ITMDecoderInit( &_r.i, options.forceITMSync ); OFLOWInit( &_r.c ); - struct Stream *stream = _tryOpenStream(); + stream = _tryOpenStream(); /* This ensures the signal handler gets called */ if ( SIG_ERR == signal( SIGINT, _intHandler ) ) @@ -455,8 +455,6 @@ int main( int argc, char *argv[] ) genericsReport( V_INFO, "Connected" EOL ); alreadyReported = false; } - - break; } if ( !alreadyReported ) @@ -469,8 +467,6 @@ int main( int argc, char *argv[] ) usleep( 10000 ); } - - /* .... and the file to dump it into */ opFile = fopen( options.outfile, "wb" ); diff --git a/Src/orbfifo.c b/Src/orbfifo.c index 3c10f5fc..c09328cf 100644 --- a/Src/orbfifo.c +++ b/Src/orbfifo.c @@ -174,31 +174,6 @@ static bool _processOptions( int argc, char *argv[] ) options.permafile = true; break; - // ------------------------------------ - case 's': - options.server = optarg; - - // See if we have an optional port number too - char *a = optarg; - - while ( ( *a ) && ( *a != ':' ) ) - { - a++; - } - - if ( *a == ':' ) - { - *a = 0; - options.port = atoi( ++a ); - } - - if ( !options.port ) - { - options.port = NWCLIENT_SERVER_PORT; - } - - break; - // ------------------------------------ case 'p': @@ -454,7 +429,6 @@ static void _doExit( void ) { _r.ending = true; itmfifoShutdown( _r.f ); - /* Give them a bit of time, then we're leaving anyway */ usleep( 200 ); } diff --git a/Src/orbmortem.c b/Src/orbmortem.c index ac97eb31..fe480a40 100644 --- a/Src/orbmortem.c +++ b/Src/orbmortem.c @@ -199,6 +199,8 @@ static void _printHelp( const char *const progName ) genericsPrintf( " -V, --version: Print version and exit" EOL ); genericsPrintf( EOL "(Will connect one port higher than that set in -s when TPIU is not used)" EOL ); genericsPrintf( "(this will automatically select the second output stream from orb TPIU.)" EOL ); + genericsPrintf( EOL "Environment Variables;" EOL ); + genericsPrintf( " OBJDUMP: to use non-standard objdump binary" EOL ); } // ==================================================================================================== void _printVersion( void ) diff --git a/Src/orbprofile.c b/Src/orbprofile.c index 333d796f..78593d1c 100644 --- a/Src/orbprofile.c +++ b/Src/orbprofile.c @@ -115,7 +115,6 @@ struct RunTime /* Subsystem data support */ struct TRACEDecoder i; - struct TPIUDecoder t; struct SymbolSet *s; /* Symbols read from elf */ struct OFLOW c; @@ -364,14 +363,6 @@ static void _traceCB( void *d ) static uint32_t incAddr = 0; static uint32_t disposition = 0; - if ( TRACEStateChanged( &r->i, EV_CH_ADDRESS ) ) - { - printf( EOL "Address 0x%08lx" EOL, r->i.cpu.addr ); - } - - TRACEStateChanged( &r->i, 0xffffffff ); - return; - /* This routine gets called when valid data are available */ /* if these are the first data, then reset counters etc. */ if ( !r->sampling ) @@ -511,7 +502,6 @@ static struct option _longOptions[] = {"trace-proto", required_argument, NULL, 'P'}, {"protocol", required_argument, NULL, 'p'}, {"server", required_argument, NULL, 's'}, - {"tpiu", required_argument, NULL, 't'}, {"all-truncate", no_argument, NULL, 'T'}, {"tag", required_argument, NULL, 't'}, {"verbose", required_argument, NULL, 'v'}, @@ -661,13 +651,6 @@ static bool _processOptions( int argc, char *argv[], struct RunTime *r ) break; // ------------------------------------ - case 't': - r->options->useTPIU = true; - r->options->channel = atoi( optarg ); - break; - - // ------------------------------------ - case 'v': if ( !isdigit( *optarg ) ) { diff --git a/Src/orbtop.c b/Src/orbtop.c index be57b797..e2473067 100644 --- a/Src/orbtop.c +++ b/Src/orbtop.c @@ -362,7 +362,7 @@ void _handleSW( struct ITMDecoder *i, struct ITMPacket *p ) // Outputter routines // ==================================================================================================== // ==================================================================================================== -uint32_t _consolidateReport( struct reportLine **returnReport, uint32_t *returnReportLines ) +uint32_t _consolodateReport( struct reportLine **returnReport, uint32_t *returnReportLines ) { struct nameEntry *n; @@ -1504,7 +1504,7 @@ int main( int argc, char *argv[] ) if ( receiveResult == RECEIVE_RESULT_TIMEOUT || remainTime <= 0 ) { /* Create the report that we will output */ - total = _consolidateReport( &report, &reportLines ); + total = _consolodateReport( &report, &reportLines ); if ( options.json ) { diff --git a/Src/orbtraceIf.c b/Src/orbtraceIf.c index e22f4805..602e4d80 100644 --- a/Src/orbtraceIf.c +++ b/Src/orbtraceIf.c @@ -272,7 +272,6 @@ void OrbtraceIfDestroyContext( struct OrbtraceIf *o ) } } // ==================================================================================================== - int OrbtraceIfGetDeviceList( struct OrbtraceIf *o, char *sn, uint32_t devmask ) /* Get list of devices that match (partial) serial number & devmask */ @@ -540,6 +539,8 @@ bool OrbtraceGetIfandEP( struct OrbtraceIf *o ) } /* Loop through the interfaces looking for ours */ + bool interface_found = false; + for ( int if_num = 0; if_num < config->bNumInterfaces && !interface_found; if_num++ ) { for ( int alt_num = 0; alt_num < config->interface[if_num].num_altsetting && !interface_found; alt_num++ ) diff --git a/Src/orbuculum.c b/Src/orbuculum.c index 7aba1c19..17d16266 100644 --- a/Src/orbuculum.c +++ b/Src/orbuculum.c @@ -59,10 +59,6 @@ #include "orbtraceIf.h" #include "stream.h" -#ifndef O_BINARY - #define O_BINARY 0 -#endif - #define MAX_LINE_LEN (1024) #define ORBTRACE "orbtrace" #define ORBTRACEENVNAME "ORBTRACE" @@ -489,7 +485,7 @@ bool _processOptions( int argc, char *argv[], struct RunTime *r ) case 'm': r->options->intervalReportTime = atoi( optarg ); - if ( r->options->intervalReportTime<500 ) + if ( r->options->intervalReportTime < 500 ) { genericsReport( V_ERROR, "intervalReportTime is out of range" EOL ); return false; @@ -698,12 +694,6 @@ bool _processOptions( int argc, char *argv[], struct RunTime *r ) return false; } - if ( ( r->options->useCOBS ) && ( r->options->useTPIU ) ) - { - genericsReport( V_ERROR, "Cannot specify COBS and TPIU at the same time" EOL ); - return false; - } - if ( ( r->options->port ) && ( r->options->nwserverPort ) ) { genericsReport( V_ERROR, "Cannot specify port and NW Server at same time" EOL ); @@ -1508,7 +1498,6 @@ static int _fileFeeder( struct RunTime *r ) genericsReport( V_INFO, "File read error" EOL ); } - usleep( INTERVAL_1S ); close( r->f ); return true; } @@ -1622,7 +1611,7 @@ int main( int argc, char *argv[] ) if ( _r.options->outfile ) { - _r.opFileHandle = open( _r.options->outfile, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH ); + _r.opFileHandle = open( _r.options->outfile, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH ); if ( _r.opFileHandle < 0 ) { diff --git a/Src/symbols.c b/Src/symbols.c index bd109d16..2158ef16 100644 --- a/Src/symbols.c +++ b/Src/symbols.c @@ -474,7 +474,6 @@ static enum symbolErr _getTargetProgramInfo( struct SymbolSet *s ) snprintf( commandLine, MAX_LINE_LEN, OBJDUMP " -Sl%s --source-comment=" SOURCE_INDICATOR " %s %s", s->demanglecpp ? " -C" : "", s->elfFile, s->odoptions ); } - printf( "\n\n%s\n\n", commandLine ); #if defined(WIN32) PROCESS_INFORMATION processInfo; FILE *errorOut; diff --git a/meson.build b/meson.build index 6a5a48df..b65f96d9 100644 --- a/meson.build +++ b/meson.build @@ -19,8 +19,13 @@ dependencies = [ ] incdirs = include_directories(['Inc', 'Inc/external']) +cc = meson.get_compiler('c') if host_machine.system() == 'windows' + winsock2 = cc.find_library('ws2_32') + dependencies += [ + winsock2 + ] elif host_machine.system() == 'darwin' add_project_arguments('-DOSX', language: 'c') elif host_machine.system() == 'freebsd'