1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Implementing the disassembly mode.

This commit is contained in:
Mikhail Khodjaiants 2002-10-10 15:29:50 +00:00
parent 16e22eb4b8
commit e01a121c1c
5 changed files with 48 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2002-10-10 Mikhail Khodjaiants
* CSourceManager.java: Implementing the disassembly mode.
* DisassemblyManager.java: Implementing the disassembly mode.
* DisassemblyStorage.java: Implementing the disassembly mode.
* CDebugUtils.java: Added the 'toHexAddressString' method.
2002-10-10 Alain Magloire 2002-10-10 Alain Magloire
* ICDISourceManager.java: Changing the getInstructions() * ICDISourceManager.java: Changing the getInstructions()

View file

@ -64,4 +64,17 @@ public class CDebugUtils
} }
} }
} }
public static String toHexAddressString( long address )
{
String addressString = Long.toHexString( address );
StringBuffer sb = new StringBuffer( 10 );
sb.append( "0x" );
for ( int i = 0; i < 8 - addressString.length(); ++i )
{
sb.append( '0' );
}
sb.append( addressString );
return sb.toString();
}
} }

View file

@ -62,6 +62,13 @@ public class DisassemblyStorage implements IDisassemblyStorage
*/ */
public int getLineNumber( long address ) public int getLineNumber( long address )
{ {
for ( int i = 0; i < fInstructions.length; ++i )
{
if ( fInstructions[i].getAdress() == address )
{
return i + 1;
}
}
return 0; return 0;
} }
@ -139,7 +146,7 @@ public class DisassemblyStorage implements IDisassemblyStorage
StringBuffer lines = new StringBuffer(); StringBuffer lines = new StringBuffer();
for ( int i = 0; i < fInstructions.length; ++i ) for ( int i = 0; i < fInstructions.length; ++i )
{ {
lines.append( fInstructions[i].toString() ); lines.append( getInstructionString( fInstructions[i] ) );
} }
fInputStream = new ByteArrayInputStream( lines.toString().getBytes() ); fInputStream = new ByteArrayInputStream( lines.toString().getBytes() );
} }
@ -158,6 +165,22 @@ public class DisassemblyStorage implements IDisassemblyStorage
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if ( instruction != null ) if ( instruction != null )
{ {
sb .append( CDebugUtils.toHexAddressString( instruction.getAdress() ) );
sb.append( ' ' );
if ( instruction.getFuntionName() != null && instruction.getFuntionName().length() > 0 )
{
sb.append( '<' );
sb.append( instruction.getFuntionName() );
if ( instruction.getOffset() != 0 )
{
sb.append( '+' );
sb.append( instruction.getOffset() );
}
sb.append( ">:" );
sb.append( '\t' );
}
sb.append( instruction.getInstruction() );
sb.append( '\n' );
} }
return sb.toString(); return sb.toString();
} }

View file

@ -52,6 +52,10 @@ public class CSourceManager implements ICSourceLocator, ISourceMode, IAdaptable
return frameInfo.getFrameLineNumber(); return frameInfo.getFrameLineNumber();
} }
} }
if ( getRealMode() == ISourceMode.MODE_DISASSEMBLY && getDisassemblyManager() != null )
{
return getDisassemblyManager().getLineNumber( frameInfo );
}
return 0; return 0;
} }

View file

@ -118,7 +118,7 @@ public class DisassemblyManager
{ {
try try
{ {
instructions = sm.getInstructions( "0x" + Long.toHexString( address ), "0x" + Long.toHexString( address + DISASSEMBLY_BLOCK_SIZE ) ); instructions = sm.getInstructions( address, address + DISASSEMBLY_BLOCK_SIZE );
} }
catch( CDIException e ) catch( CDIException e )
{ {