Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Changed the format of the disassembly view's output.

Changed the format of the disassembly view's output.

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v
retrieving revision 1.7
diff -u -r1.7 ChangeLog
--- ChangeLog 10 Oct 2002 22:29:59 -0000 1.7
+++ ChangeLog 11 Oct 2002 14:58:12 -0000
@@ -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
  * CVariable.java: Made the 'fChanged' field protected to access to it from the derived class (CRegister).
  * CRegister.java: Added the 'hasValueChanged' method to 'CRegister'.
Index: src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java,v
retrieving revision 1.4
diff -u -r1.4 DisassemblyStorage.java
--- src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java 10 Oct 2002 15:29:50 -0000 1.4
+++ src/org/eclipse/cdt/debug/internal/core/DisassemblyStorage.java 11 Oct 2002 14:58:12 -0000
@@ -8,6 +8,7 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
+import java.util.Arrays;
 
 import org.eclipse.cdt.debug.core.IDisassemblyStorage;
 import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
@@ -144,9 +145,23 @@
  private void createContent()
  {
   StringBuffer lines = new StringBuffer();
+  int maxFunctionName = 0;
+  long maxOffset = 0;
   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() );
  }
@@ -160,12 +175,14 @@
   }
  }
  
- private String getInstructionString( ICDIInstruction instruction )
+ private String getInstructionString( ICDIInstruction instruction, int instrPosition )
  {
+  char[] spaces= new char[instrPosition];
+  Arrays.fill( spaces, ' ' );
   StringBuffer sb = new StringBuffer();
   if ( instruction != null )
   {
-   sb .append( CDebugUtils.toHexAddressString( instruction.getAdress() ) );
+   sb.append( CDebugUtils.toHexAddressString( instruction.getAdress() ) );
    sb.append( ' ' );
    if ( instruction.getFuntionName() != null && instruction.getFuntionName().length() > 0 )
    {
@@ -177,11 +194,16 @@
      sb.append( instruction.getOffset() );
     }
     sb.append( ">:" );
-    sb.append( '\t' );
+    sb.append( spaces, 0, instrPosition - sb.length() );
    }
    sb.append( instruction.getInstruction() );
    sb.append( '\n' );
   }
   return sb.toString();
+ }

+ private int calculateInstructionPosition( int maxFunctionName, long maxOffset )
+ {
+  return ( 16 + maxFunctionName + Long.toString( maxOffset ).length() );
  }
 }

Back to the top