Skip to content

Commit

Permalink
Fix decode of atom type 6
Browse files Browse the repository at this point in the history
  • Loading branch information
mubes committed Feb 8, 2024
1 parent fb37008 commit b74b4e5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
26 changes: 16 additions & 10 deletions Src/loadelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ static void _processFunctionDie( struct symbol *p, Dwarf_Debug dbg, Dwarf_Die di

{
char *name = NULL;
char *manglename = NULL;
char *manglename = NULL;
Dwarf_Addr h = 0;
Dwarf_Addr l = 0;
enum Dwarf_Form_Class formclass = DW_FORM_CLASS_UNKNOWN;
Expand Down Expand Up @@ -386,11 +386,11 @@ static void _processFunctionDie( struct symbol *p, Dwarf_Debug dbg, Dwarf_Die di
specification_die = die;

/* Get the possibly mangled linkage name if it exists */
if ( DW_DLV_OK == dwarf_attr( die, DW_AT_linkage_name, &attr_data, 0) )
if ( DW_DLV_OK == dwarf_attr( die, DW_AT_linkage_name, &attr_data, 0 ) )
{
dwarf_formstring( attr_data, &manglename, 0 );
}

if ( DW_DLV_OK != dwarf_diename( die, &name, 0 ) )
{
/* Name will be hidden in a specification reference */
Expand All @@ -416,12 +416,16 @@ static void _processFunctionDie( struct symbol *p, Dwarf_Debug dbg, Dwarf_Die di
p->nfunc++;

newFunc->funcname = strdup( name );
newFunc->manglename= strdup( manglename );
newFunc->producer = producerN;
newFunc->filename = filenameN;
newFunc->lowaddr = l;
newFunc->highaddr = h - 1;

if ( manglename )
{
newFunc->manglename = strdup( manglename );
}

/* Collect start of function line and column */
attr_tag = DW_AT_decl_line;

Expand Down Expand Up @@ -710,11 +714,12 @@ static bool _loadSource( struct symbol *p )

/* Spin forwards for next newline or eof */
while ( ( --l > 0 ) && ( *r++ != '\n' ) ) {};
if (l)
{
*r++ = 0;
l--;
}

if ( l )
{
*r++ = 0;
l--;
}
}
}

Expand Down Expand Up @@ -1194,7 +1199,8 @@ bool _listFunctions( struct symbol *p, bool includeLines )

while ( f = symbolFunctionIndex( p, iter++ ) )
{
fprintf( stderr, MEMADDRF "..." MEMADDRF " %s ( %s %d,%d ) %s" EOL, f->lowaddr, f->highaddr, f->funcname, symbolGetFilename( p, f->filename ), f->startline, f->startcol, f->manglename?f->manglename:"" );
fprintf( stderr, MEMADDRF "..." MEMADDRF " %s ( %s %d,%d ) %s" EOL, f->lowaddr, f->highaddr, f->funcname, symbolGetFilename( p, f->filename ), f->startline, f->startcol,
f->manglename ? f->manglename : "" );

if ( includeLines )
{
Expand Down
7 changes: 3 additions & 4 deletions Src/orbmortem.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ 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 Expand Up @@ -905,7 +903,7 @@ static void _traceCB( void *d )
( ( !linearRun ) && ( r->i.protocol == TRACE_PROT_ETM4 ) && ( ( !( ic & LE_IC_JUMP ) ) || ( disposition & 1 ) ) ) ||

/* MTB case - a linear run to last address */
( ( linearRun ) &&
( ( linearRun ) && ( r->i.protocol == TRACE_PROT_MTB ) &&
( ( ( r->op.workingAddr != targetAddr ) && ( ! ( ic & LE_IC_JUMP ) ) ) ||
( r->op.workingAddr == targetAddr )
) ) );
Expand Down Expand Up @@ -944,6 +942,7 @@ static void _traceCB( void *d )
/* Update working address according to if jump was taken */
if ( ic & LE_IC_IMMEDIATE )
{
_traceReport( V_DEBUG, "Immediate address %8x", newaddr );
/* We have a good address, so update with it */
r->op.workingAddr = newaddr;
}
Expand Down Expand Up @@ -978,7 +977,7 @@ static void _traceCB( void *d )
}
else
{
_appendRefToOPBuffer( r, l, r->op.currentLine, LT_ASSEMBLY, "\t\tASSEMBLY NOT FOUND" EOL );
_appendToOPBuffer( r, l, r->op.currentLine, LT_ASSEMBLY, "%8x:\tASSEMBLY NOT FOUND" EOL, r->op.workingAddr );
r->op.workingAddr += 2;
disposition >>= 1;
incAddr--;
Expand Down
6 changes: 4 additions & 2 deletions Src/traceDecoder_etm4.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,13 @@ static bool _pumpAction( struct TRACEDecoderEngine *e, struct TRACECPUState *cpu
case 0b11100000 ... 0b11110100: /* Atom format 6, Figure 6-44, Pg 6.307 */
cpu->eatoms = ( c & 0x1f ) + 3;
cpu->instCount = cpu->eatoms;
cpu->disposition = ( 1 << ( cpu->eatoms + 1 ) ) - 1;
cpu->disposition = ( 1 << ( cpu->eatoms ) ) - 1;

/* Deal with last instruction to be executed */
if ( c & ( 1 << 5 ) )
{
cpu->disposition &= 0xfffffffe;
DEBUG( "Got a non-execute" );
cpu->disposition &= ~( 1 << ( cpu->eatoms - 1 ) );
cpu->eatoms--;
cpu->natoms = 1;
}
Expand Down

0 comments on commit b74b4e5

Please sign in to comment.