Skip to content

Commit

Permalink
Start of V2.00 solidification
Browse files Browse the repository at this point in the history
  • Loading branch information
mubes committed May 27, 2022
1 parent 17790f5 commit 6228fbd
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 79 deletions.
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Version 1.20 in Progress
Version 2.00 in Progress

* Various fixes in orbmortem for reliability and performance
* Improve timing of orbuculum mux to ensure data get flushed to orbmortem on crash
* Version bumped to 2.00 in Progress because of size and impact of changes
* Addition of `orbprofile` for ETM profiling and integration with {k/q}cachegrind, see https://github.com/KDE/kcachegrind.
* Addition of `orbmortem` for ETM/ETB post-mortem analysis.
* Licenses updated to use SPDX identifiers...the license itself hasn't changed, we just lost a chunk of text at the head of every file, with the license now in the LICENSE file.
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Build configuration
VERBOSE?=0
DEBUG=1
#DEBUG=1
SCREEN_HANDLING=1
#MAKE_EXPERIMENTAL=1

# Set your preferred screen colours here, or create a new palette by copying the file to a new one
SCREEN_PALETTE="uicolours_default.h"
#SCREEN_PALETTE="uicolours_mono.h"

CFLAGS=-DVERSION="\"1.20InProgress\""
CFLAGS=-DVERSION="\"2.00Solidifying\""

CROSS_COMPILE=
# Output Files
Expand All @@ -20,8 +21,12 @@ ORBDUMP = orbdump
ORBSTAT = orbstat
ORBMORTEM = orbmortem
ORBPROFILE= orbprofile
ORBTRACE = orbtrace

ifdef MAKE_EXPERIMENTAL
ORBTRACE = orbtrace
else
ORBTRACE =
endif
##########################################################################
# Check Host OS
##########################################################################
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* Latest Changes:

This is the development branch for V1.20. ORBTrace (the FPGA trace interface) has now been moved into its own separate repository as it's grown considerably and really needs its own identity. History for orbtrace until the split point is maintained here for provenance purposes, but new work is now done over in the new location.
This is the development branch for V2.00 which includes parallel trace support as well as all the SWO goodness that Orbuculum has always offered. ORBTrace (the FPGA trace interface) has now been moved into its own separate repository as it's grown considerably and really needs its own identity. History for orbtrace until the split point is maintained here for provenance purposes, but new work is now done over in the new location.

The CHANGES file now tells you what's been done when.

Expand Down Expand Up @@ -515,9 +515,9 @@ The command line options of note are;

`-c [command]`: Set command line for external editor (0.000000 = filename, % = line). A few examples are;

* emacs; `-c emacs "+%l %f"`
* codium/VSCode: `-c codium -g "%f:%l"`
* eclipse: `-c eclipse "%f:%l"`
* emacs; `-c emacs "+%l %f"`
* codium/VSCode; `-c codium -g "%f:%l"`
* eclipse; `-c eclipse "%f:%l"`
`-D`: Switch off C++ symbol demangling

Expand All @@ -529,7 +529,7 @@ The command line options of note are;

`-f [filename]`: Take input from specified file rather than live from a probe (useful for ETB decode)

