From 736dbc1bec2e946f60c6260ce9e72020559b659e Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Fri, 11 Oct 2002 14:59:18 +0000 Subject: [PATCH] Changed the format of the disassembly view's output. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 3 ++ .../internal/core/DisassemblyStorage.java | 30 ++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 273e57e171b..5125b896131 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -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'. 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 f5049bb13ec..18145d8dfed 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 @@ -8,6 +8,7 @@ package org.eclipse.cdt.debug.internal.core; 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 @@ public class DisassemblyStorage implements IDisassemblyStorage 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 @@ public class DisassemblyStorage implements IDisassemblyStorage } } - 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 @@ public class DisassemblyStorage implements IDisassemblyStorage 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() ); + } }