Skip to content

Commit

Permalink
Rebase of cobs on main and minor fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
mubes committed Aug 29, 2024
1 parent baba7a2 commit 6315e78
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 73 deletions.
2 changes: 1 addition & 1 deletion Inc/nwclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
5 changes: 1 addition & 4 deletions Src/nwclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )

Expand Down
6 changes: 3 additions & 3 deletions Src/orbcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 " +|"
Expand Down Expand Up @@ -115,7 +115,7 @@ struct
#define DWT_TO_US (100000L)

// ====================================================================================================
uint64_t _timestamp( void )
int64_t _timestamp( void )

{
struct timeval te;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions Src/orbdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) )
Expand All @@ -455,8 +455,6 @@ int main( int argc, char *argv[] )
genericsReport( V_INFO, "Connected" EOL );
alreadyReported = false;
}

break;
}

if ( !alreadyReported )
Expand All @@ -469,8 +467,6 @@ int main( int argc, char *argv[] )
usleep( 10000 );
}



/* .... and the file to dump it into */
opFile = fopen( options.outfile, "wb" );

Expand Down
26 changes: 0 additions & 26 deletions Src/orbfifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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 );
}
Expand Down
2 changes: 2 additions & 0 deletions Src/orbmortem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
17 changes: 0 additions & 17 deletions Src/orbprofile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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'},
Expand Down Expand Up @@ -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 ) )
{
Expand Down
4 changes: 2 additions & 2 deletions Src/orbtop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
{
Expand Down
3 changes: 2 additions & 1 deletion Src/orbtraceIf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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++ )
Expand Down
15 changes: 2 additions & 13 deletions Src/orbuculum.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 )
{
Expand Down
1 change: 0 additions & 1 deletion Src/symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 6315e78

Please sign in to comment.