Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2003-11-19 17:37:13 +0000
committerAlain Magloire2003-11-19 17:37:13 +0000
commitf9e69cf8c79b338465257f6f7492b01e66a812de (patch)
treee2aba0982e6fe0dae5a36edcf34c9f4b2dbfd99e
parent008ec4a579ea5f4654bd8bfa9084defd65e467d1 (diff)
downloadorg.eclipse.cdt-f9e69cf8c79b338465257f6f7492b01e66a812de.tar.gz
org.eclipse.cdt-f9e69cf8c79b338465257f6f7492b01e66a812de.tar.xz
org.eclipse.cdt-f9e69cf8c79b338465257f6f7492b01e66a812de.zip
Catch the Info in the IBinary
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java113
1 files changed, 72 insertions, 41 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java
index 0b99b357bb..f5b4a69cde 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java
@@ -20,12 +20,19 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
public class Binary extends Openable implements IBinary {
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;
IBinaryFile binaryFile;
@@ -40,10 +47,6 @@ public class Binary extends Openable implements IBinary {
binaryFile = bin;
}
- protected IBinaryFile getBinaryFile() {
- return binaryFile;
- }
-
public boolean isSharedLib() {
return getType() == IBinaryObject.SHARED;
}
@@ -62,73 +65,103 @@ public class Binary extends Openable implements IBinary {
public boolean hasDebug() {
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() {
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() {
if (isExecutable() || isSharedLib()) {
- return ((IBinaryExecutable)getBinaryFile()).getNeededSharedLibs();
- }
- return new String[0];
- }
-
- protected int getType() {
- if (getBinaryFile() != null && (fBinType == 0 || getModificationStamp() != fLastModification )) {
- fLastModification = getModificationStamp();
- fBinType = getBinaryFile().getType();
+ if (needed == null || hasChanged()) {
+ needed = ((IBinaryExecutable)getBinaryFile()).getNeededSharedLibs();
+ }
}
- return fBinType;
- }
-
- protected long getModificationStamp() {
- IResource res = getResource();
- if (res != null)
- return res.getModificationStamp();
- return 0;
+ return (needed == null ? new String[0] : needed);
}
public long getText() {
if (isObject() || isExecutable() || isSharedLib()) {
- return ((IBinaryObject)getBinaryFile()).getText();
+ if (longText == -1 || hasChanged()) {
+ longText = ((IBinaryObject)getBinaryFile()).getText();
+ }
}
- return 0;
+ return longText;
}
public long getData() {
if (isObject() || isExecutable() || isSharedLib()) {
- return ((IBinaryObject)getBinaryFile()).getData();
+ if (longData == -1 || hasChanged()) {
+ longData = ((IBinaryObject)getBinaryFile()).getData();
+ }
}
- return 0;
+ return longData;
}
public long getBSS() {
if (isObject() || isExecutable() || isSharedLib()) {
- return ((IBinaryObject)getBinaryFile()).getBSS();
+ if (longBSS == -1 || hasChanged()) {
+ longBSS = ((IBinaryObject)getBinaryFile()).getBSS();
+ }
}
- return 0;
+ return longBSS;
}
public String getSoname() {
if (isSharedLib()) {
- return ((IBinaryShared)getBinaryFile()).getSoName();
+ if (soname == null || hasChanged()) {
+ soname = ((IBinaryShared)getBinaryFile()).getSoName();
+ }
}
- return "";
+ return (soname == null ? "" : soname);
}
public boolean isLittleEndian() {
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
- return ((IBinaryObject)getBinaryFile()).isLittleEndian();
+ if (endian == null || hasChanged()) {
+ endian = Boolean.toString(((IBinaryObject)getBinaryFile()).isLittleEndian());
+ }
+ }
+ return Boolean.valueOf(endian).booleanValue();
+ }
+
+ protected IBinaryFile getBinaryFile() {
+ return binaryFile;
+ }
+
+ protected int getType() {
+ if (getBinaryFile() != null && (fBinType == 0 || hasChanged())) {
+ fBinType = getBinaryFile().getType();
+ }
+ 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() {
+ IResource res = getResource();
+ if (res != null) {
+ return res.getModificationStamp();
}
- return false;
+ return 0;
}
/* (non-Javadoc)
@@ -177,8 +210,7 @@ public class Binary extends Openable implements IBinary {
IPath filename = filename = symbol.getFilename();
BinaryFunction function = null;
- // Addr2line returns the funny "??" when it can find the file.
- if (filename != null && !filename.equals("??")) {
+ if (filename != null) {
BinaryModule module = null;
if (hash.containsKey(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) {
IPath filename = filename = symbol.getFilename();
BinaryVariable variable = null;
- // Addr2line returns the funny "??" when it can not find the file.
- if (filename != null && !filename.equals("??")) {
+ if (filename != null) {
BinaryModule module = null;
if (hash.containsKey(filename)) {
module = (BinaryModule)hash.get(filename);

Back to the top