1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-30 12:25:35 +02:00

Changed the format of the disassembly view's output.

This commit is contained in:
Mikhail Khodjaiants 2002-10-11 14:59:18 +00:00
parent a4401df722
commit 736dbc1bec
2 changed files with 29 additions and 4 deletions

View file

@ -1,3 +1,6 @@
2002-10-11 Mikhail Khodjaiants
* DisassemblyStorage.java: Changed the format of the disassembly view's output.
2002-10-10 Mikhail Khodjaiants 2002-10-10 Mikhail Khodjaiants
* CVariable.java: Made the 'fChanged' field protected to access to it from the derived class (CRegister). * CVariable.java: Made the 'fChanged' field protected to access to it from the derived class (CRegister).
* CRegister.java: Added the 'hasValueChanged' method to 'CRegister'. * CRegister.java: Added the 'hasValueChanged' method to 'CRegister'.

View file

@ -8,6 +8,7 @@ package org.eclipse.cdt.debug.internal.core;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.util.Arrays;
import org.eclipse.cdt.debug.core.IDisassemblyStorage; import org.eclipse.cdt.debug.core.IDisassemblyStorage;
import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction; import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
@ -144,9 +145,23 @@ public class DisassemblyStorage implements IDisassemblyStorage
private void createContent() private void createContent()
{ {
StringBuffer lines = new StringBuffer(); StringBuffer lines = new StringBuffer();
int maxFunctionName = 0;
long maxOffset = 0;
for ( int i = 0; i < fInstructions.length; ++i ) for ( int i = 0; i < fInstructions.length; ++i )
{ {
lines.append( getInstructionString( fInstructions[i] ) ); if ( fInstructions[i].getFuntionName().length() > maxFunctionName )
{
maxFunctionName = fInstructions[i].getFuntionName().length();
}
if ( fInstructions[i].getOffset() > maxOffset )
{
maxOffset = fInstructions[i].getOffset();
}
}
int instrPos = calculateInstructionPosition( maxFunctionName, maxOffset );
for ( int i = 0; i < fInstructions.length; ++i )
{
lines.append( getInstructionString( fInstructions[i], instrPos ) );
} }
fInputStream = new ByteArrayInputStream( lines.toString().getBytes() ); fInputStream = new ByteArrayInputStream( lines.toString().getBytes() );
} }
@ -160,12 +175,14 @@ public class DisassemblyStorage implements IDisassemblyStorage
} }
} }
private String getInstructionString( ICDIInstruction instruction ) private String getInstructionString( ICDIInstruction instruction, int instrPosition )
{ {
char[] spaces= new char[instrPosition];
Arrays.fill( spaces, ' ' );
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if ( instruction != null ) if ( instruction != null )
{ {
sb .append( CDebugUtils.toHexAddressString( instruction.getAdress() ) ); sb.append( CDebugUtils.toHexAddressString( instruction.getAdress() ) );
sb.append( ' ' ); sb.append( ' ' );
if ( instruction.getFuntionName() != null && instruction.getFuntionName().length() > 0 ) if ( instruction.getFuntionName() != null && instruction.getFuntionName().length() > 0 )
{ {
@ -177,11 +194,16 @@ public class DisassemblyStorage implements IDisassemblyStorage
sb.append( instruction.getOffset() ); sb.append( instruction.getOffset() );
} }
sb.append( ">:" ); sb.append( ">:" );
sb.append( '\t' ); sb.append( spaces, 0, instrPosition - sb.length() );
} }
sb.append( instruction.getInstruction() ); sb.append( instruction.getInstruction() );
sb.append( '\n' ); sb.append( '\n' );
} }
return sb.toString(); return sb.toString();
} }
private int calculateInstructionPosition( int maxFunctionName, long maxOffset )
{
return ( 16 + maxFunctionName + Long.toString( maxOffset ).length() );
}
} }