From 7a06b483595c6eb92bb1d0505ded47579ef4f3be Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Sat, 10 Jan 2004 05:38:40 +0000 Subject: [PATCH] Implement ISymbol.getSize(). --- core/org.eclipse.cdt.core/ChangeLog | 7 +++++++ .../org/eclipse/cdt/utils/coff/parser/BinaryObject.java | 9 +++++++-- .../utils/org/eclipse/cdt/utils/coff/parser/Symbol.java | 8 ++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index 32081ab9c03..c644e9e20f1 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,10 @@ +2004-01-09 Alain Magloire + + * utils/org/eclipse/cdt/utils/coff/parser/BinaryObject.java + Fix bug in finding the symbols. + * utils/org/eclipse/cdt/utils/coff/parser/Symbol.java + Implement ISymbol.java + 2004-01-09 Alain Magloire * src/org/eclipse/cdt/core/IBinaryParser.java 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 9c9a71df6c3..c522a9aed5d 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 @@ -59,14 +59,19 @@ public class BinaryObject extends BinaryFile implements IBinaryObject { public ISymbol getSymbol(long addr) { ISymbol[] syms = getSymbols(); int insertion = Arrays.binarySearch(syms, new Long(addr)); - if (insertion > 0) { + if (insertion >= 0) { return syms[insertion]; } if (insertion == -1) { return null; } insertion = -insertion - 1; - return syms[insertion - 1]; + ISymbol symbol = syms[insertion - 1]; + if (addr < (symbol.getAddress() + symbol.getSize())) { + return syms[insertion - 1]; + } + return null; + } /** diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/Symbol.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/Symbol.java index ddbd1892324..228e1ae360c 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/Symbol.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/Symbol.java @@ -26,6 +26,7 @@ public class Symbol implements ISymbol { public int startLine; public int endLine; public long addr; + public long size; public String name; public int type; @@ -108,6 +109,13 @@ public class Symbol implements ISymbol { return (thisVal < anotherVal ? -1 : (thisVal == anotherVal ? 0 : 1)); } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.IBinaryParser.ISymbol#getSize() + */ + public long getSize() { + return size; + } + synchronized Addr2line startAddr2Line () { if (addr2line == null) { addr2line = binary.getAddr2Line();