mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Applied patch from Chris Songer: Assembly View Fixups
This commit is contained in:
parent
7134b93779
commit
4c7265d240
6 changed files with 92 additions and 11 deletions
|
@ -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
|
||||
|
||||
Adjust the code refactor in the CoreModel for IBinary
|
||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.debug.core.cdi.model;
|
|||
*/
|
||||
public interface ICDIInstruction extends ICDIObject {
|
||||
/**
|
||||
* Returns the Address.
|
||||
* Returns the Address.
|
||||
* @return the address.
|
||||
*/
|
||||
long getAdress();
|
||||
|
@ -28,8 +28,19 @@ public interface ICDIInstruction extends ICDIObject {
|
|||
* @return the instruction.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return the offset of this machine instruction
|
||||
|
|
|
@ -150,6 +150,7 @@ public class DisassemblyStorage implements IDisassemblyStorage
|
|||
{
|
||||
StringBuffer lines = new StringBuffer();
|
||||
int maxFunctionName = 0;
|
||||
int maxOpcodeLength = 0;
|
||||
long maxOffset = 0;
|
||||
for ( int i = 0; i < fInstructions.length; ++i )
|
||||
{
|
||||
|
@ -157,15 +158,21 @@ public class DisassemblyStorage implements IDisassemblyStorage
|
|||
{
|
||||
maxFunctionName = fInstructions[i].getFuntionName().length();
|
||||
}
|
||||
|
||||
String opcode = fInstructions[i].getOpcode();
|
||||
if ( opcode.length() > maxOpcodeLength )
|
||||
maxOpcodeLength = opcode.length();
|
||||
|
||||
if ( fInstructions[i].getOffset() > maxOffset )
|
||||
{
|
||||
maxOffset = fInstructions[i].getOffset();
|
||||
}
|
||||
}
|
||||
int instrPos = calculateInstructionPosition( maxFunctionName, maxOffset );
|
||||
int argPosition = instrPos + maxOpcodeLength + 1;
|
||||
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() );
|
||||
}
|
||||
|
@ -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, ' ' );
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if ( instruction != null )
|
||||
|
@ -200,7 +208,9 @@ public class DisassemblyStorage implements IDisassemblyStorage
|
|||
sb.append( ">:" );
|
||||
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' );
|
||||
}
|
||||
return sb.toString();
|
||||
|
|
|
@ -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
|
||||
|
||||
Some applications, like recursive code, have a very deep stackframes
|
||||
|
|
|
@ -47,4 +47,17 @@ public class Instruction extends CObject implements ICDIInstruction {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,9 @@ package org.eclipse.cdt.debug.mi.core.output;
|
|||
public class MIAsm {
|
||||
long address;
|
||||
String function = "";
|
||||
String opcode = "";
|
||||
String args = "";
|
||||
long offset;
|
||||
String instruction = "";
|
||||
|
||||
public MIAsm (MITuple tuple) {
|
||||
parse(tuple);
|
||||
|
@ -31,7 +32,7 @@ public class MIAsm {
|
|||
}
|
||||
|
||||
public String getInstruction() {
|
||||
return instruction;
|
||||
return opcode + " " + args;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
@ -40,7 +41,7 @@ public class MIAsm {
|
|||
buffer.append("address=\"" + Long.toHexString(address) +"\"");
|
||||
buffer.append(",func-name=\"" + function + "\"");
|
||||
buffer.append(",offset=\"").append(offset).append('"');
|
||||
buffer.append(",inst=\"" + instruction + "\"");
|
||||
buffer.append(",inst=\"" + getInstruction() + "\"");
|
||||
buffer.append('}');
|
||||
return buffer.toString();
|
||||
}
|
||||
|
@ -69,8 +70,44 @@ public class MIAsm {
|
|||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue