mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
New method getAddress()
This commit is contained in:
parent
a8f37dc4b4
commit
447b3b553a
4 changed files with 65 additions and 42 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue