diff -NaurbB workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IBinaryElement.java workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IBinaryElement.java --- workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IBinaryElement.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IBinaryElement.java 2004-09-17 09:03:15.000000000 +0400 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.core.model; +import org.eclipse.cdt.core.IAddress; + /** */ @@ -22,7 +24,7 @@ * @exception CModelException if this element does not have address * information. */ - long getAddress() throws CModelException; + IAddress getAddress() throws CModelException; /** * Returns the binary object the element belongs to. diff -NaurbB workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IBinary.java workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IBinary.java --- workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IBinary.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IBinary.java 2004-09-17 09:03:15.000000000 +0400 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.core.model; +import org.eclipse.cdt.core.IAddressFactory; + /** * Represents a Binary file, for example an ELF excutable. @@ -43,4 +45,6 @@ public boolean isLittleEndian(); + public IAddressFactory getAddressFactory(); + } diff -NaurbB workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryElement.java workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryElement.java --- workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryElement.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryElement.java 2004-09-17 09:03:15.000000000 +0400 @@ -7,6 +7,7 @@ import java.io.IOException; import java.util.Map; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.IBinaryElement; @@ -27,9 +28,9 @@ */ public class BinaryElement extends CElement implements IBinaryElement, ISourceManipulation, ISourceReference { - long addr; + IAddress addr; - public BinaryElement(ICElement parent, String name, int type, long a) { + public BinaryElement(ICElement parent, String name, int type, IAddress a) { super(parent, name, type); addr = a; } @@ -153,7 +154,7 @@ /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IBinaryElement#getAddress() */ - public long getAddress() throws CModelException { + public IAddress getAddress() throws CModelException { return addr; } diff -NaurbB workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryFunction.java workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryFunction.java --- workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryFunction.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryFunction.java 2004-09-17 09:03:15.000000000 +0400 @@ -11,6 +11,7 @@ package org.eclipse.cdt.internal.core.model; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.model.IBinaryFunction; import org.eclipse.cdt.core.model.ICElement; @@ -18,7 +19,7 @@ */ public class BinaryFunction extends BinaryElement implements IBinaryFunction { - public BinaryFunction(ICElement parent, String name, long a) { + public BinaryFunction(ICElement parent, String name, IAddress a) { super(parent, name, ICElement.C_FUNCTION, a); } diff -NaurbB workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java --- workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java 2004-09-17 09:03:15.000000000 +0400 @@ -17,6 +17,7 @@ import java.util.HashMap; import java.util.Map; +import org.eclipse.cdt.core.IAddressFactory; import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable; import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; @@ -43,6 +44,7 @@ private long longBSS; private String endian; private String soname; + private IAddressFactory addressFactory; private long fLastModification; @@ -172,6 +174,15 @@ return binaryObject; } + public IAddressFactory getAddressFactory() { + if (isObject() || isExecutable() || isSharedLib() || isCore()) { + if (addressFactory == null || hasChanged()) { + addressFactory = getBinaryObject().getAddressFactory(); + } + } + return addressFactory; + } + protected int getType() { IBinaryObject obj = getBinaryObject(); if (obj != null && (fBinType == 0 || hasChanged())) { @@ -193,6 +204,7 @@ longData = -1; longText = -1; soname = null; + addressFactory = null; } return changed; } diff -NaurbB workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryModule.java workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryModule.java --- workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryModule.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryModule.java 2004-09-17 09:03:15.000000000 +0400 @@ -13,6 +13,7 @@ import java.util.Map; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.IBinaryElement; @@ -47,8 +48,8 @@ /* (non-Javadoc) * @see org.eclipse.cdt.core.model.IBinaryElement#getAddress() */ - public long getAddress() throws CModelException { - return 0; + public IAddress getAddress() throws CModelException { + return null; } /* (non-Javadoc) diff -NaurbB workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryVariable.java workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryVariable.java --- workspace-orig/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryVariable.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryVariable.java 2004-09-17 09:03:15.000000000 +0400 @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.model; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IVariable; @@ -18,7 +19,7 @@ */ public class BinaryVariable extends BinaryElement implements IVariable { - public BinaryVariable(ICElement parent, String name, long a) { + public BinaryVariable(ICElement parent, String name, IAddress a) { super(parent, name, ICElement.C_VARIABLE, a); } diff -NaurbB workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr32Factory.java workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr32Factory.java --- workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr32Factory.java 1970-01-01 03:00:00.000000000 +0300 +++ workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr32Factory.java 2004-09-17 09:01:33.000000000 +0400 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2004 Intel Corporation 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: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core; + + +/* + */ +final public class Addr32Factory implements IAddressFactory +{ + + final public IAddress getZero() + { + return Addr32.ZERO; + } + + final public IAddress getMax() + { + return Addr32.MAX; + } + + final public IAddress createAddress(String addr) + { + IAddress address=new Addr32(addr); + return address; + } + + final public IAddress createAddress(String addr, int radix) + { + IAddress address=new Addr32(addr, radix); + return address; + } + +} diff -NaurbB workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr32.java workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr32.java --- workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr32.java 1970-01-01 03:00:00.000000000 +0300 +++ workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr32.java 2004-09-17 09:01:33.000000000 +0400 @@ -0,0 +1,141 @@ +/******************************************************************************* + * Copyright (c) 2004 Intel Corporation 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: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core; + +import java.math.BigInteger; + +/* + */ +final public class Addr32 implements IAddress +{ + public static final Addr32 ZERO=new Addr32(0); + public static final Addr32 MAX=new Addr32(0xffffffffL); + + public static final BigInteger MAX_OFFSET = BigInteger.valueOf(0xffffffffL); + + public static final int BYTES_NUM = 4; + public static final int DIGITS_NUM = BYTES_NUM * 2; + public static final int CHARS_NUM = DIGITS_NUM + 2; + + private long address; + + /* + * addrBytes should be 4 bytes length + */ + public Addr32(byte [] addrBytes) + { + /*We should mask out sign bits to have correct value*/ + this.address = ( ( ((long)addrBytes[0]) << 24 ) & 0xFF000000L) + + ( ( ((long)addrBytes[1]) << 16 ) & 0x00FF0000L) + + ( ( ((long)addrBytes[2]) << 8 ) & 0x0000FF00L) + + ( ((long)addrBytes[3]) & 0x000000FFL); + } + + public Addr32(long rawaddress) + { + this.address=rawaddress; + } + + public Addr32(String addr) + { + addr = addr.toLowerCase(); + if ( addr.startsWith( "0x" ) ) + { + this.address = Long.parseLong(addr.substring(2), 16); + } + else + { + this.address = Long.parseLong(addr, 10); + } + } + + public Addr32(String addr, int radix) + { + this.address=Long.parseLong(addr, radix); + } + + final public IAddress add(BigInteger offset) + { + return new Addr32(this.address + offset.longValue()); + } + + final public BigInteger getMaxOffset() + { + return MAX_OFFSET; + } + + final public BigInteger distance(IAddress other) + { + return BigInteger.valueOf(address - ((Addr32)other).address); + } + + final public int compareTo(IAddress addr) + { + if (address > ((Addr32)addr).address) + { + return 1; + } + if (address < ((Addr32)addr).address) + { + return -1; + } + return 0; + } + + final public boolean isMax() + { + return address == MAX.address; + } + + final public boolean isZero() + { + return address == ZERO.address; + } + + final public String toString() + { + return toString(10); + } + + final public String toString(int radix) + { + return Long.toString(address, radix); + } + + final public boolean equals(IAddress x) + { + if (x == this) + return true; + if (!(x instanceof Addr32)) + return false; + return this.address == ((Addr32)x).address; + } + + final public String toHexAddressString( ) + { + String addressString = Long.toString(address,16); + StringBuffer sb = new StringBuffer( CHARS_NUM ); + int count = DIGITS_NUM - addressString.length(); + sb.append( "0x" ); + for ( int i = 0; i < count ; ++i ) + { + sb.append( '0' ); + } + sb.append( addressString ); + return sb.toString(); + } + + final public int getCharsNum() + { + return CHARS_NUM; + } + +} diff -NaurbB workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr64Factory.java workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr64Factory.java --- workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr64Factory.java 1970-01-01 03:00:00.000000000 +0300 +++ workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr64Factory.java 2004-09-17 09:01:33.000000000 +0400 @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2004 Intel Corporation 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: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core; + + +/* + */ +final public class Addr64Factory implements IAddressFactory{ + + final public IAddress getZero() + { + return Addr64.ZERO; + } + + final public IAddress getMax() + { + return Addr64.MAX; + } + + final public IAddress createAddress(String addr) + { + IAddress address=new Addr64(addr); + return address; + } + + final public IAddress createAddress(String addr, int radix) + { + IAddress address=new Addr64(addr, radix); + return address; + } +} diff -NaurbB workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr64.java workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr64.java --- workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr64.java 1970-01-01 03:00:00.000000000 +0300 +++ workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/Addr64.java 2004-09-17 09:01:33.000000000 +0400 @@ -0,0 +1,128 @@ +/******************************************************************************* + * Copyright (c) 2004 Intel Corporation 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: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core; + +import java.math.BigInteger; + +/* + */ +final public class Addr64 implements IAddress +{ + public static final Addr64 ZERO=new Addr64("0"); + public static final Addr64 MAX=new Addr64("ffffffffffffffff",16); + + public static final BigInteger MAX_OFFSET = new BigInteger("ffffffffffffffff",16); + + public static final int BYTES_NUM = 8; + public static final int DIGITS_NUM = BYTES_NUM * 2; + public static final int CHARS_NUM = DIGITS_NUM + 2; + + private BigInteger address; + + public Addr64(byte [] addrBytes) + { + if( addrBytes.length != 8) + throw(new NumberFormatException("Invalid address array")); + this.address = new BigInteger(1, addrBytes); + } + + public Addr64(BigInteger rawaddress) + { + this.address=rawaddress; + } + + public Addr64(String addr) + { + addr = addr.toLowerCase(); + if ( addr.startsWith( "0x" ) ) + { + this.address = new BigInteger(addr.substring(2), 16); + } + else + { + this.address = new BigInteger(addr, 10); + } + } + + public Addr64(String addr, int radix) + { + this.address=new BigInteger(addr, radix); + } + + final public IAddress add(BigInteger offset) + { + return new Addr64(this.address.add(offset)); + } + + final public BigInteger getMaxOffset() + { + return MAX_OFFSET; + } + + final public BigInteger distance(IAddress other) + { + return address.add(((Addr64)other).address.negate()); + } + + final public boolean isMax() + { + return address.equals(MAX); + } + + final public boolean isZero() + { + return address.equals(ZERO); + } + + final public int compareTo(IAddress addr) + { + return this.address.compareTo(((Addr64)addr).address); + } + + final public boolean equals(IAddress x) + { + if (x == this) + return true; + if (!(x instanceof Addr64)) + return false; + return this.address.equals(((Addr64)x).address); + } + + final public String toString() + { + return toString(10); + } + + final public String toString(int radix) + { + return address.toString(radix); + } + + final public String toHexAddressString( ) + { + String addressString = address.toString(16); + StringBuffer sb = new StringBuffer( CHARS_NUM ); + int count = DIGITS_NUM - addressString.length(); + sb.append( "0x" ); + for ( int i = 0; i < count; ++i ) + { + sb.append( '0' ); + } + sb.append( addressString ); + return sb.toString(); + } + + final public int getCharsNum() + { + return CHARS_NUM; + } +} + diff -NaurbB workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IAddressFactory.java workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IAddressFactory.java --- workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IAddressFactory.java 1970-01-01 03:00:00.000000000 +0300 +++ workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IAddressFactory.java 2004-09-17 09:01:33.000000000 +0400 @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2004 Intel Corporation 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: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core; + + +/* + * This inteface serves as an address factory. If you need to + * implement your own addresses, you should extend this. + * + * Please see Addr32Factory and Addr64Factory to see how it can be implemented. + */ +public interface IAddressFactory +{ + /* + * Returns zero address, i.e. minimal possible address + */ + IAddress getZero(); + /* + * Returns maximal address. + */ + IAddress getMax(); + /* + * Creates address from string representation. + * + * 1. This method should be able to create address from hex + * address string (string produced with + * IAddress.toHexAddressString() method). + * 2. Method should be case insensetive + * 3. Method should be able to create address from decimal address + * representation + * + * Please see Addr32Factory.createAddress() for reference implementation. + */ + IAddress createAddress(String addr); + /* + * Creates address from string with given radix. + * + * Given string should not contain any prefixes or sign numbers. + * + * Method should be case insensetive + */ + IAddress createAddress(String addr, int radix); +} diff -NaurbB workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IAddress.java workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IAddress.java --- workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IAddress.java 1970-01-01 03:00:00.000000000 +0300 +++ workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IAddress.java 2004-09-17 09:02:01.000000000 +0400 @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2004 Intel Corporation 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: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core; + +import java.math.BigInteger; + +/* + * Represents C/C++ address in CDT. All implementors of this inteface should be + * immutable, i.e. all methods should not modify objects, they should return + * new object. + * + * Please see Addr32 and Addr64 classes to see how this interface should + * be extended + */ +public interface IAddress +{ + /* + * Return adds offset to address and returns new address object + * which is the result + */ + IAddress add(BigInteger offset); + /* + * Returns maximal offset possible for address. The offset + * should be Identicall for all addresses of given class. + */ + BigInteger getMaxOffset(); + /* + * Returns distance between two addresses. Distance may be positive or negative + */ + BigInteger distance(IAddress other); + /* + * Compares two addresses. + * + * Returns: + * -1 if this < addr + * 0 if this == addr + * 1 if this > addr + */ + int compareTo(IAddress addr); + /* + * Returns true if addresses are equal + */ + boolean equals(IAddress addr); + /* + * Return true if address is zero, i.e. minimal possible + */ + boolean isZero(); + /* + * Return true if address is maximal, i.e. maximal possible + */ + boolean isMax(); + + /* + * Converts address to string as an unsigned number with given radix + */ + String toString(int radix); + /* + * Identical to toString(10) + */ + String toString(); + /* + * Converts address to the hex representation with '0x' prefix and + * with all leading zeros. The length of returned string should be + * the same for all addresses of given class. I.e. 10 for 32-bit + * addresses and 18 for 64-bit addresses + */ + String toHexAddressString(); + + /* + * Returns amount of symbols in hex representation. Is identical to + * toHexAddressString().length(). It is present for perfomance purpose. + */ + int getCharsNum(); + +} diff -NaurbB workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IBinaryParser.java workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IBinaryParser.java --- workspace-orig/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IBinaryParser.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IBinaryParser.java 2004-09-17 09:01:33.000000000 +0400 @@ -121,7 +121,7 @@ * @param addr * @return ISymbol */ - ISymbol getSymbol(long addr); + ISymbol getSymbol(IAddress addr); /** * The name of the object @@ -129,6 +129,7 @@ */ String getName(); + IAddressFactory getAddressFactory(); } /** @@ -176,7 +177,7 @@ * Address of the symbol * @return */ - long getAddress(); + IAddress getAddress(); /** * Size of the symbol. diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr2line.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr2line.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr2line.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr2line.java 2004-09-17 09:03:57.000000000 +0400 @@ -15,7 +15,9 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.math.BigInteger; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.utils.spawner.ProcessFactory; public class Addr2line { @@ -61,13 +63,13 @@ } } - public String getLine(long address) throws IOException { - getOutput(Integer.toHexString((int)address)); + public String getLine(IAddress address) throws IOException { + getOutput(address.toString(16)); return lastline; } - public String getFunction(long address) throws IOException { - getOutput(Integer.toHexString((int)address)); + public String getFunction(IAddress address) throws IOException { + getOutput(address.toString(16)); return lastsymbol; } @@ -78,7 +80,7 @@ * main * hello.c:39 */ - public String getFileName(long address) throws IOException { + public String getFileName(IAddress address) throws IOException { String filename = null; String line = getLine(address); int index1, index2; @@ -103,12 +105,14 @@ * main * hello.c:39 */ - public int getLineNumber(long address) throws IOException { + public int getLineNumber(IAddress address) throws IOException { // We try to get the nearest match // since the symbol may not exactly align with debug info. // In C line number 0 is invalid, line starts at 1 for file, we use // this for validation. - for (int i = 0; i <= 20; i += 4, address += i) { + + //IPF_TODO: check + for (int i = 0; i <= 20; i += 4, address = address.add(BigInteger.valueOf(i))) { String line = getLine(address); if (line != null) { int colon = line.lastIndexOf(':'); diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/BinaryObjectAdapter.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/BinaryObjectAdapter.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/BinaryObjectAdapter.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/BinaryObjectAdapter.java 2004-09-17 09:03:57.000000000 +0400 @@ -10,8 +10,11 @@ *******************************************************************************/ package org.eclipse.cdt.utils; +import java.math.BigInteger; import java.util.Arrays; +import org.eclipse.cdt.core.IAddress; +import org.eclipse.cdt.core.IAddressFactory; import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; @@ -35,6 +38,7 @@ public String soname; public String[] needed; public String cpu; + public IAddressFactory addressFactory; public BinaryObjectInfo() { cpu = soname = ""; //$NON-NLS-1$ @@ -49,9 +53,9 @@ /* (non-Javadoc) * @see org.eclipse.cdt.core.IBinaryParser.IBinaryObject#getSymbol(long) */ - public ISymbol getSymbol(long addr) { + public ISymbol getSymbol(IAddress addr) { ISymbol[] syms = getSymbols(); - int insertion = Arrays.binarySearch(syms, new Long(addr)); + int insertion = Arrays.binarySearch(syms, addr); if (insertion >= 0) { return syms[insertion]; } @@ -60,7 +64,7 @@ } insertion = -insertion - 1; ISymbol symbol = syms[insertion - 1]; - if (addr < (symbol.getAddress() + symbol.getSize())) { + if (addr.compareTo(symbol.getAddress().add(BigInteger.valueOf(symbol.getSize()))) < 0) { return syms[insertion - 1]; } return null; @@ -153,7 +157,14 @@ } return ""; //$NON-NLS-1$ } - + public IAddressFactory getAddressFactory() + { + BinaryObjectInfo info = getBinaryObjectInfo(); + if (info != null) { + return info.addressFactory; + } + return null; //$NON-NLS-1$ + } /** * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryObject#getName() */ diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/ARMember.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/ARMember.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/ARMember.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/ARMember.java 2004-09-17 09:03:57.000000000 +0400 @@ -15,6 +15,7 @@ import java.io.InputStream; import java.util.List; +import org.eclipse.cdt.core.Addr32; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser.ISymbol; @@ -77,7 +78,7 @@ continue; } int type = peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE; - list.add(new Symbol(this, name, type, peSyms[i].n_value, 1)); + list.add(new Symbol(this, name, type, new Addr32(peSyms[i].n_value), 1)); } } } diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinPEBinaryObject.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinPEBinaryObject.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinPEBinaryObject.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinPEBinaryObject.java 2004-09-17 09:03:57.000000000 +0400 @@ -11,8 +11,11 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.math.BigInteger; import java.util.List; +import org.eclipse.cdt.core.Addr32; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IBinaryParser.ISymbol; import org.eclipse.cdt.utils.Addr2line; import org.eclipse.cdt.utils.CPPFilt; @@ -147,7 +150,7 @@ continue; } int type = peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE; - int addr = peSyms[i].n_value; + IAddress addr = new Addr32(peSyms[i].n_value); int size = 4; if (cppfilt != null) { try { @@ -172,7 +175,7 @@ } IPath file = filename != null ? new Path(filename) : Path.EMPTY; int startLine = addr2line.getLineNumber(addr); - int endLine = addr2line.getLineNumber(addr + size - 1); + int endLine = addr2line.getLineNumber(addr.add(BigInteger.valueOf(size - 1))); list.add(new CygwinSymbol(this, name, type, addr, size, file, startLine, endLine)); } catch (IOException e) { addr2line = null; diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinSymbol.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinSymbol.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinSymbol.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinSymbol.java 2004-09-17 09:03:57.000000000 +0400 @@ -7,7 +7,9 @@ package org.eclipse.cdt.utils.coff.parser; import java.io.IOException; +import java.math.BigInteger; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.utils.Addr2line; import org.eclipse.cdt.utils.Symbol; import org.eclipse.core.runtime.IPath; @@ -31,7 +33,7 @@ * @param startLine * @param endLine */ - public CygwinSymbol(CygwinPEBinaryObject binary, String name, int type, long addr, long size, IPath sourceFile, int startLine, + public CygwinSymbol(CygwinPEBinaryObject binary, String name, int type, IAddress addr, long size, IPath sourceFile, int startLine, int endLine) { super(binary, name, type, addr, size, sourceFile, startLine, endLine); } @@ -43,7 +45,7 @@ * @param addr * @param size */ - public CygwinSymbol(CygwinPEBinaryObject binary, String name, int type, long addr, long size) { + public CygwinSymbol(CygwinPEBinaryObject binary, String name, int type, IAddress addr, long size) { super(binary, name, type, addr, size); } @@ -55,7 +57,7 @@ Addr2line addr2line = ((CygwinPEBinaryObject)binary).getAddr2line(true); if (addr2line != null) { try { - return addr2line.getLineNumber(getAddress() + offset); + return addr2line.getLineNumber(getAddress().add(BigInteger.valueOf(offset))); } catch (IOException e) { // ignore } diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/PEBinaryObject.java 2004-09-17 09:03:57.000000000 +0400 @@ -15,6 +15,7 @@ import java.util.Arrays; import java.util.List; +import org.eclipse.cdt.core.Addr32; import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; import org.eclipse.cdt.core.IBinaryParser.ISymbol; @@ -107,6 +108,7 @@ info.isLittleEndian = attribute.isLittleEndian(); info.hasDebug = attribute.hasDebug(); info.cpu = attribute.getCPU(); + info.addressFactory = attribute.getAddressFactory(); } protected void loadSymbols(PE pe) throws IOException { @@ -129,7 +131,7 @@ continue; } int type = peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE; - list.add(new Symbol(this, name, type, peSyms[i].n_value, 1)); + list.add(new Symbol(this, name, type, new Addr32(peSyms[i].n_value), 1)); } } } diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/PE.java 2004-09-17 09:03:57.000000000 +0400 @@ -14,7 +14,9 @@ import java.io.IOException; import java.io.RandomAccessFile; +import org.eclipse.cdt.core.Addr32Factory; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.IAddressFactory; import org.eclipse.cdt.utils.coff.Coff.FileHeader; import org.eclipse.cdt.utils.coff.Coff.OptionalHeader; import org.eclipse.cdt.utils.coff.Coff.SectionHeader; @@ -84,6 +86,7 @@ int word; boolean bDebug; boolean isle; + IAddressFactory addrFactory; public String getCPU() { return cpu; @@ -104,6 +107,11 @@ public int getWord() { return word; } + + public IAddressFactory getAddressFactory(){ + return addrFactory; + } + } /** @@ -462,6 +470,8 @@ if ((filhdr.f_flags & PEConstants.IMAGE_FILE_32BIT_MACHINE) != 0) { attrib.word = 32; } + + attrib.addrFactory = new Addr32Factory(); return attrib; } diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java 2004-09-17 09:03:57.000000000 +0400 @@ -17,10 +17,21 @@ import java.util.Arrays; import java.util.Comparator; +import org.eclipse.cdt.core.Addr32; +import org.eclipse.cdt.core.Addr32Factory; +import org.eclipse.cdt.core.Addr64; +import org.eclipse.cdt.core.Addr64Factory; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.IAddress; +import org.eclipse.cdt.core.IAddressFactory; // test checkin public class Elf { + public final static int ELF32_ADDR_SIZE = 4; + public final static int ELF32_OFF_SIZE = 4; + public final static int ELF64_ADDR_SIZE = 8; + public final static int ELF64_OFF_SIZE = 8; + protected ERandomAccessFile efile; protected ELFhdr ehdr; @@ -52,7 +63,7 @@ /* e_ident[EI_CLASS] */ public final static int ELFCLASSNONE = 0; - public final static int ELCLASS32 = 1; + public final static int ELFCLASS32 = 1; public final static int ELFCLASS64 = 2; /* e_ident[EI_DATA] */ @@ -117,7 +128,7 @@ public int e_type; /* file type (Elf32_Half) */ public int e_machine; /* machine type (Elf32_Half) */ public long e_version; /* version number (Elf32_Word) */ - public long e_entry; /* entry point (Elf32_Addr)*/ + public IAddress e_entry; /* entry point (Elf32_Addr)*/ public long e_phoff; /* Program hdr offset (Elf32_Off)*/ public long e_shoff; /* Section hdr offset (Elf32_Off)*/ public long e_flags; /* Processor flags (Elf32_Word)*/ @@ -138,9 +149,30 @@ e_type = efile.readShortE(); e_machine = efile.readShortE(); e_version = efile.readIntE(); - e_entry = efile.readIntE(); + switch (e_ident[ELFhdr.EI_CLASS]) + { + case ELFhdr.ELFCLASS32: + { + byte[] addrArray = new byte[ELF32_ADDR_SIZE]; + efile.readFullyE(addrArray); + e_entry = new Addr32(addrArray); e_phoff = efile.readIntE(); e_shoff = efile.readIntE(); + } + break; + case ELFhdr.ELFCLASS64: + { + byte[] addrArray = new byte[ELF64_ADDR_SIZE]; + efile.readFullyE(addrArray); + e_entry = new Addr64(addrArray); + e_phoff = readUnsignedLong(efile); + e_shoff = readUnsignedLong(efile); + } + break; + case ELFhdr.ELFCLASSNONE: + default: + throw new IOException("Unknown ELF class " + e_ident[ELFhdr.EI_CLASS]); + } e_flags = efile.readIntE(); e_ehsize = efile.readShortE(); e_phentsize = efile.readShortE(); @@ -163,9 +195,30 @@ e_type = makeShort(bytes, offset, isle); offset += 2; e_machine = makeShort(bytes, offset, isle); offset += 2; e_version = makeInt(bytes, offset, isle); offset += 4; - e_entry = makeInt(bytes, offset, isle); offset += 4; - e_phoff = makeInt(bytes, offset, isle); offset += 4; - e_shoff = makeInt(bytes, offset, isle); offset += 4; + switch (e_ident[ELFhdr.EI_CLASS]) + { + case ELFhdr.ELFCLASS32: + { + byte[] addrArray = new byte[ELF32_ADDR_SIZE]; + System.arraycopy(bytes, offset, addrArray, 0, ELF32_ADDR_SIZE); offset += ELF32_ADDR_SIZE; + e_entry = new Addr32(addrArray); + e_phoff = makeInt(bytes, offset, isle); offset += ELF32_OFF_SIZE; + e_shoff = makeInt(bytes, offset, isle); offset += ELF32_OFF_SIZE; + } + break; + case ELFhdr.ELFCLASS64: + { + byte[] addrArray = new byte[ELF64_ADDR_SIZE]; + System.arraycopy(bytes, offset, addrArray, 0, ELF64_ADDR_SIZE); offset += ELF64_ADDR_SIZE; + e_entry = new Addr64(addrArray); + e_phoff = makeUnsignedLong(bytes, offset, isle); offset += ELF64_OFF_SIZE; + e_shoff = makeUnsignedLong(bytes, offset, isle); offset += ELF64_OFF_SIZE; + } + break; + case ELFhdr.ELFCLASSNONE: + default: + throw new IOException("Unknown ELF class " + e_ident[ELFhdr.EI_CLASS]); + } e_flags = makeInt(bytes, offset, isle); offset += 4; e_ehsize = makeShort(bytes, offset, isle); offset += 2; e_phentsize = makeShort(bytes, offset, isle); offset += 2; @@ -194,6 +247,38 @@ return ((val[offset + 0] << 24) + (val[offset + 1] << 16) + (val[offset + 2] << 8) + val[offset + 3]); } + private final long makeLong(byte [] val, int offset, boolean isle) throws IOException + { + long result = 0; + int shift = 0; + if ( isle ) + for(int i=7; i >= 0; i-- ) + { + shift = i*8; + result += ( ((long)val[offset + i]) << shift ) & ( 0xffL << shift ); + } + else + for(int i=0; i <= 7; i++ ) + { + shift = (7-i)*8; + result += ( ((long)val[offset + i]) << shift ) & ( 0xffL << shift ); + } + return result; + } + + private final long makeUnsignedLong(byte [] val, int offset, boolean isle) throws IOException + { + long result = makeLong(val,offset,isle); + if(result < 0) + { + throw new IOException( "Maximal file offset is " + Long.toHexString(Long.MAX_VALUE) + + " given offset is " + Long.toHexString(result)); + } + return result; + + } + + } @@ -222,7 +307,7 @@ public long sh_name; public long sh_type; public long sh_flags; - public long sh_addr; + public IAddress sh_addr; public long sh_offset; public long sh_size; public long sh_link; @@ -301,9 +386,9 @@ public final static int SHN_XINDEX = 0xffffffff; public final static int SHN_HIRESERVE = 0xffffffff; - + /*NOTE: 64 bit and 32 bit ELF sections has different order*/ public long st_name; - public long st_value; + public IAddress st_value; public long st_size; public short st_info; public short st_other; @@ -326,6 +411,7 @@ } public int compareTo(Object obj) { + /* long thisVal = 0; long anotherVal = 0; if ( obj instanceof Symbol ) { @@ -338,6 +424,8 @@ thisVal = this.st_value; } return (thisVal 0 ) return symbols[ndx]; if ( ndx == -1 ) { @@ -882,7 +1101,7 @@ ndx = -ndx - 1; return symbols[ndx-1]; } - + /* public long swapInt( long val ) { if ( ehdr.e_ident[ELFhdr.EI_DATA] == ELFhdr.ELFDATA2LSB ) { short tmp[] = new short[4]; @@ -904,8 +1123,19 @@ } return val; } - +*/ public String getFilename() { return file; } + + private final long readUnsignedLong(ERandomAccessFile file) throws IOException + { + long result = file.readLongE(); + if(result < 0) + { + throw new IOException( "Maximal file offset is " + Long.toHexString(Long.MAX_VALUE) + + " given offset is " + Long.toHexString(result)); + } + return result; + } } diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/ERandomAccessFile.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/ERandomAccessFile.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/ERandomAccessFile.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/ERandomAccessFile.java 2004-09-17 09:03:57.000000000 +0400 @@ -59,6 +59,40 @@ return ((val[0] << 24) + (val[1] << 16) + (val[2] << 8) + val[3]); } + public final long readLongE() throws IOException + { + byte [] bytes = new byte[8]; + long result = 0; + super.readFully(bytes); + int shift = 0; + if ( isle ) + for(int i=7; i >= 0; i-- ) + { + shift = i*8; + result += ( ((long)bytes[i]) << shift ) & ( 0xffL << shift ); + } + else + for(int i=0; i <= 7; i++ ) + { + shift = (7-i)*8; + result += ( ((long)bytes[i]) << shift ) & ( 0xffL << shift ); + } + return result; + } + + public final void readFullyE(byte [] bytes) throws IOException + { + super.readFully(bytes); + byte tmp = 0; + if( isle ) + for(int i=0; i <= bytes.length / 2; i++) + { + tmp = bytes[i]; + bytes[i] = bytes[bytes.length - i -1]; + bytes[bytes.length - i -1] = tmp; + } + } + public void setFileOffset( long offset ) throws IOException { ptr_offset = offset; super.seek( offset ); diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfBinaryObject.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfBinaryObject.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfBinaryObject.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfBinaryObject.java 2004-09-17 09:03:57.000000000 +0400 @@ -120,6 +120,7 @@ info.isLittleEndian = attribute.isLittleEndian(); info.hasDebug = attribute.hasDebug(); info.cpu = attribute.getCPU(); + info.addressFactory = attribute.getAddressFactory(); } protected void loadSymbols(ElfHelper helper) throws IOException { diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/GNUElfBinaryObject.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/GNUElfBinaryObject.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/GNUElfBinaryObject.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/GNUElfBinaryObject.java 2004-09-17 09:03:57.000000000 +0400 @@ -11,8 +11,10 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.math.BigInteger; import java.util.List; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.utils.Addr2line; import org.eclipse.cdt.utils.CPPFilt; import org.eclipse.cdt.utils.Objdump; @@ -124,7 +126,7 @@ cppfilt = null; } } - long addr = array[i].st_value; + IAddress addr = array[i].st_value; long size = array[i].st_size; if (addr2line != null) { try { @@ -133,7 +135,7 @@ // the file. IPath file = (filename != null && !filename.equals("??")) ? new Path(filename) : Path.EMPTY; //$NON-NLS-1$ int startLine = addr2line.getLineNumber(addr); - int endLine = addr2line.getLineNumber(addr + size - 1); + int endLine = addr2line.getLineNumber(addr.add(BigInteger.valueOf(size - 1))); list.add(new GNUSymbol(this, name, type, addr, size, file, startLine, endLine)); } catch (IOException e) { addr2line = null; diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/GNUSymbol.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/GNUSymbol.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/GNUSymbol.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/GNUSymbol.java 2004-09-17 09:03:57.000000000 +0400 @@ -11,19 +11,21 @@ package org.eclipse.cdt.utils.elf.parser; import java.io.IOException; +import java.math.BigInteger; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.utils.Addr2line; import org.eclipse.cdt.utils.Symbol; import org.eclipse.core.runtime.IPath; public class GNUSymbol extends Symbol { - public GNUSymbol(GNUElfBinaryObject binary, String name, int type, long addr, long size, IPath sourceFile, int startLine, int endLine) { + public GNUSymbol(GNUElfBinaryObject binary, String name, int type, IAddress addr, long size, IPath sourceFile, int startLine, int endLine) { super(binary, name, type, addr, size, sourceFile, startLine, endLine); // TODO Auto-generated constructor stub } - public GNUSymbol(GNUElfBinaryObject binary, String name, int type, long addr, long size) { + public GNUSymbol(GNUElfBinaryObject binary, String name, int type, IAddress addr, long size) { super(binary, name, type, addr, size); } @@ -35,7 +37,7 @@ Addr2line addr2line = ((GNUElfBinaryObject)binary).getAddr2line(true); if (addr2line != null) { try { - return addr2line.getLineNumber(getAddress() + offset); + return addr2line.getLineNumber(getAddress().add(BigInteger.valueOf(offset))); } catch (IOException e) { // ignore } diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/ARMember.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/ARMember.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/ARMember.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/ARMember.java 2004-09-17 09:03:57.000000000 +0400 @@ -15,6 +15,7 @@ import java.io.InputStream; import java.util.List; +import org.eclipse.cdt.core.Addr32; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.utils.Addr2line; @@ -72,7 +73,7 @@ protected void addSymbols(MachO.Symbol[] array, int type, Addr2line addr2line, CPPFilt cppfilt, List list) { for (int i = 0; i < array.length; i++) { - list.add(new Symbol(this, array[i].toString(), type, array[i].n_value, 4)); + list.add(new Symbol(this, array[i].toString(), type, new Addr32(array[i].n_value), 4)); } } diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryObject.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryObject.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryObject.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/macho/parser/MachOBinaryObject.java 2004-09-17 09:03:57.000000000 +0400 @@ -15,6 +15,7 @@ import java.util.Arrays; import java.util.List; +import org.eclipse.cdt.core.Addr32; import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; import org.eclipse.cdt.core.IBinaryParser.ISymbol; @@ -161,7 +162,7 @@ int size = 0; String filename = array[i].getFilename(); IPath filePath = (filename != null) ? new Path(filename) : null; //$NON-NLS-1$ - list.add(new Symbol(this, name, type, array[i].n_value, size, filePath, array[i].getLineNumber(addr), array[i].getLineNumber(addr + size - 1))); + list.add(new Symbol(this, name, type, new Addr32(array[i].n_value), size, filePath, array[i].getLineNumber(addr), array[i].getLineNumber(addr + size - 1))); } } diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/ARMember.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/ARMember.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/ARMember.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/ARMember.java 2004-09-17 09:03:57.000000000 +0400 @@ -15,15 +15,15 @@ import java.io.InputStream; import java.util.List; +import org.eclipse.cdt.core.Addr32; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser.ISymbol; -import org.eclipse.core.runtime.IPath; - import org.eclipse.cdt.utils.CPPFilt; import org.eclipse.cdt.utils.Symbol; import org.eclipse.cdt.utils.som.AR; import org.eclipse.cdt.utils.som.SOM; +import org.eclipse.core.runtime.IPath; /** * A member of a SOM archive @@ -61,7 +61,7 @@ cppfilt = null; } } - Symbol sym = new Symbol(this, name, peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE, peSyms[i].symbol_value, 1); + Symbol sym = new Symbol(this, name, peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE, new Addr32(peSyms[i].symbol_value), 1); list.add(sym); } diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMBinaryObject.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMBinaryObject.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMBinaryObject.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SOMBinaryObject.java 2004-09-17 09:03:57.000000000 +0400 @@ -13,10 +13,13 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.eclipse.cdt.core.Addr32; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; import org.eclipse.cdt.core.IBinaryParser.ISymbol; @@ -25,7 +28,6 @@ import org.eclipse.cdt.utils.CPPFilt; import org.eclipse.cdt.utils.Objdump; import org.eclipse.cdt.utils.som.SOM; -import org.eclipse.cdt.utils.som.parser.SOMParser; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -162,7 +164,7 @@ continue; } int type = peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE; - int addr = peSyms[i].symbol_value; + IAddress addr = new Addr32(peSyms[i].symbol_value); int size = 4; if (cppfilt != null) { try { @@ -181,7 +183,7 @@ IPath file = filename != null ? new Path(filename) : Path.EMPTY; int startLine = addr2line.getLineNumber(addr); - int endLine = addr2line.getLineNumber(addr + size - 1); + int endLine = addr2line.getLineNumber(addr.add(BigInteger.valueOf(size - 1))); list.add(new SomSymbol(this, name, type, addr, size, file, startLine, endLine)); } catch (IOException e) { addr2line = null; diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SomSymbol.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SomSymbol.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SomSymbol.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/som/parser/SomSymbol.java 2004-09-17 09:03:57.000000000 +0400 @@ -11,7 +11,9 @@ package org.eclipse.cdt.utils.som.parser; import java.io.IOException; +import java.math.BigInteger; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.utils.Addr2line; import org.eclipse.cdt.utils.BinaryObjectAdapter; import org.eclipse.cdt.utils.Symbol; @@ -34,7 +36,7 @@ * @param startLine * @param endLine */ - public SomSymbol(BinaryObjectAdapter binary, String name, int type, long addr, long size, IPath sourceFile, int startLine, int endLine) { + public SomSymbol(BinaryObjectAdapter binary, String name, int type, IAddress addr, long size, IPath sourceFile, int startLine, int endLine) { super(binary, name, type, addr, size, sourceFile, startLine, endLine); // TODO Auto-generated constructor stub } @@ -46,7 +48,7 @@ * @param addr * @param size */ - public SomSymbol(BinaryObjectAdapter binary, String name, int type, long addr, long size) { + public SomSymbol(BinaryObjectAdapter binary, String name, int type, IAddress addr, long size) { super(binary, name, type, addr, size); // TODO Auto-generated constructor stub } @@ -59,7 +61,7 @@ Addr2line addr2line = ((SOMBinaryObject)binary).getAddr2line(true); if (addr2line != null) { try { - return addr2line.getLineNumber(getAddress() + offset); + return addr2line.getLineNumber(getAddress().add(BigInteger.valueOf(offset))); } catch (IOException e) { // ignore } diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Symbol.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Symbol.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Symbol.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Symbol.java 2004-09-17 09:07:38.000000000 +0400 @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.utils; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; import org.eclipse.cdt.core.IBinaryParser.ISymbol; import org.eclipse.core.runtime.IPath; @@ -19,14 +20,14 @@ protected final BinaryObjectAdapter binary; private final String name; - private final long addr; + private final IAddress addr; private final int type; private final long size; private final int startLine; private final int endLine; private final IPath sourceFile; - public Symbol(BinaryObjectAdapter binary, String name, int type, long addr, long size, IPath sourceFile, int startLine, int endLine) { + public Symbol(BinaryObjectAdapter binary, String name, int type, IAddress addr, long size, IPath sourceFile, int startLine, int endLine) { this.binary = binary; this.name = name; this.type = type; @@ -37,7 +38,7 @@ this.sourceFile = sourceFile; } - public Symbol(BinaryObjectAdapter binary, String name, int type, long addr, long size) { + public Symbol(BinaryObjectAdapter binary, String name, int type, IAddress addr, long size) { this.binary = binary; this.name = name; this.type = type; @@ -81,7 +82,7 @@ * * @see org.eclipse.cdt.core.IBinaryParser.ISymbol#getAdress() */ - public long getAddress() { + public IAddress getAddress() { return addr; } @@ -122,17 +123,13 @@ } public int compareTo(Object obj) { - long thisVal = 0; - long anotherVal = 0; + IAddress thisVal = this.addr; + IAddress anotherVal = null; if (obj instanceof Symbol) { - Symbol sym = (Symbol) obj; - thisVal = this.addr; - anotherVal = sym.addr; - } else if (obj instanceof Long) { - Long val = (Long) obj; - anotherVal = val.longValue(); - thisVal = this.addr; + anotherVal = ((Symbol) obj).addr; + } else if (obj instanceof IAddress) { + anotherVal = (IAddress) obj; } - return (thisVal < anotherVal ? -1 : (thisVal == anotherVal ? 0 : 1)); + return thisVal.compareTo(anotherVal); } } \ No newline at end of file diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/ARMember.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/ARMember.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/ARMember.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/ARMember.java 2004-09-17 09:03:57.000000000 +0400 @@ -15,6 +15,7 @@ import java.io.InputStream; import java.util.List; +import org.eclipse.cdt.core.Addr32; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser.ISymbol; @@ -87,7 +88,7 @@ cppfilt = null; } } - Symbol sym = new Symbol(this, name, peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE, peSyms[i].n_value, 1); + Symbol sym = new Symbol(this, name, peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE, new Addr32(peSyms[i].n_value), 1); list.add(sym); } diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCOFFBinaryObject.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCOFFBinaryObject.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCOFFBinaryObject.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCOFFBinaryObject.java 2004-09-17 09:03:57.000000000 +0400 @@ -11,10 +11,13 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.eclipse.cdt.core.Addr32; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; import org.eclipse.cdt.core.IBinaryParser.ISymbol; @@ -164,7 +167,7 @@ continue; } int type = peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE; - int addr = peSyms[i].n_value; + IAddress addr = new Addr32(peSyms[i].n_value); int size = 4; if (cppfilt != null) { try { @@ -184,7 +187,7 @@ IPath file = filename != null ? new Path(filename) : Path.EMPTY; int startLine = addr2line.getLineNumber(addr); - int endLine = addr2line.getLineNumber(addr + size - 1); + int endLine = addr2line.getLineNumber(addr.add(BigInteger.valueOf(size - 1))); list.add(new XCoffSymbol(this, name, type, addr, size, file, startLine, endLine)); } catch (IOException e) { addr2line = null; diff -NaurbB workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCoffSymbol.java workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCoffSymbol.java --- workspace-orig/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCoffSymbol.java 2004-09-17 08:43:07.000000000 +0400 +++ workspace/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/xcoff/parser/XCoffSymbol.java 2004-09-17 09:03:57.000000000 +0400 @@ -7,7 +7,9 @@ package org.eclipse.cdt.utils.xcoff.parser; import java.io.IOException; +import java.math.BigInteger; +import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.utils.Addr2line; import org.eclipse.cdt.utils.BinaryObjectAdapter; import org.eclipse.cdt.utils.Symbol; @@ -32,7 +34,7 @@ * @param startLine * @param endLine */ - public XCoffSymbol(BinaryObjectAdapter binary, String name, int type, long addr, long size, IPath sourceFile, int startLine, + public XCoffSymbol(BinaryObjectAdapter binary, String name, int type, IAddress addr, long size, IPath sourceFile, int startLine, int endLine) { super(binary, name, type, addr, size, sourceFile, startLine, endLine); // TODO Auto-generated constructor stub @@ -45,7 +47,7 @@ * @param addr * @param size */ - public XCoffSymbol(BinaryObjectAdapter binary, String name, int type, long addr, long size) { + public XCoffSymbol(BinaryObjectAdapter binary, String name, int type, IAddress addr, long size) { super(binary, name, type, addr, size); // TODO Auto-generated constructor stub } @@ -58,7 +60,7 @@ Addr2line addr2line = ((XCOFFBinaryObject)binary).getAddr2line(true); if (addr2line != null) { try { - return addr2line.getLineNumber(getAddress() + offset); + return addr2line.getLineNumber(getAddress().add(BigInteger.valueOf(offset))); } catch (IOException e) { // ignore }