Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2003-11-20 17:06:20 +0000
committerAlain Magloire2003-11-20 17:06:20 +0000
commite118256c067a09512d7f0871e273590d671ab5c9 (patch)
treee5c48cd923aadb488c8f1575d6aad68d217c3f17
parentace9aa5fd7328a3a39104588b392a97b8dd255ad (diff)
downloadorg.eclipse.cdt-e118256c067a09512d7f0871e273590d671ab5c9.tar.gz
org.eclipse.cdt-e118256c067a09512d7f0871e273590d671ab5c9.tar.xz
org.eclipse.cdt-e118256c067a09512d7f0871e273590d671ab5c9.zip
Bug fix, the Arrays.binarySearch() return the
insertion index.
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryObject.java10
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryObject.java10
2 files changed, 14 insertions, 6 deletions
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryObject.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryObject.java
index 771b14acc3..9c9a71df6c 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryObject.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryObject.java
@@ -58,11 +58,15 @@ public class BinaryObject extends BinaryFile implements IBinaryObject {
*/
public ISymbol getSymbol(long addr) {
ISymbol[] syms = getSymbols();
- int i = Arrays.binarySearch(syms, new Long(addr));
- if (i < 0 || i >= syms.length) {
+ int insertion = Arrays.binarySearch(syms, new Long(addr));
+ if (insertion > 0) {
+ return syms[insertion];
+ }
+ if (insertion == -1) {
return null;
}
- return syms[i];
+ insertion = -insertion - 1;
+ return syms[insertion - 1];
}
/**
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryObject.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryObject.java
index fa0fd575c5..b5acdff084 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryObject.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryObject.java
@@ -56,11 +56,15 @@ public class BinaryObject extends BinaryFile implements IBinaryObject {
*/
public ISymbol getSymbol(long addr) {
ISymbol[] syms = getSymbols();
- int i = Arrays.binarySearch(syms, new Long(addr));
- if (i < 0 || i >= syms.length) {
+ int insertion = Arrays.binarySearch(syms, new Long(addr));
+ if (insertion > 0) {
+ return syms[insertion];
+ }
+ if (insertion == -1) {
return null;
}
- return syms[i];
+ insertion = -insertion - 1;
+ return syms[insertion - 1];
}
/**

Back to the top