1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Work to support bigger then 32 bits application

This commit is contained in:
Alain Magloire 2004-09-18 03:46:42 +00:00
parent 05ca77b425
commit ca9852bf78
48 changed files with 322 additions and 250 deletions

View file

@ -10,8 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.debug.core.cdi;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
/**
*
@ -26,7 +25,7 @@ public interface ICDILocation {
*
* @return the address of this location
*/
IAddress getAddress();
BigInteger getAddress();
/**
* Returns the source file of this location or <code>null</code>

View file

@ -11,7 +11,8 @@
package org.eclipse.cdt.debug.core.cdi;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
/**
@ -42,7 +43,7 @@ public interface ICDIMemoryManager extends ICDIManager {
* @return a memory block with the specified identifier
* @throws CDIException on failure. Reasons include:
*/
ICDIMemoryBlock createMemoryBlock(IAddress address, int length)
ICDIMemoryBlock createMemoryBlock(BigInteger address, int length)
throws CDIException;
/**

View file

@ -11,7 +11,8 @@
package org.eclipse.cdt.debug.core.cdi;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction;
@ -41,7 +42,7 @@ public interface ICDISourceManager extends ICDIManager {
* @param endAddress is the end address
* @throws CDIException on failure.
*/
ICDIInstruction[] getInstructions(IAddress startAddress, IAddress endAddress)
ICDIInstruction[] getInstructions(BigInteger startAddress, BigInteger endAddress)
throws CDIException;
/**
@ -67,8 +68,8 @@ public interface ICDISourceManager extends ICDIManager {
* @throws CDIException on failure.
*/
ICDIMixedInstruction[] getMixedInstructions(
IAddress startAddress,
IAddress endAddress)
BigInteger startAddress,
BigInteger endAddress)
throws CDIException;
/**

View file

@ -11,7 +11,8 @@
package org.eclipse.cdt.debug.core.cdi;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.model.ICDITracepoint;
/**
@ -156,5 +157,5 @@ public interface ICDITraceManager extends ICDISessionObject {
* @param address - an address
* @return an ICDILocation object
*/
ICDILocation createLocation( IAddress address );
ICDILocation createLocation( BigInteger address );
}

View file

@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.debug.core.cdi.event;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
/**
*
@ -21,5 +21,5 @@ public interface ICDIMemoryChangedEvent extends ICDIChangedEvent {
/**
* @return the modified addresses.
*/
IAddress[] getAddresses();
BigInteger[] getAddresses();
}

View file

@ -11,7 +11,8 @@
package org.eclipse.cdt.debug.core.cdi.model;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
/**
*
@ -24,7 +25,7 @@ public interface ICDIInstruction extends ICDIObject {
* Returns the Address.
* @return the address.
*/
IAddress getAdress();
BigInteger getAdress();
/**
* @return the function name.

View file

@ -11,7 +11,8 @@
package org.eclipse.cdt.debug.core.cdi.model;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
/**
@ -27,7 +28,7 @@ public interface ICDIMemoryBlock extends ICDIObject {
*
* @return the start address of this memory block
*/
IAddress getStartAddress();
BigInteger getStartAddress();
/**
* Returns the length of this memory block in bytes.

View file

@ -10,7 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.debug.core.cdi.model;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
/**
@ -33,14 +34,14 @@ public interface ICDISharedLibrary extends ICDIObject {
*
* @return the start address of this library
*/
IAddress getStartAddress();
BigInteger getStartAddress();
/**
* Returns the end address of this library.
*
* @return the end address of this library
*/
IAddress getEndAddress();
BigInteger getEndAddress();
/**
* Returns whether the symbols of this library are read.

View file

@ -11,7 +11,8 @@
package org.eclipse.cdt.debug.core.cdi.model;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
@ -183,6 +184,6 @@ public interface ICDITarget extends ICDIThreadGroup, ICDISessionObject {
/**
* Returns a ICDILocation
*/
ICDILocation createLocation(IAddress address);
ICDILocation createLocation(BigInteger address);
}

View file