`-s [Server:Port]: to use
`-s [Server:Port]`: to use

`-t [channel]`: Use TPIU to strip TPIU on specfied channel (normally best to let `orbuculum` handle this

Expand Down
2 changes: 2 additions & 0 deletions Src/etmDecoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,8 @@ void ETMDecoderForceSync( struct ETMDecoder *i, bool isSynced )
if ( !isSynced )
{
i->stats.lostSyncCount++;
i->asyncCount = 0;
i->rxedISYNC = false;
i->p = ETM_UNSYNCED;
}
}
Expand Down
3 changes: 2 additions & 1 deletion Src/ext_fileformats.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static int _calls_src_sort_fn( const void *a, const void *b )
return ( int )( ( ( struct subcall * )a )->dsth->functionindex ) - ( int )( ( ( struct subcall * )b )->dsth->functionindex );
}
// ====================================================================================================
#if 0 // Not used for now, but left here in case its useful later...
static int _calls_dst_sort_fn( const void *a, const void *b )

/* Sort instructions by called to address */
Expand All @@ -55,7 +56,7 @@ static int _calls_dst_sort_fn( const void *a, const void *b )

return ( int )( ( ( struct subcall * )a )->srch->functionindex ) - ( int )( ( ( struct subcall * )b )->srch->functionindex );
}

#endif
// ====================================================================================================
// ====================================================================================================
// ====================================================================================================
Expand Down
16 changes: 9 additions & 7 deletions Src/orbcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,12 +633,14 @@ int main( int argc, char *argv[] )
exit( fileFeeder() );
}

do {
int rc = socketFeeder();
// TODO - make logging of failures/reconnections "nicer" based on rc?
(void)rc;
// tradeoff to re-attach "promptly" vs CPU spinning and log spam
usleep(100*1000);
} while (!options.endTerminate);
do
{
int rc = socketFeeder();
// TODO - make logging of failures/reconnections "nicer" based on rc?
( void )rc;
// tradeoff to re-attach "promptly" vs CPU spinning and log spam
usleep( 100 * 1000 );
}
while ( !options.endTerminate );
}
// ====================================================================================================
89 changes: 48 additions & 41 deletions Src/orbmortem.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define MAX_TAGS (10) /* How many tags we will allow */

#define INTERVAL_TIME_MS (1000) /* Intervaltime between acculumator resets */
#define HANG_TIME_MS (490) /* Time without a packet after which we dump the buffer */
#define HANG_TIME_MS (990) /* Time without a packet after which we dump the buffer */
#define TICK_TIME_MS (100) /* Time intervals for screen updates and keypress check */

/* Record for options, either defaults or from command line */
Expand Down Expand Up @@ -124,8 +124,8 @@ struct RunTime
/* For opening the editor (Shift-Right-Arrow) the following command lines work for a few editors;
*
* emacs; -c "emacs +%l %f"
* codium: -c "codium -g %f:%l"
* eclipse: -c "eclipse %f:%l"
* codium; -c "codium -g %f:%l"
* eclipse; -c "eclipse %f:%l"
*/

// ====================================================================================================
Expand Down Expand Up @@ -162,6 +162,7 @@ static void _printHelp( struct RunTime *r )
genericsPrintf( " -t <channel>: Use TPIU to strip TPIU on specfied channel" EOL );
genericsPrintf( " -v: <level> Verbose mode 0(errors)..3(debug)" EOL );
genericsPrintf( EOL "(Will connect one port higher than that set in -s when TPIU is not used)" EOL );
genericsPrintf( EOL "(this will automatically select the second output stream from orb TPIU.)" EOL );
genericsPrintf( EOL "Environment Variables;" EOL );
genericsPrintf( " OBJDUMP: to use non-standard obbdump binary" EOL );
}
Expand Down Expand Up @@ -359,16 +360,13 @@ static void _processBlock( struct RunTime *r )
r->held = true;
return;
}
}
else
{
r->wp = nwp;
else
{
r->rp = ( r->rp + 1 ) % r->options->buflen;
}
}

if ( r->wp == r->rp )
{
r->rp++;
}
r->wp = nwp;
}
}
}
Expand All @@ -389,16 +387,13 @@ static void _processBlock( struct RunTime *r )
r->held = true;
return;
}
}
else
{
r->wp = nwp;
else
{
r->rp = ( r->rp + 1 ) % r->options->buflen;
}
}

if ( r->wp == r->rp )
{
r->rp++;
}
r->wp = nwp;
}
}
}
Expand All @@ -425,6 +420,12 @@ static void _flushBuffer( struct RunTime *r )
free( r->opText );
r->opText = NULL;
r->numLines = 0;

/* ...and the file/line references */
r->op.currentLine = NO_LINE;
r->op.currentFileindex = NO_FILE;
r->op.currentFunctionindex = NO_FUNCTION;
r->op.workingAddr = NO_DESTADDRESS;
}
// ====================================================================================================
static void _appendToOPBuffer( struct RunTime *r, int32_t lineno, enum LineType lt, const char *fmt, ... )
Expand Down Expand Up @@ -592,34 +593,34 @@ static void _etmCB( void *d )
r->op.currentLine = n.line - n.linesInBlock + 1;
*construct = 0;

while ( *v )
{
/* In buffer output NL/CR are treated as end of string, so this is safe */
/* with these buffers that can span multiple lines. Split into separate ones. */
_appendRefToOPBuffer( r, r->op.currentLine++, LT_SOURCE, v );

/* Move to the CR/NL or EOL on this line */
while ( ( *v ) && ( *v != '\r' ) && ( *v != '\n' ) )
if ( v ) while ( *v )
{
v++;
}
/* In buffer output NL/CR are treated as end of string, so this is safe */
/* with these buffers that can span multiple lines. Split into separate ones. */
_appendRefToOPBuffer( r, r->op.currentLine++, LT_SOURCE, v );

if ( *v )
{
/* Found end of string or NL/CR...move past those */
if ( ( ( *v == '\r' ) && ( *( v + 1 ) == '\n' ) ) ||
( ( *v == '\n' ) && ( *( v + 1 ) == '\r' ) )
)
/* Move to the CR/NL or EOL on this line */
while ( ( *v ) && ( *v != '\r' ) && ( *v != '\n' ) )
{
v += 2;
v++;
}
else

if ( *v )
{
v++;
/* Found end of string or NL/CR...move past those */
if ( ( ( *v == '\r' ) && ( *( v + 1 ) == '\n' ) ) ||
( ( *v == '\n' ) && ( *( v + 1 ) == '\r' ) )
)
{
v += 2;
}
else
{
v++;
}
}
}

}
}
}

/* If this line has assembly then output it */
Expand Down Expand Up @@ -676,11 +677,17 @@ static void _dumpBuffer( struct RunTime *r )
/* Pump the received messages through the ETM decoder, it will callback to _etmCB with complete sentences */
int bytesAvailable = ( ( r->wp + r->options->buflen ) - r->rp ) % r->options->buflen;

/* If we've started wrapping (i.e. the rx ring buffer is full) then any guesses about sync status are invalid */
if ( bytesAvailable == r->options->buflen - 1 )
{
ETMDecoderForceSync( &r->i, false );
}

if ( ( bytesAvailable + r->rp ) > r->options->buflen )
{
/* Buffer is wrapped - submit both parts */
ETMDecoderPump( &r->i, &r->pmBuffer[r->rp], r->options->buflen - r->rp, _etmCB, r );
ETMDecoderPump( &r->i, &r->pmBuffer[0], r->rp, _etmCB, r );
ETMDecoderPump( &r->i, &r->pmBuffer[0], r->wp, _etmCB, r );
}
else
{
Expand Down
37 changes: 19 additions & 18 deletions Src/orbprofile.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ static void _checkJumps( struct RunTime *r )
if ( r->op.h )
{

if ( ( ETMStateChanged( &r->i, EV_CH_EX_EXIT ) ) || ( r->op.h->isReturn ) )
if ( ( ETMStateChanged( &r->i, EV_CH_EX_EXIT ) ) || ( r->op.h->isReturn ) )
{
_returnEvent( r, r->op.workingAddr );
}
Expand Down Expand Up @@ -379,6 +379,7 @@ static void _etmCB( void *d )
r->op.inth->functionindex = INTERRUPT;
HASH_ADD_INT( r->insthead, addr, r->op.inth );
}

r->op.lasttstamp = cpu->instCount;

/* Pull changes introduced by this event ============================== */
Expand All @@ -399,25 +400,25 @@ static void _etmCB( void *d )
_handleInstruction( r, disposition & 1 );

if ( ( r->op.h->isJump ) || ( r->op.h->isSubCall ) || ( r->op.h->isReturn ) )
{
{
if ( ETMStateChanged( &r->i, EV_CH_ADDRESS ) )
{
printf("New addr %08x" EOL,cpu->addr);
{
printf( "New addr %08x" EOL, cpu->addr );
r->op.workingAddr = cpu->addr;
}
}

_checkJumps( r );
}
}
}
}

if ( ETMStateChanged( &r->i, EV_CH_ADDRESS ) )
{
if ( ETMStateChanged( &r->i, EV_CH_EX_ENTRY ))
{
printf("INTERRUPT!!" EOL);
{
if ( ETMStateChanged( &r->i, EV_CH_EX_ENTRY ) )
{
printf( "INTERRUPT!!" EOL );
_callEvent( r, r->op.workingAddr, cpu->addr );
}
}

r->op.workingAddr = cpu->addr;
printf( "A:%08x" EOL, cpu->addr );
Expand Down Expand Up @@ -856,33 +857,33 @@ int main( int argc, char *argv[] )

if ( HASH_COUNT( _r.subhead ) )
{
if ( ext_ff_outputDot( _r.options->dotfile, _r.subhead, _r.s ) )
if ( ext_ff_outputDot( _r.options->dotfile, _r.subhead, _r.s ) )
{
genericsReport( V_INFO, "Output DOT" EOL );
}
else
{
if ( _r.options->dotfile )
if ( _r.options->dotfile )
{
genericsExit( -1, "Failed to output DOT" EOL );
genericsExit( -1, "Failed to output DOT" EOL );
}
}

if ( ext_ff_outputProfile( _r.options->profile, _r.options->elffile,
if ( ext_ff_outputProfile( _r.options->profile, _r.options->elffile,
_r.options->truncateDeleteMaterial ? _r.options->deleteMaterial : NULL,
true,
_r.op.lasttstamp - _r.op.firsttstamp,
_r.insthead,
_r.subhead,
_r.s ) )
_r.s ) )
{
genericsReport( V_INFO, "Output Profile" EOL );
}
else
{
if ( _r.options->profile )
if ( _r.options->profile )
{
genericsExit( -1, "Failed to output profile" EOL );
genericsExit( -1, "Failed to output profile" EOL );
}
}
}
Expand Down
Loading

0 comments on commit 6228fbd

Please sign in to comment.