1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

New method getAddress()

This commit is contained in:
Alain Magloire 2003-03-31 03:43:47 +00:00
parent a8f37dc4b4
commit 447b3b553a
4 changed files with 65 additions and 42 deletions

View file

@ -321,12 +321,14 @@ public class ElfBinaryFile extends PlatformObject implements IBinaryFile, IBinar
Symbol sym = new Symbol(); Symbol sym = new Symbol();
sym.type = type; sym.type = type;
sym.name = array[i].toString(); sym.name = array[i].toString();
sym.addr = array[i].st_value;
try { try {
// This can fail if we use addr2line // This can fail if we use addr2line
// but we can safely ignore the error. // but we can safely ignore the error.
if (header == null) { if (header == null) {
sym.filename = array[i].getFilename(); sym.filename = array[i].getFilename();
sym.lineno = array[i].getFuncLineNumber(); sym.startLine = array[i].getFuncLineNumber();
sym.endLine = sym.startLine;
} }
} catch (IOException e) { } catch (IOException e) {
//e.printStackTrace(); //e.printStackTrace();

View file

@ -281,7 +281,9 @@ public class PEBinaryFile extends PlatformObject implements IBinaryFile,
Symbol sym = new Symbol(); Symbol sym = new Symbol();
sym.filename = null; sym.filename = null;
sym.name = name; 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; sym.type = peSyms[i].isFunction() ? ISymbol.FUNCTION : ISymbol.VARIABLE;
symbols.add(sym); symbols.add(sym);
} }

View file

@ -10,7 +10,9 @@ import org.eclipse.cdt.core.IBinaryParser.ISymbol;
public class Symbol implements ISymbol { public class Symbol implements ISymbol {
public String filename; public String filename;
public int lineno; public int startLine;
public int endLine;
public long addr;
public String name; public String name;
public int type; public int type;
@ -21,12 +23,6 @@ public class Symbol implements ISymbol {
return filename; 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() * @see org.eclipse.cdt.core.model.IBinaryParser.ISymbol#getName()
@ -42,4 +38,25 @@ public class Symbol implements ISymbol {
return type; 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;
}
} }

View file

@ -18,73 +18,75 @@ public interface IBinaryParser {
/** /**
* Represents a binary file for example an ELF executable. * Represents a binary file for example an ELF executable.
*/ */
public interface IBinaryFile extends IAdaptable { interface IBinaryFile extends IAdaptable {
public int OBJECT = 0x1; static final int OBJECT = 0x1;
public int EXECUTABLE = 0x02; static final int EXECUTABLE = 0x02;
public int SHARED = 0x04; static final int SHARED = 0x04;
public int ARCHIVE = 0x08; static final int ARCHIVE = 0x08;
public int CORE = 0x10; static final int CORE = 0x10;
public IPath getPath(); IPath getPath();
public int getType(); int getType();
public InputStream getContents(); InputStream getContents();
} }
/** /**
* Represents an archive. * Represents an archive.
*/ */
public interface IBinaryArchive extends IBinaryFile { interface IBinaryArchive extends IBinaryFile {
public IBinaryObject[] getObjects(); IBinaryObject[] getObjects();
} }
/** /**
* Represents a binary, for example an ELF excutable. * 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. * An executable.
*/ */
public interface IBinaryExecutable extends IBinaryObject { interface IBinaryExecutable extends IBinaryObject {
public String[] getNeededSharedLibs(); String[] getNeededSharedLibs();
} }
/** /**
* A DLL. * A DLL.
*/ */
public interface IBinaryShared extends IBinaryExecutable { interface IBinaryShared extends IBinaryExecutable {
public String getSoName(); String getSoName();
} }
public interface ISymbol { interface ISymbol {
public int FUNCTION = 0x01; static final int FUNCTION = 0x01;
public int VARIABLE = 0x02; static final int VARIABLE = 0x02;
public String getName(); String getName();
public int getLineNumber(); long getAdress();
public String getFilename(); int getStartLine();
public int getType(); int getEndLine();
String getFilename();
int getType();
} }
public IBinaryFile getBinary(IPath path) throws IOException; IBinaryFile getBinary(IPath path) throws IOException;
public String getFormat(); String getFormat();
} }