@ -11,6 +11,8 @@
package org.eclipse.cdt.debug.core.cdi.model.type;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
@ -23,6 +25,8 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
*/
public interface ICDIIntegralValue extends ICDIValue {
public BigInteger bigIntegerValue() throws CDIException;
public long longValue() throws CDIException;
public int intValue() throws CDIException;

View file

@ -11,7 +11,8 @@
package org.eclipse.cdt.debug.core.cdi.model.type;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
@ -23,5 +24,5 @@ import org.eclipse.cdt.debug.core.cdi.CDIException;
*/
public interface ICDIPointerValue extends ICDIDerivedValue {
IAddress pointerValue() throws CDIException;
BigInteger pointerValue() throws CDIException;
}

View file

@ -10,12 +10,13 @@
*******************************************************************************/
package org.eclipse.cdt.debug.core.cdi.model.type;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
/**
*/
public interface ICDIReferenceValue extends ICDIDerivedValue {
IAddress referenceValue() throws CDIException;
BigInteger referenceValue() throws CDIException;
}

View file

@ -10,6 +10,7 @@
***********************************************************************/
package org.eclipse.cdt.debug.internal.core;
import java.math.BigInteger;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.HashMap;
@ -17,6 +18,7 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils;
@ -265,7 +267,10 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
try {
ICDILocation location = ((ICDILocationBreakpoint)cdiBreakpoint).getLocation();
if ( location != null )
return location.getAddress();
{
IAddressFactory factory = getDebugTarget().getAddressFactory();
return factory.createAddress( location.getAddress().toString() );
}
}
catch( CDIException e ) {
}
@ -495,7 +500,7 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
private ICDIBreakpoint setAddressBreakpoint( ICAddressBreakpoint breakpoint ) throws CDIException, CoreException, NumberFormatException {
ICDITarget cdiTarget = getCDITarget();
ICDILocation location = cdiTarget.createLocation( getDebugTarget().getAddressFactory().createAddress(breakpoint.getAddress()));
ICDILocation location = cdiTarget.createLocation( new BigInteger ( breakpoint.getAddress() ) );
ICDIBreakpoint cdiBreakpoint = null;
synchronized ( getBreakpointMap() ) {
cdiBreakpoint = cdiTarget.setLocationBreakpoint( ICDIBreakpoint.REGULAR, location, null, null, true );
@ -565,7 +570,7 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
else if ( !isEmpty( cdiBreakpoint.getLocation().getFunction() ) ) {
breakpoint = createFunctionBreakpoint( cdiBreakpoint );
}
else if ( ! cdiBreakpoint.getLocation().getAddress().isZero() ) {
else if ( ! cdiBreakpoint.getLocation().getAddress().equals( BigInteger.ZERO ) ) {
breakpoint = createAddressBreakpoint( cdiBreakpoint );
}
}
@ -573,7 +578,7 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
else if ( !isEmpty( cdiBreakpoint.getLocation().getFunction() ) ) {
breakpoint = createFunctionBreakpoint( cdiBreakpoint );
}
else if ( ! cdiBreakpoint.getLocation().getAddress().isZero()) {
else if ( ! cdiBreakpoint.getLocation().getAddress().equals( BigInteger.ZERO ) ) {
breakpoint = createAddressBreakpoint( cdiBreakpoint );
}
}
@ -618,9 +623,10 @@ public class CBreakpointManager implements IBreakpointManagerListener, ICDIEvent
private ICAddressBreakpoint createAddressBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException {
IFile execFile = getExecFile();
String sourceHandle = execFile.getFullPath().toOSString();
IAddress address = getDebugTarget().getAddressFactory().createAddress( cdiBreakpoint.getLocation().getAddress().toString() );
ICAddressBreakpoint breakpoint = CDIDebugModel.createAddressBreakpoint( sourceHandle,
execFile,
cdiBreakpoint.getLocation().getAddress(),
address,
cdiBreakpoint.isEnabled(),
cdiBreakpoint.getCondition().getIgnoreCount(),
cdiBreakpoint.getCondition().getExpression(),

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
import org.eclipse.cdt.debug.core.model.IAsmInstruction;
@ -20,19 +21,25 @@ import org.eclipse.cdt.debug.core.model.IAsmInstruction;
public class AsmInstruction implements IAsmInstruction {
private ICDIInstruction fCDIInstruction;
private IAddressFactory fAddressFactory;
/**
* Constructor for AsmInstruction.
*/
public AsmInstruction( ICDIInstruction cdiInstruction ) {
public AsmInstruction( IAddressFactory factory, ICDIInstruction cdiInstruction ) {
fCDIInstruction = cdiInstruction;
fAddressFactory = factory;
}
public IAddressFactory getAddressFactory() {
return fAddressFactory;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IAsmInstruction#getAdress()
*/
public IAddress getAdress() {
return fCDIInstruction.getAdress();
IAddressFactory factory = getAddressFactory();
return factory.createAddress( fCDIInstruction.getAdress().toString() );
}
/* (non-Javadoc)

View file

@ -10,6 +10,7 @@
***********************************************************************/
package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
import org.eclipse.cdt.debug.core.model.IAsmInstruction;
import org.eclipse.cdt.debug.core.model.IAsmSourceLine;
@ -26,11 +27,11 @@ public class AsmSourceLine implements IAsmSourceLine {
/**
* Constructor for AsmSourceLine.
*/
public AsmSourceLine( String text, ICDIInstruction[] cdiInstructions ) {
public AsmSourceLine( IAddressFactory factory, String text, ICDIInstruction[] cdiInstructions ) {
fText = text;
fInstructions = new IAsmInstruction[cdiInstructions.length];
for ( int i = 0; i < fInstructions.length; ++i ) {
fInstructions[i] = new AsmInstruction( cdiInstructions[i] );
fInstructions[i] = new AsmInstruction( factory, cdiInstructions[i] );
}
}

View file

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.model;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@ -1518,7 +1519,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
if ( skipBreakpoints ) {
getBreakpointManager().skipBreakpoints( true );
}
ICDILocation location = getCDITarget().createLocation( address );
ICDILocation location = getCDITarget().createLocation( new BigInteger( address.toString() ) );
try {
getCDITarget().stepUntil( location );
}
@ -1619,7 +1620,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
public void jumpToAddress( IAddress address ) throws DebugException {
if ( !canJumpToAddress( address ) )
return;
ICDILocation location = getCDITarget().createLocation( address );
ICDILocation location = getCDITarget().createLocation( new BigInteger( address.toString() ) );
try {
getCDITarget().resume( location );
}

View file

@ -15,6 +15,7 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.cdi.CDIException;
@ -293,11 +294,12 @@ public class CFormattedMemoryBlock extends CDebugElement
public IAddress getRealStartAddress()
{
IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory();
if ( fCDIMemoryBlock != null )
{
return fCDIMemoryBlock.getStartAddress();
return factory.createAddress( fCDIMemoryBlock.getStartAddress().toString() );
}
return ((CDebugTarget)getDebugTarget()).getAddressFactory().getZero();
return factory.getZero();
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlock#getLength()
@ -500,7 +502,13 @@ public class CFormattedMemoryBlock extends CDebugElement
{
resetBytes();
resetRows();
setChangedAddresses( event.getAddresses() );
IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory();
BigInteger[] bigs = event.getAddresses();
IAddress[] addresses = new IAddress[bigs.length];
for (int i = 0; i < addresses.length; ++i) {
addresses[i] = factory.createAddress( bigs[i].toString() );
}
setChangedAddresses( addresses );
fireChangeEvent( DebugEvent.CONTENT );
}

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
@ -55,9 +56,10 @@ public class CSharedLibrary extends CDebugElement
*/
public IAddress getStartAddress()
{
IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory();
if ( getCDISharedLibrary() != null )
return getCDISharedLibrary().getStartAddress();
return ((CDebugTarget)getDebugTarget()).getAddressFactory().getZero();
return factory.createAddress(getCDISharedLibrary().getStartAddress().toString());
return factory.getZero();
}
/* (non-Javadoc)
@ -65,9 +67,10 @@ public class CSharedLibrary extends CDebugElement
*/
public IAddress getEndAddress()
{
IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory();
if ( getCDISharedLibrary() != null )
return getCDISharedLibrary().getEndAddress();
return ((CDebugTarget)getDebugTarget()).getAddressFactory().getZero();
return factory.createAddress(getCDISharedLibrary().getEndAddress().toString());
return factory.getZero();
}
/* (non-Javadoc)

View file

@ -18,6 +18,7 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
@ -532,7 +533,8 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
* @see org.eclipse.cdt.debug.core.model.ICStackFrame#getAddress()
*/
public IAddress getAddress() {
return getCDIStackFrame().getLocation().getAddress();
IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory();
return factory.createAddress( getCDIStackFrame().getLocation().getAddress().toString() );
}
/* (non-Javadoc)

View file

@ -18,6 +18,7 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
@ -363,9 +364,11 @@ public class CValue extends AbstractCValue {
private String getPointerValueString( ICDIPointerValue value ) throws CDIException
{
//IPF_TODO Workaround to solve incoorect handling of structures referenced by pointers or references
IAddress address = value.pointerValue();
if(address == null) return "";
//TODO:IPF_TODO Workaround to solve incorrect handling of structures referenced by pointers or references
IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory();
IAddress address = factory.createAddress(value.pointerValue().toString());
if ( address == null )
return ""; //$NON-NLS-1$
CVariableFormat format = getParentVariable().getFormat();
if( CVariableFormat.NATURAL.equals( format ) ||
CVariableFormat.HEXADECIMAL.equals( format ) )
@ -378,9 +381,11 @@ public class CValue extends AbstractCValue {
private String getReferenceValueString( ICDIReferenceValue value ) throws CDIException
{
//NOTE: Reference should be displayed identically to address
//IPF_TODO Workaround to solve incoorect handling of structures referenced by pointers or references
IAddress address = value.referenceValue();
if(address == null) return "";
//TODO:IPF_TODO Workaround to solve incoorect handling of structures referenced by pointers or references
IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory();
IAddress address = factory.createAddress( value.referenceValue().toString() );
if (address == null)
return ""; //$NON-NLS-1$
CVariableFormat format = getParentVariable().getFormat();
if( CVariableFormat.NATURAL.equals( format ) ||
CVariableFormat.HEXADECIMAL.equals( format ) )

View file

@ -79,7 +79,8 @@ public class Disassembly extends CDebugElement implements IDisassembly {
if ( mixedInstrs.length == 0 ||
!containsAddress( mixedInstrs, address ) ) {
try {
ICDIInstruction[] instructions = getFunctionInstructions( sm.getInstructions( address, address.add(BigInteger.valueOf(DISASSEMBLY_BLOCK_SIZE)) ) );
BigInteger addr = new BigInteger( address.toString() );
ICDIInstruction[] instructions = getFunctionInstructions( sm.getInstructions( addr, addr.add(BigInteger.valueOf(DISASSEMBLY_BLOCK_SIZE)) ) );
return DisassemblyBlock.create( this, instructions );
}
catch( CDIException e ) {

View file

@ -17,6 +17,7 @@ import java.io.IOException;
import java.io.LineNumberReader;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction;
import org.eclipse.cdt.debug.core.model.IAsmInstruction;
@ -61,15 +62,17 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
if ( adapter instanceof IAdaptable ) {
locator = (ICSourceLocator)((IAdaptable)adapter).getAdapter( ICSourceLocator.class );
}
block.setSourceLines( createSourceLines( locator, instructions ) );
IAddressFactory factory = ((CDebugTarget)disassembly.getDebugTarget()).getAddressFactory();
block.setSourceLines( createSourceLines( factory, locator, instructions ) );
block.initializeAddresses();
return block;
}
public static DisassemblyBlock create( IDisassembly disassembly, ICDIInstruction[] instructions ) {
DisassemblyBlock block = new DisassemblyBlock( disassembly );
IAddressFactory factory = ((CDebugTarget)disassembly.getDebugTarget()).getAddressFactory();
block.setMixedMode( false );
block.setSourceLines( createSourceLines( instructions ) );
block.setSourceLines( createSourceLines( factory, instructions ) );
block.initializeAddresses();
return block;
}
@ -130,7 +133,7 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
public void dispose() {
}
private static IAsmSourceLine[] createSourceLines( ICSourceLocator locator, ICDIMixedInstruction[] mi ) {
private static IAsmSourceLine[] createSourceLines( IAddressFactory factory, ICSourceLocator locator, ICDIMixedInstruction[] mi ) {
IAsmSourceLine[] result = new IAsmSourceLine[mi.length];
LineNumberReader reader = null;
if ( result.length > 0 && locator != null ) {
@ -170,13 +173,14 @@ public class DisassemblyBlock implements IDisassemblyBlock, IAdaptable {
}
}
}
result[i] = new AsmSourceLine( text, mi[i].getInstructions() );
result[i] = new AsmSourceLine( factory, text, mi[i].getInstructions() );
}
return result;
}
private static IAsmSourceLine[] createSourceLines( ICDIInstruction[] instructions ) {
return new IAsmSourceLine[] { new AsmSourceLine( "", instructions ) }; //$NON-NLS-1$
private static IAsmSourceLine[] createSourceLines( IAddressFactory factory, ICDIInstruction[] instructions ) {
return new IAsmSourceLine[] { new AsmSourceLine( factory, "", instructions ) }; //$NON-NLS-1$
}
private void initializeAddresses() {

View file

@ -10,13 +10,13 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
@ -650,7 +650,7 @@ public class BreakpointManager extends Manager {
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#createLocation(long)
*/
public ICDILocation createLocation(IAddress address) {
public ICDILocation createLocation(BigInteger address) {
return new Location(address);
}

View file

@ -10,13 +10,13 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIEventManager;
import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager;
@ -120,7 +120,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
MemoryManager mgr = (MemoryManager)session.getMemoryManager();
MemoryBlock[] blocks = mgr.getMemoryBlocks(miEvent.getMISession());
MIMemoryChangedEvent miMem = (MIMemoryChangedEvent)miEvent;
IAddress[] addresses = miMem.getAddresses();
BigInteger[] addresses = miMem.getAddresses();
for (int i = 0; i < blocks.length; i++) {
if (blocks[i].contains(addresses) &&
(! blocks[i].isFrozen() || blocks[i].isDirty())) {

View file

@ -10,14 +10,15 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
/**
*/
public class Location implements ICDILocation {
IAddress addr;
BigInteger addr;
String file = ""; //$NON-NLS-1$
String function = ""; //$NON-NLS-1$
int line;
@ -26,7 +27,7 @@ public class Location implements ICDILocation {
this(f, fnct, l, null);
}
public Location(String f, String fnct, int l, IAddress a) {
public Location(String f, String fnct, int l, BigInteger a) {
if (f != null)
file = f;
if (fnct != null)
@ -35,14 +36,14 @@ public class Location implements ICDILocation {
addr = a;
}
public Location(IAddress address) {
public Location(BigInteger address) {
addr = address;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDILocation#getAddress()
*/
public IAddress getAddress() {
public BigInteger getAddress() {
return addr;
}
@ -87,7 +88,7 @@ public class Location implements ICDILocation {
}
}
}
IAddress oaddr = location.getAddress();
BigInteger oaddr = location.getAddress();
if (addr != null && oaddr != null) { //IPF_TODO: check ZERO addresses
if (addr.equals(oaddr)) {
return true;

View file

@ -18,7 +18,6 @@ import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
@ -102,12 +101,12 @@ public class MemoryManager extends Manager implements ICDIMemoryManager {
/**
* update one Block.
*/
public IAddress[] update(MemoryBlock block, List aList) throws CDIException {
public BigInteger[] update(MemoryBlock block, List aList) throws CDIException {
Target target = (Target)block.getTarget();
MISession miSession = target.getMISession();
MemoryBlock newBlock = cloneBlock(block);
boolean newAddress = ! newBlock.getStartAddress().equals(block.getStartAddress());
IAddress[] array = compareBlocks(block, newBlock);
BigInteger[] array = compareBlocks(block, newBlock);
// Update the block MIDataReadMemoryInfo.
block.setMIDataReadMemoryInfo(newBlock.getMIDataReadMemoryInfo());
if (array.length > 0 || newAddress) {
@ -128,11 +127,11 @@ public class MemoryManager extends Manager implements ICDIMemoryManager {
* oldBlock.getLength() == newBlock.getLength();
* @return Long[] array of modified addresses.
*/
IAddress[] compareBlocks (MemoryBlock oldBlock, MemoryBlock newBlock) throws CDIException {
BigInteger[] compareBlocks (MemoryBlock oldBlock, MemoryBlock newBlock) throws CDIException {
byte[] oldBytes = oldBlock.getBytes();
byte[] newBytes = newBlock.getBytes();
List aList = new ArrayList(newBytes.length);
BigInteger distance = newBlock.getStartAddress().distance(oldBlock.getStartAddress());
BigInteger distance = newBlock.getStartAddress().subtract(oldBlock.getStartAddress());
//IPF_TODO enshure it is OK here
int diff = distance.intValue();
if ( Math.abs(diff) < newBytes.length) {
@ -144,7 +143,7 @@ public class MemoryManager extends Manager implements ICDIMemoryManager {
}
}
}
return (IAddress[])aList.toArray(new IAddress[0]);
return (BigInteger[]) aList.toArray(new BigInteger[aList.size()]);
}
/**
@ -180,9 +179,9 @@ public class MemoryManager extends Manager implements ICDIMemoryManager {
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#createMemoryBlock(long, int)
*/
public ICDIMemoryBlock createMemoryBlock(IAddress address, int length)
public ICDIMemoryBlock createMemoryBlock(BigInteger address, int length)
throws CDIException {
return createMemoryBlock(address.toHexAddressString(), length);
return createMemoryBlock(address.toString(16), length);
}
/**

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.debug.mi.core.cdi;
import java.util.Properties;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICDIEventManager;
@ -55,19 +54,19 @@ public class Session implements ICDISession, ICDISessionObject {
SourceManager sourceManager;
ICDIConfiguration configuration;
public Session(MISession miSession, IAddressFactory addrFactory, boolean attach) {
public Session(MISession miSession, boolean attach) {
commonSetup();
setConfiguration(new Configuration(miSession, attach));
Target target = new Target(this, miSession, addrFactory);
Target target = new Target(this, miSession);
addTargets(new Target[] { target }, target);
}
public Session(MISession miSession, IAddressFactory addrFactory) {
public Session(MISession miSession) {
commonSetup();
setConfiguration(new CoreFileConfiguration());
Target target = new Target(this, miSession, addrFactory);
Target target = new Target(this, miSession);
addTargets(new Target[] { target }, target);
}

View file

@ -11,18 +11,19 @@
package org.eclipse.cdt.debug.mi.core.cdi;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager;
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.MIFormat;
import org.eclipse.cdt.debug.mi.core.MISession;
import org.eclipse.cdt.debug.mi.core.cdi.model.SharedLibrary;
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
@ -146,10 +147,9 @@ public class SharedLibraryManager extends Manager implements ICDISharedLibraryMa
}
public boolean hasSharedLibChanged(ICDISharedLibrary lib, MIShared miLib) {
IAddressFactory af = ((Target)getSession().getCurrentTarget()).getAddressFactory();
return !miLib.getName().equals(lib.getFileName()) ||
!af.createAddress(miLib.getFrom()).equals(lib.getStartAddress()) ||
!af.createAddress(miLib.getTo()).equals(lib.getEndAddress()) ||
!MIFormat.getBigInteger(miLib.getFrom()).equals(lib.getStartAddress()) ||
!MIFormat.getBigInteger(miLib.getTo()).equals(lib.getEndAddress()) ||
miLib.isRead() != lib.areSymbolsLoaded();
}

View file

@ -10,9 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi;
import java.math.BigInteger;
import java.util.StringTokenizer;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDISourceManager;
import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
@ -146,16 +146,16 @@ public class SourceManager extends Manager implements ICDISourceManager {
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getInstructions(long, long)
*/
public ICDIInstruction[] getInstructions(IAddress start, IAddress end) throws CDIException {
public ICDIInstruction[] getInstructions(BigInteger start, BigInteger end) throws CDIException {
Target target = (Target)getSession().getCurrentTarget();
return getInstructions(target, start, end);
}
public ICDIInstruction[] getInstructions(Target target, IAddress start, IAddress end) throws CDIException {
public ICDIInstruction[] getInstructions(Target target, BigInteger start, BigInteger end) throws CDIException {
MISession mi = target.getMISession();
CommandFactory factory = mi.getCommandFactory();
String hex = "0x"; //$NON-NLS-1$
String sa = start.toHexAddressString();
String ea = end.toHexAddressString();
String sa = hex + start.toString(16);
String ea = hex + end.toString(16);
MIDataDisassemble dis = factory.createMIDataDisassemble(sa, ea, false);
try {
mi.postCommand(dis);
@ -206,15 +206,16 @@ public class SourceManager extends Manager implements ICDISourceManager {
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getMixedInstructions(long, long)
*/
public ICDIMixedInstruction[] getMixedInstructions(IAddress start, IAddress end) throws CDIException {
public ICDIMixedInstruction[] getMixedInstructions(BigInteger start, BigInteger end) throws CDIException {
Target target = (Target)getSession().getCurrentTarget();
return getMixedInstructions(target, start, end);
}
public ICDIMixedInstruction[] getMixedInstructions(Target target, IAddress start, IAddress end) throws CDIException {
public ICDIMixedInstruction[] getMixedInstructions(Target target, BigInteger start, BigInteger end) throws CDIException {
MISession mi = target.getMISession();
CommandFactory factory = mi.getCommandFactory();
String sa = start.toHexAddressString();
String ea = end.toHexAddressString();
String hex = "0x"; //$NON-NLS-1$
String sa = hex + start.toString(16);
String ea = hex + end.toString(16);
MIDataDisassemble dis = factory.createMIDataDisassemble(sa, ea, true);
try {
mi.postCommand(dis);
@ -340,7 +341,7 @@ public class SourceManager extends Manager implements ICDISourceManager {
} else if (typename.equals("int32_t")) { //$NON-NLS-1$
return new LongType(vo, typename);
} else if (typename.equals("int64_t")) { //$NON-NLS-1$
return new IntType(vo, typename);
return new LongLongType(vo, typename);
} else if (typename.equals("int128_t")) { //$NON-NLS-1$
return new IntType(vo, typename);
}
@ -480,12 +481,16 @@ public class SourceManager extends Manager implements ICDISourceManager {
}
public String getTypeName(VariableObject vo, String variable) throws CDIException {
Target target = (Target)vo.getTarget();
ICDIStackFrame frame = vo.getStackFrame();
Target target = (Target)frame.getTarget();
ICDIThread currentThread = target.getCurrentThread();
ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame();
target.setCurrentThread(frame.getThread(), false);
frame.getThread().setCurrentStackFrame(frame, false);
ICDIThread currentThread = null;
ICDIStackFrame currentFrame = null;
if (frame != null) {
currentThread = target.getCurrentThread();
currentFrame = currentThread.getCurrentStackFrame();
target.setCurrentThread(frame.getThread(), false);
frame.getThread().setCurrentStackFrame(frame, false);
}
try {
MISession mi = target.getMISession();
CommandFactory factory = mi.getCommandFactory();
@ -499,8 +504,12 @@ public class SourceManager extends Manager implements ICDISourceManager {
} catch (MIException e) {
throw new MI2CDIException(e);
} finally {
target.setCurrentThread(currentThread, false);
currentThread.setCurrentStackFrame(currentFrame, false);
if (currentThread != null) {
target.setCurrentThread(currentThread, false);
}
if (currentFrame != null) {
currentThread.setCurrentStackFrame(currentFrame, false);
}
}
}

View file

@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi.event;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.cdi.event.ICDIMemoryChangedEvent;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.mi.core.cdi.Session;
@ -37,16 +37,16 @@ public class MemoryChangedEvent implements ICDIMemoryChangedEvent {
/**
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getAddresses()
*/
public IAddress[] getAddresses() {
public BigInteger[] getAddresses() {
/* But only returns the address that are in the block. */
IAddress[] mi_addresses = miMem.getAddresses();
BigInteger[] mi_addresses = miMem.getAddresses();
List aList = new ArrayList(mi_addresses.length);
for (int i = 0; i < mi_addresses.length; i++) {
if (source.contains(mi_addresses[i])) {
aList.add(mi_addresses[i]);
}
}
return (IAddress[])aList.toArray(new IAddress[0]);
return (BigInteger[]) aList.toArray(new BigInteger[aList.size()]);
}
/**

View file

@ -10,11 +10,14 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi.model;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
import org.eclipse.cdt.debug.mi.core.MIFormat;
import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager;
import org.eclipse.cdt.debug.mi.core.cdi.Condition;
import org.eclipse.cdt.debug.mi.core.cdi.Location;
@ -153,7 +156,7 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint {
fLocation = new Location (miBreakpoint.getFile(),
miBreakpoint.getFunction(),
miBreakpoint.getLine(),
((Target)getTarget()).getAddressFactory().createAddress(miBreakpoint.getAddress()));
MIFormat.getBigInteger(miBreakpoint.getAddress()));
}
}
return fLocation;

View file

@ -10,8 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi.model;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
import org.eclipse.cdt.debug.mi.core.MIFormat;
import org.eclipse.cdt.debug.mi.core.output.MIAsm;
/**
@ -27,8 +29,8 @@ public class Instruction extends CObject implements ICDIInstruction {
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction#getAdress()
*/
public IAddress getAdress() {
return ((Target)getTarget()).getAddressFactory().createAddress(asm.getAddress());
public BigInteger getAdress() {
return MIFormat.getBigInteger(asm.getAddress());
}
/**

View file

@ -15,7 +15,6 @@ import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
import org.eclipse.cdt.debug.mi.core.MIException;
@ -39,7 +38,7 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock {
boolean dirty;
private MIDataReadMemoryInfo mem;
private IAddress cStartAddress; //cashed start address
private BigInteger cStartAddress; //cashed start address
private byte[] cBytes; //cashed bytes
public MemoryBlock(Target target, String exp, MIDataReadMemoryInfo info) {
@ -61,7 +60,7 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock {
* using this method
*/
public void setMIDataReadMemoryInfo(MIDataReadMemoryInfo m) {
cStartAddress = ((Target)getTarget()).getAddressFactory().createAddress(m.getAddress());
cStartAddress = MIFormat.getBigInteger(m.getAddress());
cBytes = getBytes(m);
mem = m;
}
@ -76,7 +75,7 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock {
/**
* @return true if any address in the array is within the block.
*/
public boolean contains(IAddress[] adds) {
public boolean contains(BigInteger[] adds) {
for (int i = 0; i < adds.length; i++) {
if (contains(adds[i])) {
return true;
@ -88,8 +87,8 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock {
/**
* @return true if the address is within the block.
*/
public boolean contains(IAddress addr) {
IAddress start = getStartAddress();
public boolean contains(BigInteger addr) {
BigInteger start = getStartAddress();
long length = getLength();
if ( start.compareTo(addr) <= 0 &&
addr.compareTo(start.add(BigInteger.valueOf(length))) <= 0 )
@ -144,7 +143,7 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock {
Target target = (Target)getTarget();
MemoryManager mgr = (MemoryManager)target.getSession().getMemoryManager();
setDirty(true);
IAddress[] addresses = mgr.update(this, null);
BigInteger[] addresses = mgr.update(this, null);
// Check if this affects other blocks.
if (addresses.length > 0) {
MemoryBlock[] blocks = mgr.getMemoryBlocks(target.getMISession());
@ -168,7 +167,7 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock {
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock#getStartAddress()
*/
public IAddress getStartAddress() {
public BigInteger getStartAddress() {
return cStartAddress;
}

View file

@ -11,9 +11,11 @@
package org.eclipse.cdt.debug.mi.core.cdi.model;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
import org.eclipse.cdt.debug.mi.core.MIFormat;
import org.eclipse.cdt.debug.mi.core.cdi.Session;
import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager;
import org.eclipse.cdt.debug.mi.core.output.MIShared;
@ -48,15 +50,15 @@ public class SharedLibrary extends CObject implements ICDISharedLibrary {
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary#getStartAddress()
*/
public IAddress getStartAddress() {
return ((Target)getTarget()).getAddressFactory().createAddress(miShared.getFrom());
public BigInteger getStartAddress() {
return MIFormat.getBigInteger(miShared.getFrom());
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary#getEndAddress()
*/
public IAddress getEndAddress() {
return ((Target)getTarget()).getAddressFactory().createAddress(miShared.getTo());
public BigInteger getEndAddress() {
return MIFormat.getBigInteger(miShared.getTo());
}
/**

View file

@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi.model;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.model.ICDIArgument;
@ -20,6 +22,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.MIFormat;
import org.eclipse.cdt.debug.mi.core.MISession;
import org.eclipse.cdt.debug.mi.core.cdi.CdiResources;
import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException;
@ -41,6 +44,7 @@ public class StackFrame extends CObject implements ICDIStackFrame {
int level;
ICDIArgument[] args;
ICDIVariable[] locals;
Location fLocation;
/*
*
@ -130,12 +134,15 @@ public class StackFrame extends CObject implements ICDIStackFrame {
*/
public ICDILocation getLocation() {
if (frame != null) {
return new Location(frame.getFile(),
if (fLocation == null) {
fLocation = new Location(frame.getFile(),
frame.getFunction(),
frame.getLine(),
((Target)getTarget()).getAddressFactory().createAddress(frame.getAddress()));
MIFormat.getBigInteger(frame.getAddress()));
}
return fLocation;
}
return new Location("", "", 0, ((Target)getTarget()).getAddressFactory().getZero()); //$NON-NLS-1$ //$NON-NLS-2$
return new Location("", "", 0, BigInteger.ZERO); //$NON-NLS-1$ //$NON-NLS-2$
}
/**

View file

@ -10,11 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi.model;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
@ -65,13 +64,11 @@ public class Target implements ICDITarget {
Thread[] noThreads = new Thread[0];
Thread[] currentThreads;
int currentThreadId;
IAddressFactory addressFactory;
public Target(Session s, MISession mi, IAddressFactory addrFactory) {
public Target(Session s, MISession mi) {
session = s;
miSession = mi;
currentThreads = noThreads;
addressFactory = addrFactory;
}
public MISession getMISession() {
@ -468,7 +465,7 @@ public class Target implements ICDITarget {
loc = location.getFile() + ":" + location.getLineNumber(); //$NON-NLS-1$
} else if (location.getFunction() != null && location.getFunction().length() > 0) {
loc = location.getFunction();
} else if ( ! location.getAddress().isZero() ) {
} else if ( ! location.getAddress().equals(BigInteger.ZERO) ) {
loc = "*" + location.getAddress().toString(); //$NON-NLS-1$
}
MIExecUntil until = factory.createMIExecUntil(loc);
@ -579,7 +576,7 @@ public class Target implements ICDITarget {
loc = location.getFile() + ":" + location.getLineNumber(); //$NON-NLS-1$
} else if (location.getFunction() != null && location.getFunction().length() > 0) {
loc = location.getFunction();
} else if (! location.getAddress().isZero()) {
} else if (! location.getAddress().equals(BigInteger.ZERO)) {
loc = "*" + location.getAddress().toString(); //$NON-NLS-1$
}
MIJump jump = factory.createMIJump(loc);
@ -746,44 +743,8 @@ public class Target implements ICDITarget {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#createLocation(long)
*/
public ICDILocation createLocation(IAddress address) {
public ICDILocation createLocation(BigInteger address) {
BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager();
return bMgr.createLocation(address);
}
/*
private IAddressFactory createAddressFactory() throws CDIException
{
MISession mi = ((Session)getSession()).getMISession();
CommandFactory cf = mi.getCommandFactory();
MIGDBShowAddressSize as = cf.createMIGDBShowAddressSize();
try
{
mi.postCommand(as );
MIGDBShowAddressSizeInfo info = (MIGDBShowAddressSizeInfo)as.getMIInfo();
if (info == null)
{
throw new CDIException("Target is not responding");
}
switch ( info.getAddressSize() )
{
case 32:
return new Addr32Factory();
case 64:
return new Addr64Factory();
default:
throw new CDIException("Undefined address size");
}
}
catch (MIException e)
{
throw new MI2CDIException(e);
}
}
*/
public IAddressFactory getAddressFactory()
{
return addressFactory;
}
}

View file

@ -161,8 +161,11 @@ public class VariableObject extends CObject implements ICDIVariableObject {
public ICDIType getType() throws CDIException {
if (type == null) {
Target target = (Target)getTarget();
ICDIStackFrame frame = getStackFrame();
Session session = (Session) (target.getSession());
ICDIStackFrame frame = getStackFrame();
if (frame == null) {
frame = target.getCurrentThread().getCurrentStackFrame();
}
SourceManager sourceMgr = (SourceManager) session.getSourceManager();
String nametype = sourceMgr.getTypeName(this, getQualifiedName());
try {

View file

@ -11,8 +11,11 @@
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIIntegralValue;
import org.eclipse.cdt.debug.mi.core.MIFormat;
import org.eclipse.cdt.debug.mi.core.cdi.model.Value;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
@ -27,6 +30,24 @@ public abstract class IntegralValue extends Value implements ICDIIntegralValue {
super(v);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#biIntegerValue()
*/
public BigInteger bigIntegerValue() throws CDIException {
String valueString = getValueString();
int space = valueString.indexOf(' ');
if (space != -1) {
valueString = valueString.substring(0, space).trim();
}
try {
return MIFormat.getBigInteger(valueString);
} catch (NumberFormatException e) {
}
return BigInteger.ZERO;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#longValue()
*/
@ -38,7 +59,7 @@ public abstract class IntegralValue extends Value implements ICDIIntegralValue {
valueString = valueString.substring(0, space).trim();
}
try {
value = Long.decode(valueString).longValue();
value = MIFormat.getBigInteger(valueString).longValue();
} catch (NumberFormatException e) {
}
return value;
@ -55,7 +76,7 @@ public abstract class IntegralValue extends Value implements ICDIIntegralValue {
valueString = valueString.substring(0, space).trim();
}
try {
value = Integer.decode(valueString).intValue();
value = MIFormat.getBigInteger(valueString).intValue();
} catch (NumberFormatException e) {
}
return value;
@ -72,7 +93,7 @@ public abstract class IntegralValue extends Value implements ICDIIntegralValue {
valueString = valueString.substring(0, space).trim();
}
try {
value = Short.decode(valueString).shortValue();
value = MIFormat.getBigInteger(valueString).shortValue();
} catch (NumberFormatException e) {
}
return value;
@ -89,7 +110,7 @@ public abstract class IntegralValue extends Value implements ICDIIntegralValue {
valueString = valueString.substring(0, space).trim();
}
try {
value = Byte.decode(valueString).byteValue();
value = MIFormat.getBigInteger(valueString).byteValue();
} catch (NumberFormatException e) {
}
return value;

View file

@ -11,10 +11,11 @@
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
import org.eclipse.cdt.debug.mi.core.MIFormat;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
/**
@ -31,18 +32,15 @@ public class PointerValue extends DerivedValue implements ICDIPointerValue {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerValue#pointerValue()
*/
public IAddress pointerValue() throws CDIException {
public BigInteger pointerValue() throws CDIException {
String valueString = getValueString().trim();
int space = valueString.indexOf(' ');
if (space != -1) {
valueString = valueString.substring(0, space).trim();
}
try{
return ((Target)getTarget()).getAddressFactory().createAddress(valueString);
}
catch(Exception e)
{
try {
return MIFormat.getBigInteger(valueString);
} catch(Exception e) {
return null;
}
}

View file

@ -11,10 +11,11 @@
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceValue;
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
import org.eclipse.cdt.debug.mi.core.MIFormat;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
/**
@ -34,20 +35,19 @@ public class ReferenceValue extends DerivedValue implements ICDIReferenceValue {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceValue#referenceValue()
*/
public IAddress referenceValue() throws CDIException {
public BigInteger referenceValue() throws CDIException {
String valueString = getValueString().trim();
if ( valueString.startsWith("@") ) //$NON-NLS-1$
valueString = valueString.substring( 1 );
if (valueString.startsWith("@")) { //$NON-NLS-1$
valueString = valueString.substring(1);
}
int space = valueString.indexOf(":"); //$NON-NLS-1$
if (space != -1) {
valueString = valueString.substring(0, space).trim();
}
try{
try {
return ((Target)getTarget()).getAddressFactory().createAddress(valueString);
}
catch(Exception e)
{
return MIFormat.getBigInteger(valueString);
} catch(Exception e){
return null;
}

View file

@ -20,7 +20,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput;
public class MIGDBShowAddressSize extends MIGDBShow {
public MIGDBShowAddressSize () {
super(new String[] { "remoteaddresssize" });
super(new String[] { "remoteaddresssize" }); //$NON-NLS-1$
}
public MIInfo getMIInfo() throws MIException {

View file

@ -10,9 +10,9 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.event;
import org.eclipse.cdt.debug.mi.core.MISession;
import java.math.BigInteger;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.mi.core.MISession;
/**
* This can not be detected yet by gdb/mi.
@ -20,18 +20,18 @@ import org.eclipse.cdt.core.IAddress;
*/
public class MIMemoryChangedEvent extends MIChangedEvent {
IAddress[] addresses;
BigInteger[] addresses;
public MIMemoryChangedEvent(MISession source, IAddress[] addrs) {
public MIMemoryChangedEvent(MISession source, BigInteger[] addrs) {
this(source, 0, addrs);
}
public MIMemoryChangedEvent(MISession source, int token, IAddress[] addrs) {
public MIMemoryChangedEvent(MISession source, int token, BigInteger[] addrs) {
super(source, token);
addresses = addrs;
}
public IAddress[] getAddresses() {
public BigInteger[] getAddresses() {
return addresses;
}
}

View file

@ -10,7 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.event;
import org.eclipse.cdt.core.IAddress;
import java.math.BigInteger;
import org.eclipse.cdt.debug.mi.core.MISession;
@ -21,20 +22,20 @@ import org.eclipse.cdt.debug.mi.core.MISession;
*/
public class MIMemoryCreatedEvent extends MICreatedEvent {
IAddress address;
BigInteger address;
long totalBytes;
public MIMemoryCreatedEvent(MISession source, IAddress addr, long total) {
public MIMemoryCreatedEvent(MISession source, BigInteger addr, long total) {
this(source, 0, addr, total);
}
public MIMemoryCreatedEvent(MISession source, int token, IAddress addr, long total) {
public MIMemoryCreatedEvent(MISession source, int token, BigInteger addr, long total) {
super(source, token);
address = addr;
totalBytes = total;
}
public IAddress getAddress() {
public BigInteger getAddress() {
return address;
}

View file

@ -14,12 +14,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* GDB/MI thread list parsing.
&"info shared\n"
~"From To Syms Read Shared Object Library\n"
~"0x40042fa0 0x4013ba9b Yes /lib/i686/libc.so.6\n"
~"0x40001db0 0x4001321c Yes /lib/ld-linux.so.2\n"
*
*/
public class MIInfoSharedLibraryInfo extends MIInfo {
@ -80,8 +75,8 @@ public class MIInfoSharedLibraryInfo extends MIInfo {
if (str.length() > 0) {
// Pass the header
int index = -1;
String from = "";
String to = "";
String from = ""; //$NON-NLS-1$
String to = ""; //$NON-NLS-1$
boolean syms = false;
String name = ""; //$NON-NLS-1$
@ -117,8 +112,8 @@ public class MIInfoSharedLibraryInfo extends MIInfo {
}
void parseWinShared(String str, List aList) {
String from = "";
String to = "";
String from = ""; //$NON-NLS-1$
String to = ""; //$NON-NLS-1$
boolean syms = true;
int index = str.lastIndexOf(' ');

View file

@ -73,7 +73,7 @@ public class GDBDebugger implements ICDebugger {
String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); //$NON-NLS-1$
File cwd = exe.getProject().getLocation().toFile();
String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit"); //$NON-NLS-1$
session = (Session)MIPlugin.getDefault().createCSession(gdb, exe, cwd, gdbinit);
session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), cwd, gdbinit);
initializeLibraries(config, session);
return session;
} catch (IOException e) {
@ -105,7 +105,7 @@ public class GDBDebugger implements ICDebugger {
String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); //$NON-NLS-1$
File cwd = exe.getProject().getLocation().toFile();
String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit"); //$NON-NLS-1$
session = (Session)MIPlugin.getDefault().createCSession(gdb, exe, pid, null, cwd, gdbinit);
session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), pid, null, cwd, gdbinit);
initializeLibraries(config, session);
return session;
} catch (IOException e) {
@ -137,7 +137,7 @@ public class GDBDebugger implements ICDebugger {
String gdb = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); //$NON-NLS-1$
File cwd = exe.getProject().getLocation().toFile();
String gdbinit = config.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, ".gdbinit"); //$NON-NLS-1$
session = (Session)MIPlugin.getDefault().createCSession(gdb, exe, corefile.toFile(), cwd, gdbinit);
session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), corefile.toFile(), cwd, gdbinit);
initializeLibraries(config, session);
return session;
} catch (IOException e) {

View file

@ -69,7 +69,7 @@ public class GDBServerDebugger implements ICDebugger {
remote += ":"; //$NON-NLS-1$
remote += config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, "invalid"); //$NON-NLS-1$
String[] args = new String[] {"remote", remote}; //$NON-NLS-1$
session = (Session)MIPlugin.getDefault().createCSession(gdb, exe, 0, args, cwd, gdbinit);
session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), 0, args, cwd, gdbinit);
} else {
MIPlugin plugin = MIPlugin.getDefault();
Preferences prefs = plugin.getPluginPreferences();
@ -77,7 +77,7 @@ public class GDBServerDebugger implements ICDebugger {
String remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid"); //$NON-NLS-1$
String remoteBaud = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "invalid"); //$NON-NLS-1$
session = (Session)MIPlugin.getDefault().createCSession(gdb, exe, -1, null, cwd, gdbinit);
session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), -1, null, cwd, gdbinit);
ICDITarget[] targets = session.getTargets();
for (int i = 0; i < targets.length; ++i) {
Target target = (Target)targets[i];

View file

@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core;
import java.math.BigInteger;
/**
* Help class to specify formats.
*/
@ -31,4 +33,40 @@ public final class MIFormat {
// no instanciation.
private MIFormat() {
}
public static BigInteger getBigInteger(String address) {
int index = 0;
int radix = 10;
boolean negative = false;
// Handle zero length
address = address.trim();
if (address.length() == 0) {
return BigInteger.ZERO;
}
// Handle minus sign, if present
if (address.startsWith("-")) { //$NON-NLS-1$
negative = true;
index++;
}
if (address.startsWith("0x", index) || address.startsWith("0X", index)) { //$NON-NLS-1$ //$NON-NLS-2$
index += 2;
radix = 16;
} else if (address.startsWith("#", index)) { //$NON-NLS-1$
index ++;
radix = 16;
} else if (address.startsWith("0", index) && address.length() > 1 + index) { //$NON-NLS-1$
index ++;
radix = 8;
}
if (index > 0) {
address = address.substring(index);
}
if (negative) {
address = "-" + address; //$NON-NLS-1$
}
return new BigInteger(address, radix);
}
}

View file

@ -21,10 +21,6 @@ import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.mi.core.cdi.Session;
import org.eclipse.cdt.debug.mi.core.command.CLICommand;
@ -34,8 +30,6 @@ import org.eclipse.cdt.debug.mi.core.command.MITargetSelect;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Preferences;
import org.osgi.framework.BundleContext;
@ -119,7 +113,7 @@ public class MIPlugin extends Plugin {
* @return ICDISession
* @throws MIException
*/
public ICDISession createCSession(String gdb, IFile program, File cwd, String gdbinit) throws IOException, MIException {
public ICDISession createCSession(String gdb, File program, File cwd, String gdbinit) throws IOException, MIException {
PTY pty = null;
boolean failed = false;
@ -162,7 +156,7 @@ public class MIPlugin extends Plugin {
* @return ICDISession
* @throws IOException
*/
public ICDISession createCSession(String gdb, IFile program, File cwd, String gdbinit, PTY pty) throws IOException, MIException {
public ICDISession createCSession(String gdb, File program, File cwd, String gdbinit, PTY pty) throws IOException, MIException {
if (gdb == null || gdb.length() == 0) {
gdb = GDB;
}
@ -176,13 +170,13 @@ public class MIPlugin extends Plugin {
if (program == null) {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-tty", pty.getSlaveName(), "-i", "mi1"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
} else {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-tty", pty.getSlaveName(), "-i", "mi1", program.getLocation().toFile().getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-tty", pty.getSlaveName(), "-i", "mi1", program.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
}
} else {
if (program == null) {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-i", "mi1"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
} else {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-i", "mi1", program.getLocation().toFile().getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "-q", "-nw", "-i", "mi1", program.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
}
}
@ -212,7 +206,7 @@ public class MIPlugin extends Plugin {
// If an exception is thrown that means ok
// we did not attach to any target.
}
return new Session(session, getAddressFactory(program), false);
return new Session(session, false);
}
/**
@ -222,7 +216,7 @@ public class MIPlugin extends Plugin {
* @return ICDISession
* @throws IOException
*/
public ICDISession createCSession(String gdb, IFile program, File core, File cwd, String gdbinit) throws IOException, MIException {
public ICDISession createCSession(String gdb, File program, File core, File cwd, String gdbinit) throws IOException, MIException {
if (gdb == null || gdb.length() == 0) {
gdb = GDB;
}
@ -235,7 +229,7 @@ public class MIPlugin extends Plugin {
if (program == null) {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", "-c", core.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
} else {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", "-c", core.getAbsolutePath(), program.getLocation().toFile().getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", "-c", core.getAbsolutePath(), program.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
}
Process pgdb = getGDBProcess(args);
MISession session;
@ -245,7 +239,7 @@ public class MIPlugin extends Plugin {
pgdb.destroy();
throw e;
}
return new Session(session, getAddressFactory(program));
return new Session(session);
}
/**
@ -255,7 +249,7 @@ public class MIPlugin extends Plugin {
* @return ICDISession
* @throws IOException
*/
public ICDISession createCSession(String gdb, IFile program, int pid, String[] targetParams, File cwd, String gdbinit) throws IOException, MIException {
public ICDISession createCSession(String gdb, File program, int pid, String[] targetParams, File cwd, String gdbinit) throws IOException, MIException {
if (gdb == null || gdb.length() == 0) {
gdb = GDB;
}
@ -268,7 +262,7 @@ public class MIPlugin extends Plugin {
if (program == null) {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
} else {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", program.getLocation().toFile().getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", program.getAbsolutePath()}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
}
Process pgdb = getGDBProcess(args);
MISession session;
@ -304,7 +298,7 @@ public class MIPlugin extends Plugin {
//@@@ We have to manually set the suspended state when we attach
session.getMIInferior().setSuspended();
session.getMIInferior().update();
return new Session(session, getAddressFactory(program), true);
return new Session(session, true);
}
/**
@ -429,16 +423,6 @@ public class MIPlugin extends Plugin {
getPluginPreferences().setDefault(IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT, IMIConstants.DEF_REQUEST_LAUNCH_TIMEOUT);
}
protected IAddressFactory getAddressFactory(IFile exe)
{
ICElement cFile = CCorePlugin.getDefault().getCoreModel().create( exe );
if ( cFile instanceof IBinary )
{
return ((IBinary)cFile).getAddressFactory();
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugin#shutdown()
*/