1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Applied patch from Chris Songer: Assembly View Fixups

This commit is contained in:
Mikhail Khodjaiants 2003-03-27 22:47:11 +00:00
parent 7134b93779
commit 4c7265d240
6 changed files with 92 additions and 11 deletions

View file

@ -1,3 +1,8 @@
2003-03-27 Mikhail Khodjaiants
Applied patch from Chris Songer: Assembly View Fixups
* ICDIInstruction.java
* DisassemblyStorage.java
2003-03027 Alain Magloire 2003-03027 Alain Magloire
Adjust the code refactor in the CoreModel for IBinary Adjust the code refactor in the CoreModel for IBinary

View file

@ -30,6 +30,17 @@ public interface ICDIInstruction extends ICDIObject {
String getInstruction(); String getInstruction();
/** /**
* @return the opcode
*/
String getOpcode();
/**
* @return any arguments to the opcode
*/
String getArgs();
/**
* @return the offset of this machine instruction
* Returns the instruction's offset. * Returns the instruction's offset.
* *
* @return the offset of this machine instruction * @return the offset of this machine instruction

View file

@ -150,6 +150,7 @@ public class DisassemblyStorage implements IDisassemblyStorage
{ {
StringBuffer lines = new StringBuffer(); StringBuffer lines = new StringBuffer();
int maxFunctionName = 0; int maxFunctionName = 0;
int maxOpcodeLength = 0;
long maxOffset = 0; long maxOffset = 0;
for ( int i = 0; i < fInstructions.length; ++i ) for ( int i = 0; i < fInstructions.length; ++i )
{ {
@ -157,15 +158,21 @@ public class DisassemblyStorage implements IDisassemblyStorage
{ {
maxFunctionName = fInstructions[i].getFuntionName().length(); maxFunctionName = fInstructions[i].getFuntionName().length();
} }
String opcode = fInstructions[i].getOpcode();
if ( opcode.length() > maxOpcodeLength )
maxOpcodeLength = opcode.length();
if ( fInstructions[i].getOffset() > maxOffset ) if ( fInstructions[i].getOffset() > maxOffset )
{ {
maxOffset = fInstructions[i].getOffset(); maxOffset = fInstructions[i].getOffset();
} }
} }
int instrPos = calculateInstructionPosition( maxFunctionName, maxOffset ); int instrPos = calculateInstructionPosition( maxFunctionName, maxOffset );
int argPosition = instrPos + maxOpcodeLength + 1;
for ( int i = 0; i < fInstructions.length; ++i ) for ( int i = 0; i < fInstructions.length; ++i )
{ {
lines.append( getInstructionString( fInstructions[i], instrPos ) ); lines.append( getInstructionString( fInstructions[i], instrPos, argPosition ) );
} }
fInputStream = new ByteArrayInputStream( lines.toString().getBytes() ); fInputStream = new ByteArrayInputStream( lines.toString().getBytes() );
} }
@ -179,9 +186,10 @@ public class DisassemblyStorage implements IDisassemblyStorage
} }
} }
private String getInstructionString( ICDIInstruction instruction, int instrPosition ) private String getInstructionString( ICDIInstruction instruction, int instrPosition, int argPosition )
{ {
char[] spaces= new char[instrPosition]; int worstCaseSpace = Math.max( instrPosition, argPosition );
char[] spaces= new char[worstCaseSpace];
Arrays.fill( spaces, ' ' ); Arrays.fill( spaces, ' ' );
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
if ( instruction != null ) if ( instruction != null )
@ -200,7 +208,9 @@ public class DisassemblyStorage implements IDisassemblyStorage
sb.append( ">:" ); sb.append( ">:" );
sb.append( spaces, 0, instrPosition - sb.length() ); sb.append( spaces, 0, instrPosition - sb.length() );
} }
sb.append( instruction.getInstruction() ); sb.append( instruction.getOpcode() );
sb.append( spaces, 0, argPosition - sb.length() );
sb.append( instruction.getArgs() );
sb.append( '\n' ); sb.append( '\n' );
} }
return sb.toString(); return sb.toString();

View file

@ -1,3 +1,8 @@
2003-03-27 Mikhail Khodjaiants
Applied patch from Chris Songer: Assembly View Fixups
* Instruction.java
* MIAsm.java
2003-03-19 Alain Magloire 2003-03-19 Alain Magloire
Some applications, like recursive code, have a very deep stackframes Some applications, like recursive code, have a very deep stackframes

View file

@ -47,4 +47,17 @@ public class Instruction extends CObject implements ICDIInstruction {
return asm.getOffset(); return asm.getOffset();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction#getArgs()
*/
public String getArgs() {
return asm.getArgs();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction#getOpcode()
*/
public String getOpcode() {
return asm.getOpcode();
}
} }

View file

@ -11,8 +11,9 @@ package org.eclipse.cdt.debug.mi.core.output;
public class MIAsm { public class MIAsm {
long address; long address;
String function = ""; String function = "";
String opcode = "";
String args = "";
long offset; long offset;
String instruction = "";
public MIAsm (MITuple tuple) { public MIAsm (MITuple tuple) {
parse(tuple); parse(tuple);
@ -31,7 +32,7 @@ public class MIAsm {
} }
public String getInstruction() { public String getInstruction() {
return instruction; return opcode + " " + args;
} }
public String toString() { public String toString() {
@ -40,7 +41,7 @@ public class MIAsm {
buffer.append("address=\"" + Long.toHexString(address) +"\""); buffer.append("address=\"" + Long.toHexString(address) +"\"");
buffer.append(",func-name=\"" + function + "\""); buffer.append(",func-name=\"" + function + "\"");
buffer.append(",offset=\"").append(offset).append('"'); buffer.append(",offset=\"").append(offset).append('"');
buffer.append(",inst=\"" + instruction + "\""); buffer.append(",inst=\"" + getInstruction() + "\"");
buffer.append('}'); buffer.append('}');
return buffer.toString(); return buffer.toString();
} }
@ -69,8 +70,44 @@ public class MIAsm {
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
} else if (var.equals("inst")) { } else if (var.equals("inst")) {
instruction = str; /* for the instruction, we do not want the C string but the
translated string since the only thing we are doing is
displaying it. */
str = ((MIConst)value).getString();
char chars[] = str.toCharArray();
int index = 0;
// count the non-whitespace characters.
while( (index < chars.length) && (chars[index] > '\u0020'))
index++;
// guard all whitespace
if( index < chars.length )
opcode = str.substring( 0, index );
// skip any whitespace characters
while( index < chars.length && chars[index] >= '\u0000' && chars[index] <= '\u0020')
index++;
// guard no argument
if( index < chars.length )
args = str.substring( index );
} }
} }
} }
/**
* @return String
*/
public String getArgs() {
return args;
}
/**
* @return String
*/
public String getOpcode() {
return opcode;
}
} }