diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 63aba6dea42..e08766b9c77 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -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 diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIInstruction.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIInstruction.java index 50cdcbaac36..e98a1f48b3f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIInstruction.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/ICDIInstruction.java @@ -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 diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java index f53065f3721..db7c8e0a061 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java @@ -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(); diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index 4ea5d37199f..992d5ecaad0 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -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 diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Instruction.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Instruction.java index 9b435bb6425..af1b15fedb8 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Instruction.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/Instruction.java @@ -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(); + } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIAsm.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIAsm.java index d7332a0ace9..12bc62f81ad 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIAsm.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIAsm.java @@ -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; + } }