[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] 1.0.1 Assembly View Fixups
|
Hi,
We had some issues with the assembly view. In particular, \t would show up
as \t rather than whitespace and arguments for the assembly were not lined
up in a smooth fashion making it hard to read.
The following patch, derived from 1.0.1, fixes these issues.
Thanks!
-Chris
diff -r -u
xide_compare/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIInstruction.java
xide/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIInstruction.java
---
xide_compare/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIInstruction.java
Wed Mar 26 17:38:45 2003
+++
xide/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIInstruction.java
Wed Mar 26 17:38:56 2003
@@ -31,6 +31,16 @@
String getInstruction();
/**
+ * @return the opcode
+ */
+ String getOpcode();
+
+ /**
+ * @return any arguments to the opcode
+ */
+ String getArgs();
+
+ /**
* Returns the instruction's offset.
*
* @return the offset of this machine instruction
diff -r -u
xide_compare/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java
xide/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java
---
xide_compare/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java
Wed Mar 26 17:38:45 2003
+++
xide/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java
Wed Mar 26 17:38:56 2003
@@ -146,6 +146,7 @@
{
StringBuffer lines = new StringBuffer();
int maxFunctionName = 0;
+ int maxOpcodeLength = 0;
long maxOffset = 0;
for ( int i = 0; i < fInstructions.length; ++i )
{
@@ -153,15 +154,21 @@
{
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 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() );
}
@@ -175,9 +182,11 @@
}
}
- 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 )
@@ -196,7 +205,9 @@
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();
diff -r -u
xide_compare/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Instruction.java
xide/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Instruction.java
---
xide_compare/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Instruction.java
Wed Mar 26 17:38:45 2003
+++
xide/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Instruction.java
Wed Mar 26 17:38:56 2003
@@ -38,7 +38,21 @@
public String getInstruction() {
return asm.getInstruction();
}
-
+
+ /**
+ * @see org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction#getOpcode()
+ */
+ public String getOpcode() {
+ return asm.getOpcode();
+ }
+
+ /**
+ * @see org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction#getOpcode()
+ */
+ public String getArgs() {
+ return asm.getArgs();
+ }
+
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction#getOffset()
*/
diff -r -u
xide_compare/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIAsm.java
xide/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIAsm.java
---
xide_compare/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIAsm.java
Wed Mar 26 17:38:45 2003
+++
xide/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIAsm.java
Wed Mar 26 17:38:56 2003
@@ -12,7 +12,8 @@
long address;
String function = "";
long offset;
- String instruction = "";
+ String opcode = "";
+ String args = "";
public MIAsm (MITuple tuple) {
parse(tuple);
@@ -31,7 +32,15 @@
}
public String getInstruction() {
- return instruction;
+ return opcode + " " + args;
+ }
+
+ public String getOpcode() {
+ return opcode;
+ }
+
+ public String getArgs() {
+ return args;
}
public String toString() {
@@ -40,7 +49,7 @@
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,7 +78,30 @@
} 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 );
}
}
}