mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Catch the Info in the IBinary
This commit is contained in:
parent
008ec4a579
commit
f9e69cf8c7
1 changed files with 84 additions and 53 deletions
|
@ -20,12 +20,19 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
|
|
||||||
public class Binary extends Openable implements IBinary {
|
public class Binary extends Openable implements IBinary {
|
||||||
|
|
||||||
private int fBinType;
|
private int fBinType;
|
||||||
|
private String hasDebug;
|
||||||
|
private String cpu;
|
||||||
|
private String[] needed;
|
||||||
|
private long longData;
|
||||||
|
private long longText;
|
||||||
|
private long longBSS;
|
||||||
|
private String endian;
|
||||||
|
private String soname;
|
||||||
|
|
||||||
private long fLastModification;
|
private long fLastModification;
|
||||||
|
|
||||||
IBinaryFile binaryFile;
|
IBinaryFile binaryFile;
|
||||||
|
@ -40,10 +47,6 @@ public class Binary extends Openable implements IBinary {
|
||||||
binaryFile = bin;
|
binaryFile = bin;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IBinaryFile getBinaryFile() {
|
|
||||||
return binaryFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSharedLib() {
|
public boolean isSharedLib() {
|
||||||
return getType() == IBinaryObject.SHARED;
|
return getType() == IBinaryObject.SHARED;
|
||||||
}
|
}
|
||||||
|
@ -62,75 +65,105 @@ public class Binary extends Openable implements IBinary {
|
||||||
|
|
||||||
public boolean hasDebug() {
|
public boolean hasDebug() {
|
||||||
if (isObject() || isExecutable() || isSharedLib()) {
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
return ((IBinaryObject)getBinaryFile()).hasDebug();
|
if (hasDebug == null || hasChanged()) {
|
||||||
|
hasDebug = Boolean.toString(((IBinaryObject)getBinaryFile()).hasDebug());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return Boolean.valueOf(hasDebug).booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCPU() {
|
public String getCPU() {
|
||||||
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
|
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
|
||||||
return ((IBinaryObject)getBinaryFile()).getCPU();
|
if (cpu == null || hasChanged()) {
|
||||||
|
cpu = ((IBinaryObject)getBinaryFile()).getCPU();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return (cpu == null ? "" : cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getNeededSharedLibs() {
|
public String[] getNeededSharedLibs() {
|
||||||
if (isExecutable() || isSharedLib()) {
|
if (isExecutable() || isSharedLib()) {
|
||||||
return ((IBinaryExecutable)getBinaryFile()).getNeededSharedLibs();
|
if (needed == null || hasChanged()) {
|
||||||
|
needed = ((IBinaryExecutable)getBinaryFile()).getNeededSharedLibs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new String[0];
|
return (needed == null ? new String[0] : needed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getText() {
|
||||||
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
|
if (longText == -1 || hasChanged()) {
|
||||||
|
longText = ((IBinaryObject)getBinaryFile()).getText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return longText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getData() {
|
||||||
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
|
if (longData == -1 || hasChanged()) {
|
||||||
|
longData = ((IBinaryObject)getBinaryFile()).getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return longData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBSS() {
|
||||||
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
|
if (longBSS == -1 || hasChanged()) {
|
||||||
|
longBSS = ((IBinaryObject)getBinaryFile()).getBSS();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return longBSS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSoname() {
|
||||||
|
if (isSharedLib()) {
|
||||||
|
if (soname == null || hasChanged()) {
|
||||||
|
soname = ((IBinaryShared)getBinaryFile()).getSoName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (soname == null ? "" : soname);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLittleEndian() {
|
||||||
|
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
|
||||||
|
if (endian == null || hasChanged()) {
|
||||||
|
endian = Boolean.toString(((IBinaryObject)getBinaryFile()).isLittleEndian());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Boolean.valueOf(endian).booleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IBinaryFile getBinaryFile() {
|
||||||
|
return binaryFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getType() {
|
protected int getType() {
|
||||||
if (getBinaryFile() != null && (fBinType == 0 || getModificationStamp() != fLastModification )) {
|
if (getBinaryFile() != null && (fBinType == 0 || hasChanged())) {
|
||||||
fLastModification = getModificationStamp();
|
|
||||||
fBinType = getBinaryFile().getType();
|
fBinType = getBinaryFile().getType();
|
||||||
}
|
}
|
||||||
return fBinType;
|
return fBinType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean hasChanged() {
|
||||||
|
long modification = getModificationStamp();
|
||||||
|
boolean changed = modification != fLastModification;
|
||||||
|
fLastModification = modification;
|
||||||
|
hasDebug = null;
|
||||||
|
needed = null;
|
||||||
|
cpu = null;
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
protected long getModificationStamp() {
|
protected long getModificationStamp() {
|
||||||
IResource res = getResource();
|
IResource res = getResource();
|
||||||
if (res != null)
|
if (res != null) {
|
||||||
return res.getModificationStamp();
|
return res.getModificationStamp();
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getText() {
|
|
||||||
if (isObject() || isExecutable() || isSharedLib()) {
|
|
||||||
return ((IBinaryObject)getBinaryFile()).getText();
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getData() {
|
|
||||||
if (isObject() || isExecutable() || isSharedLib()) {
|
|
||||||
return ((IBinaryObject)getBinaryFile()).getData();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getBSS() {
|
|
||||||
if (isObject() || isExecutable() || isSharedLib()) {
|
|
||||||
return ((IBinaryObject)getBinaryFile()).getBSS();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSoname() {
|
|
||||||
if (isSharedLib()) {
|
|
||||||
return ((IBinaryShared)getBinaryFile()).getSoName();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLittleEndian() {
|
|
||||||
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
|
|
||||||
return ((IBinaryObject)getBinaryFile()).isLittleEndian();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.model.ICElement#isReadOnly()
|
* @see org.eclipse.cdt.core.model.ICElement#isReadOnly()
|
||||||
*/
|
*/
|
||||||
|
@ -177,8 +210,7 @@ public class Binary extends Openable implements IBinary {
|
||||||
IPath filename = filename = symbol.getFilename();
|
IPath filename = filename = symbol.getFilename();
|
||||||
BinaryFunction function = null;
|
BinaryFunction function = null;
|
||||||
|
|
||||||
// Addr2line returns the funny "??" when it can find the file.
|
if (filename != null) {
|
||||||
if (filename != null && !filename.equals("??")) {
|
|
||||||
BinaryModule module = null;
|
BinaryModule module = null;
|
||||||
if (hash.containsKey(filename)) {
|
if (hash.containsKey(filename)) {
|
||||||
module = (BinaryModule)hash.get(filename);
|
module = (BinaryModule)hash.get(filename);
|
||||||
|
@ -207,8 +239,7 @@ public class Binary extends Openable implements IBinary {
|
||||||
private void addVariable(OpenableInfo info, ISymbol symbol, Map hash) {
|
private void addVariable(OpenableInfo info, ISymbol symbol, Map hash) {
|
||||||
IPath filename = filename = symbol.getFilename();
|
IPath filename = filename = symbol.getFilename();
|
||||||
BinaryVariable variable = null;
|
BinaryVariable variable = null;
|
||||||
// Addr2line returns the funny "??" when it can not find the file.
|
if (filename != null) {
|
||||||
if (filename != null && !filename.equals("??")) {
|
|
||||||
BinaryModule module = null;
|
BinaryModule module = null;
|
||||||
if (hash.containsKey(filename)) {
|
if (hash.containsKey(filename)) {
|
||||||
module = (BinaryModule)hash.get(filename);
|
module = (BinaryModule)hash.get(filename);
|
||||||
|
|
Loading…
Add table
Reference in a new issue