From 994d18c7ab38da8095b697aab8ee9fe4e89ab86d Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Mon, 6 Oct 2003 20:16:38 +0000 Subject: [PATCH] Enable the GNU Elf Parser. --- core/org.eclipse.cdt.core/ChangeLog | 12 +++ core/org.eclipse.cdt.core/plugin.xml | 4 +- .../org/eclipse/cdt/utils/Addr2line.java | 22 +++-- .../utils/org/eclipse/cdt/utils/CPPFilt.java | 10 +- .../cdt/utils/elf/parser/BinaryArchive.java | 31 +++--- .../cdt/utils/elf/parser/BinaryFile.java | 19 ++++ .../cdt/utils/elf/parser/BinaryObject.java | 95 +++++++++++++++++-- .../cdt/utils/elf/parser/GNUElfParser.java | 26 +++-- 8 files changed, 174 insertions(+), 45 deletions(-) diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index 722130cfaf1..70dc5a469bf 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,15 @@ +2003-10-06 Alain Magloire + + Implementation of the GNU Elf parser, where you can + change the path of the external commands: addr2line and cppfilt. + + * plugin.xml: Enable the GNU Elf Parser. + * utils/org/eclipse/cdt/utils/elf/BinaryFile.java + * utils/org/eclipse/cdt/utils/elf/BinaryObject.java + * utils/org/eclipse/cdt/utils/elf/BinaryArchive.java + * utils/org/eclipse/cdt/utils/Addr2line.java + * utils/org/eclipse/cdt/utils/elf/CPPFilt.java + 2003-10-01 Bogdan Gheorghe Changed DeltaProcessor.updateDependencies to use the CModelManager diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index 19d589f7f9c..f693878f17e 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -62,7 +62,7 @@ - + + index2 = line.indexOf(':'); + if ( index1 == index2 ) { + index2 = 0; + } else { + index2--; + } + filename = line.substring(index2, index1); + try { + lineno = Integer.parseInt(line.substring(index1 + 1)); + lineno = (lineno == 0) ? -1 : lineno; + } catch(Exception e) { + lineno = -1; + } + } + } + sym.filename = filename; + sym.startLine = lineno; sym.endLine = sym.startLine; } catch (IOException e) { //e.printStackTrace(); @@ -265,4 +326,24 @@ public class BinaryObject extends BinaryFile implements IBinaryObject { symbols.add(sym); } + protected Addr2line getAddr2Line() { + IPath addr2LinePath = getAddr2LinePath(); + Addr2line addr2line = null; + try { + addr2line = new Addr2line(addr2LinePath.toOSString(), getPath().toOSString()); + } catch (IOException e1) { + } + return addr2line; + } + + protected CPPFilt getCPPFilt() { + IPath cppFiltPath = getCPPFiltPath(); + CPPFilt cppfilt = null; + try { + cppfilt = new CPPFilt(cppFiltPath.toOSString()); + } catch (IOException e2) { + } + return cppfilt; + } + } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/GNUElfParser.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/GNUElfParser.java index 32d1bd7096d..5344b2e706d 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/GNUElfParser.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/GNUElfParser.java @@ -10,7 +10,6 @@ import java.io.IOException; import org.eclipse.cdt.core.AbstractCExtension; import org.eclipse.cdt.core.IBinaryParser; import org.eclipse.cdt.core.ICExtensionReference; -import org.eclipse.cdt.internal.core.model.parser.ElfBinaryArchive; import org.eclipse.cdt.utils.elf.Elf; import org.eclipse.cdt.utils.elf.Elf.Attribute; import org.eclipse.core.runtime.IPath; @@ -25,9 +24,10 @@ public class GNUElfParser extends AbstractCExtension implements IBinaryParser { */ public IBinaryFile getBinary(IPath path) throws IOException { if (path == null) { - path = new Path(""); + throw new IOException("path is null"); } - IBinaryFile binary = null; + + BinaryFile binary = null; try { Elf.Attribute attribute = Elf.getAttributes(path.toOSString()); if (attribute != null) { @@ -52,8 +52,10 @@ public class GNUElfParser extends AbstractCExtension implements IBinaryParser { } } } catch (IOException e) { - binary = new ElfBinaryArchive(path); + binary = new BinaryArchive(path); } + binary.setAddr2LinePath(getAddr2LinePath()); + binary.setCPPFiltPath(getCPPFiltPath()); return binary; } @@ -64,13 +66,21 @@ public class GNUElfParser extends AbstractCExtension implements IBinaryParser { return "ELF"; } - String getAddr2LinePath() { + public IPath getAddr2LinePath() { ICExtensionReference ref = getExtensionReference(); - return ref.getExtensionData("addr2line"); + String value = ref.getExtensionData("addr2line"); + if (value == null || value.length() == 0) { + value = "addr2line"; + } + return new Path(value); } - String getCPPFiltPath() { + public IPath getCPPFiltPath() { ICExtensionReference ref = getExtensionReference(); - return ref.getExtensionData("c++filt"); + String value = ref.getExtensionData("c++filt"); + if (value == null || value.length() == 0) { + value = "c++filt"; + } + return new Path(value); } }