From 447b3b553a6ae76da67361bf8accedb95ede377c Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Mon, 31 Mar 2003 03:43:47 +0000 Subject: [PATCH] New method getAddress() --- .../core/model/parser/ElfBinaryFile.java | 4 +- .../core/model/parser/PEBinaryFile.java | 4 +- .../internal/core/model/parser/Symbol.java | 31 +++++++-- .../org/eclipse/cdt/core/IBinaryParser.java | 68 ++++++++++--------- 4 files changed, 65 insertions(+), 42 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java index 29f82f78cc2..61f2509cf96 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/ElfBinaryFile.java @@ -321,12 +321,14 @@ public class ElfBinaryFile extends PlatformObject implements IBinaryFile, IBinar Symbol sym = new Symbol(); sym.type = type; sym.name = array[i].toString(); + sym.addr = array[i].st_value; try { // This can fail if we use addr2line // but we can safely ignore the error. if (header == null) { sym.filename = array[i].getFilename(); - sym.lineno = array[i].getFuncLineNumber(); + sym.startLine = array[i].getFuncLineNumber(); + sym.endLine = sym.startLine; } } catch (IOException e) { //e.printStackTrace(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEBinaryFile.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEBinaryFile.java index 2c4dd50a0c3..616e289eab0 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEBinaryFile.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/PEBinaryFile.java @@ -281,7 +281,9 @@ public class PEBinaryFile extends PlatformObject implements IBinaryFile, Symbol sym = new Symbol(); sym.filename = null; sym.name = name; - sym.lineno = 0; + sym.addr = peSyms[i].n_value; + sym.startLine = 0; + sym.endLine = 0; sym.type = peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE; symbols.add(sym); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/Symbol.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/Symbol.java index a26ba87dfea..9c51286aa9b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/Symbol.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/Symbol.java @@ -10,7 +10,9 @@ import org.eclipse.cdt.core.IBinaryParser.ISymbol; public class Symbol implements ISymbol { public String filename; - public int lineno; + public int startLine; + public int endLine; + public long addr; public String name; public int type; @@ -21,12 +23,6 @@ public class Symbol implements ISymbol { return filename; } - /** - * @see org.eclipse.cdt.core.model.IBinaryParser.ISymbol#getLineNumber() - */ - public int getLineNumber() { - return lineno; - } /** * @see org.eclipse.cdt.core.model.IBinaryParser.ISymbol#getName() @@ -42,4 +38,25 @@ public class Symbol implements ISymbol { return type; } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.ISymbol#getAdress() + */ + public long getAdress() { + return addr; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.ISymbol#getEndLine() + */ + public int getEndLine() { + return endLine; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.ISymbol#getStartLine() + */ + public int getStartLine() { + return startLine; + } + } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IBinaryParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IBinaryParser.java index 38c4fd1d748..2ff6ecca599 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IBinaryParser.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IBinaryParser.java @@ -18,73 +18,75 @@ public interface IBinaryParser { /** * Represents a binary file for example an ELF executable. */ - public interface IBinaryFile extends IAdaptable { - public int OBJECT = 0x1; - public int EXECUTABLE = 0x02; - public int SHARED = 0x04; - public int ARCHIVE = 0x08; - public int CORE = 0x10; + interface IBinaryFile extends IAdaptable { + static final int OBJECT = 0x1; + static final int EXECUTABLE = 0x02; + static final int SHARED = 0x04; + static final int ARCHIVE = 0x08; + static final int CORE = 0x10; - public IPath getPath(); - public int getType(); - public InputStream getContents(); + IPath getPath(); + int getType(); + InputStream getContents(); } /** * Represents an archive. */ - public interface IBinaryArchive extends IBinaryFile { - public IBinaryObject[] getObjects(); + interface IBinaryArchive extends IBinaryFile { + IBinaryObject[] getObjects(); } /** * Represents a binary, for example an ELF excutable. */ - public interface IBinaryObject extends IBinaryFile { + interface IBinaryObject extends IBinaryFile { - public boolean hasDebug(); + boolean hasDebug(); - public String getCPU(); + String getCPU(); - public long getText(); + long getText(); - public long getData(); + long getData(); - public long getBSS(); + long getBSS(); - public boolean isLittleEndian(); + boolean isLittleEndian(); - public ISymbol[] getSymbols(); + ISymbol[] getSymbols(); - public String getName(); + String getName(); } /** * An executable. */ - public interface IBinaryExecutable extends IBinaryObject { - public String[] getNeededSharedLibs(); + interface IBinaryExecutable extends IBinaryObject { + String[] getNeededSharedLibs(); } /** * A DLL. */ - public interface IBinaryShared extends IBinaryExecutable { - public String getSoName(); + interface IBinaryShared extends IBinaryExecutable { + String getSoName(); } - public interface ISymbol { - public int FUNCTION = 0x01; - public int VARIABLE = 0x02; + interface ISymbol { + static final int FUNCTION = 0x01; + static final int VARIABLE = 0x02; - public String getName(); - public int getLineNumber(); - public String getFilename(); - public int getType(); + String getName(); + long getAdress(); + int getStartLine(); + int getEndLine(); + String getFilename(); + int getType(); } - public IBinaryFile getBinary(IPath path) throws IOException; + IBinaryFile getBinary(IPath path) throws IOException; - public String getFormat(); + String getFormat(); }