diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 479d836d8aa..47b73508157 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,11 @@ +2004-09-21 Mikhail Khodjaiants + Fixed the problems with the Disassembly view and address breakpoints caused by switch to IAddress. + * CBreakpointManager.java + * AsmInstruction.java + * Disassembly.java + * DisassemblyBlock.java + * src/org/eclipse/cdt/debug/internal/core/CDebugUtils.java: removed + 2004-09-21 Mikhail Khodjaiants Changes to the IBinary interface * CDebugTarget.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java index 82af6fb8411..89d84a9b7f9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java @@ -266,8 +266,7 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent if ( cdiBreakpoint instanceof ICDILocationBreakpoint ) { try { ICDILocation location = ((ICDILocationBreakpoint)cdiBreakpoint).getLocation(); - if ( location != null ) - { + if ( location != null ) { IAddressFactory factory = getDebugTarget().getAddressFactory(); return factory.createAddress( location.getAddress().toString() ); } @@ -499,12 +498,15 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent } private ICDIBreakpoint setAddressBreakpoint( ICAddressBreakpoint breakpoint ) throws CDIException, CoreException, NumberFormatException { - ICDITarget cdiTarget = getCDITarget(); - ICDILocation location = cdiTarget.createLocation( new BigInteger ( breakpoint.getAddress() ) ); ICDIBreakpoint cdiBreakpoint = null; - synchronized ( getBreakpointMap() ) { - cdiBreakpoint = cdiTarget.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true ); - getBreakpointMap().put( breakpoint, cdiBreakpoint ); + ICDITarget cdiTarget = getCDITarget(); + String address = breakpoint.getAddress(); + if ( address.startsWith( "0x" ) ) { //$NON-NLS-1$ + ICDILocation location = cdiTarget.createLocation( new BigInteger ( breakpoint.getAddress().substring( 2 ), 16 ) ); + synchronized ( getBreakpointMap() ) { + cdiBreakpoint = cdiTarget.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true ); + getBreakpointMap().put( breakpoint, cdiBreakpoint ); + } } return cdiBreakpoint; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugUtils.java deleted file mode 100644 index 05585515a5c..00000000000 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugUtils.java +++ /dev/null @@ -1,34 +0,0 @@ -/********************************************************************** - * Copyright (c) 2004 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation -***********************************************************************/ -package org.eclipse.cdt.debug.internal.core; - -/** - * Utilities used by C/C++ Debug Plugin's classes. - */ -public class CDebugUtils { - - /** - * Returns the hexadecimal presentation of the given address. - * - * @param address an address to be converted to hex - * @return the hexadecimal presentation of the given address - */ - public static String toHexAddressString( long address ) { - String addressString = Long.toHexString( address ); - StringBuffer sb = new StringBuffer( 10 ); - sb.append( "0x" ); //$NON-NLS-1$ - for( int i = 0; i < 8 - addressString.length(); ++i ) { - sb.append( '0' ); - } - sb.append( addressString ); - return sb.toString(); - } -} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/AsmInstruction.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/AsmInstruction.java index 43e48ce1f37..aaa8385ee21 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/AsmInstruction.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/AsmInstruction.java @@ -21,25 +21,22 @@ import org.eclipse.cdt.debug.core.model.IAsmInstruction; public class AsmInstruction implements IAsmInstruction { private ICDIInstruction fCDIInstruction; - private IAddressFactory fAddressFactory; + + private IAddress fAddress; + /** * Constructor for AsmInstruction. */ public AsmInstruction( IAddressFactory factory, ICDIInstruction cdiInstruction ) { fCDIInstruction = cdiInstruction; - fAddressFactory = factory; - } - - public IAddressFactory getAddressFactory() { - return fAddressFactory; + fAddress = factory.createAddress( cdiInstruction.getAdress().toString() ); } /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.IAsmInstruction#getAdress() */ public IAddress getAdress() { - IAddressFactory factory = getAddressFactory(); - return factory.createAddress( fCDIInstruction.getAdress().toString() ); + return fAddress; } /* (non-Javadoc) diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java index 04327c6236d..53c6e8a8ac1 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.debug.internal.core.model; import java.math.BigInteger; import java.util.ArrayList; - import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.ICDebugConstants; @@ -80,7 +79,7 @@ public class Disassembly extends CDebugElement implements IDisassembly { !containsAddress( mixedInstrs, address ) ) { try { BigInteger addr = new BigInteger( address.toString() ); - ICDIInstruction[] instructions = getFunctionInstructions( sm.getInstructions( addr, addr.add(BigInteger.valueOf(DISASSEMBLY_BLOCK_SIZE)) ) ); + ICDIInstruction[] instructions = getFunctionInstructions( sm.getInstructions( addr, addr.add( BigInteger.valueOf( DISASSEMBLY_BLOCK_SIZE ) ) ) ); return DisassemblyBlock.create( this, instructions ); } catch( CDIException e ) { @@ -98,9 +97,12 @@ public class Disassembly extends CDebugElement implements IDisassembly { private boolean containsAddress( ICDIMixedInstruction[] mi, IAddress address ) { for( int i = 0; i < mi.length; ++i ) { ICDIInstruction[] instructions = mi[i].getInstructions(); - for ( int j = 0; j < instructions.length; ++j ) - if ( address.equals(instructions[j].getAdress())) + for ( int j = 0; j < instructions.length; ++j ) { + // TODO: better comparison of IAddress and BigInteger + BigInteger a = new BigInteger( address.toString() ); + if ( a.equals( instructions[j].getAdress() ) ) return true; + } } return false; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyBlock.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyBlock.java index 23df3bca9b9..89044b9e727 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyBlock.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyBlock.java @@ -105,11 +105,12 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable { if ( !getDisassembly().getDebugTarget().equals( frame.getDebugTarget() ) ) return false; IAddress address = frame.getAddress(); - return ( address.compareTo(fStartAddress) >= 0 && - address.compareTo(fEndAddress) <= 0 ); + return (address.compareTo( fStartAddress ) >= 0 && address.compareTo( fEndAddress ) <= 0); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.cdt.debug.core.model.IDisassemblyBlock#getSourceLines() */ public IAsmSourceLine[] getSourceLines() {