From 2c72e31d52a3cf68eccc287fec1b1656d1fc27fd Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Tue, 20 Jan 2004 21:13:28 +0000 Subject: [PATCH] To remove the hardcoded "objdump" we had to lay down some infrastructure. This is base on ideas/patch from Chris Songer. The idea is to define in the IToolsProvider the Objdump class and reuse it to implement IBinaryFile.getContents(). Next step is to come up with ObjdumpEditor, to go this route will be more flexible. --- core/org.eclipse.cdt.core/ChangeLog | 20 +++ .../cdt/internal/core/model/Binary.java | 55 ++++++++ .../cdt/utils/CygwinToolsProvider.java | 53 ++++++++ .../org/eclipse/cdt/utils/IToolsProvider.java | 16 +++ .../utils/org/eclipse/cdt/utils/Objdump.java | 80 ++++++++++++ .../org/eclipse/cdt/utils/ToolsProvider.java | 117 ++++++++++++++++++ .../cdt/utils/coff/parser/BinaryFile.java | 24 +++- .../cdt/utils/coff/parser/CygwinPEParser.java | 89 ++++--------- .../cdt/utils/elf/parser/BinaryFile.java | 25 +++- .../cdt/utils/elf/parser/GNUElfParser.java | 50 ++------ 10 files changed, 422 insertions(+), 107 deletions(-) create mode 100644 core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CygwinToolsProvider.java create mode 100644 core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Objdump.java create mode 100644 core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/ToolsProvider.java diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index ae5d09aa424..42ba4343370 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,23 @@ +2004-01-20 Alain Magloire + + To remove the hardcoded "objdump" we had to lay + down some infrastructure. This is base on ideas/patch + from Chris Songer. The idea is to define in the IToolsProvider + the Objdump class and reuse it to implement IBinaryFile.getContents(). + Next step is to come up with ObjdumpEditor, to go this route + will be more flexible. + + * model/org/eclipse/cdt/internal/core/model/Binary.java + * utils/org/eclipse/cdt/utils/CygwinToolsProvider.java + * utils/org/eclipse/cdt/utils/ToolsProvider.java + * utils/org/eclipse/cdt/utils/Objdump.java + * utils/org/eclipse/cdt/utils/IToolsProvider.java + * utils/org/eclipse/cdt/utils/coff/parser/CygwinPEParser.java + * utils/org/eclipse/cdt/utils/coff/parser/BinaryFile.java + * utils/org/eclipse/cdt/utils/elf/parser/BinaryFilejava + * utils/org/eclipse/cdt/utils/elf/parser/GNUElfParser.java + + 2004-01-19 John Camelon Updated CModelBuilder to access line number information from IASTOffsetableElement. 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 99fb459c34e..b9b3358cab4 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 @@ -5,6 +5,9 @@ package org.eclipse.cdt.internal.core.model; * All Rights Reserved. */ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; @@ -15,6 +18,7 @@ import org.eclipse.cdt.core.IBinaryParser.IBinaryShared; import org.eclipse.cdt.core.IBinaryParser.ISymbol; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.IBinary; +import org.eclipse.cdt.core.model.IBuffer; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; @@ -271,4 +275,55 @@ public class Binary extends Openable implements IBinary { //} } + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.model.Openable#openBuffer(org.eclipse.core.runtime.IProgressMonitor) + */ + protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException { + + // create buffer - translation units only use default buffer factory + BufferManager bufManager = getBufferManager(); + IBuffer buffer = getBufferFactory().createBuffer(this); + if (buffer == null) + return null; + + // set the buffer source + if (buffer.getCharacters() == null){ + IBinaryFile bin = getBinaryFile(); + if (bin != null) { + StringBuffer sb = new StringBuffer(); + try { + BufferedReader stream = new BufferedReader(new InputStreamReader(bin.getContents())); + char[] buf = new char[512]; + int len; + while ((len = stream.read(buf, 0, buf.length)) != -1) { + sb.append(buf, 0, len); + } + } catch (IOException e) { + // nothint. + } + buffer.setContents(sb.toString()); + } else { + IResource file = this.getResource(); + if (file != null && file.getType() == IResource.FILE) { + buffer.setContents(Util.getResourceContentsAsCharArray((IFile)file)); + } + } + } + + // add buffer to buffer cache + bufManager.addBuffer(buffer); + + // listen to buffer changes + // buffer.addBufferChangedListener(this); + + return buffer; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.model.Openable#hasBuffer() + */ + protected boolean hasBuffer() { + return true; + } + } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CygwinToolsProvider.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CygwinToolsProvider.java new file mode 100644 index 00000000000..b4d930d37e6 --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CygwinToolsProvider.java @@ -0,0 +1,53 @@ +/********************************************************************** + * Copyright (c) 2002,2003 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.utils; + +import java.io.IOException; + +import org.eclipse.cdt.core.ICExtension; +import org.eclipse.cdt.core.ICExtensionReference; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; + +/* + * CygwinToolsProvider +*/ +public class CygwinToolsProvider extends ToolsProvider implements ICygwinToolsProvider { + + public CygwinToolsProvider(ICExtension cextension) { + super(cextension); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.ICygwinToolsProvider#getCygPath() + */ + public CygPath getCygPath() { + IPath cygPathPath = getCygPathPath(); + CygPath cygpath = null; + if (cygPathPath != null && !cygPathPath.isEmpty()) { + try { + cygpath = new CygPath(cygPathPath.toOSString()); + } catch (IOException e1) { + } + } + return cygpath; + } + + public IPath getCygPathPath() { + ICExtensionReference ref = getExtensionReference(); + String value = ref.getExtensionData("cygpath"); //$NON-NLS-1 + if (value == null || value.length() == 0) { + value = "cygpath"; //$NON-NLS-1 + } + return new Path(value); + } + +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/IToolsProvider.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/IToolsProvider.java index 274699c2465..9708d84823c 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/IToolsProvider.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/IToolsProvider.java @@ -16,8 +16,24 @@ import org.eclipse.core.runtime.IPath; */ public interface IToolsProvider { + /** + * Return Addr2Line for this executable + * @param path, the executable + * @return + */ Addr2line getAddr2Line(IPath path); + /** + * Return CPPFilt to translate mangle names + * @return + */ CPPFilt getCPPFilt(); + /** + * Return Objdump for this executable + * @param path, the executable + * @return + */ + Objdump getObjdump(IPath path); + } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Objdump.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Objdump.java new file mode 100644 index 00000000000..257957a85cd --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Objdump.java @@ -0,0 +1,80 @@ +/********************************************************************** + * Copyright (c) 2002,2003 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.utils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import org.eclipse.cdt.utils.spawner.ProcessFactory; + +/* + * Objdump + */ +public class Objdump { + String[] args; + + public Objdump(String command, String param, String file) throws IOException { + String[] params; + if (param == null || param.length() == 0) { + params = new String[0]; + } else { + // FIXME: This is wrong we have to check for quoted strings. + List list = new ArrayList(); + StringTokenizer st = new StringTokenizer(param); + while (st.hasMoreTokens()) { + list.add(st.nextToken()); + } + params = new String[list.size()]; + list.toArray(params); + } + init(command, params, file); + } + + public Objdump(String command, String[] params, String file) throws IOException { + init(command, params, file); + } + + public Objdump(String file) throws IOException { + this("objdump", new String[0], file); + } + + void init(String command, String[] params, String file) throws IOException { + if (params == null || params.length == 0) { + args = new String[] { command, "-C", "-x", "-S", file }; + } else { + args = new String[params.length + 1]; + args[0] = command; + System.arraycopy(params, 0, args, 1, params.length); + } + } + + public byte[] getOutput() throws IOException { + Process objdump = ProcessFactory.getFactory().exec(args); + StringBuffer buffer = new StringBuffer(); + BufferedReader stdout = new BufferedReader(new InputStreamReader(objdump.getInputStream())); + char[] buf = new char[512]; + int len; + while ((len = stdout.read(buf, 0, buf.length)) != -1) { + buffer.append(buf, 0, len); + } + stdout.close(); + objdump.destroy(); + return buffer.toString().getBytes(); + } + + public void dispose() { + } + +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/ToolsProvider.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/ToolsProvider.java new file mode 100644 index 00000000000..099324d9d3b --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/ToolsProvider.java @@ -0,0 +1,117 @@ +/********************************************************************** + * Copyright (c) 2002,2003 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.utils; + +import java.io.IOException; + +import org.eclipse.cdt.core.ICExtension; +import org.eclipse.cdt.core.ICExtensionReference; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; + +/* + * ToolsProvider +*/ +public class ToolsProvider implements IToolsProvider { + + ICExtension cextension; + + public ToolsProvider(ICExtension cext) { + cextension = cext; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.IToolsProvider#getAddr2Line(org.eclipse.core.runtime.IPath) + */ + public Addr2line getAddr2Line(IPath path) { + IPath addr2LinePath = getAddr2LinePath(); + Addr2line addr2line = null; + if (addr2LinePath != null && !addr2LinePath.isEmpty()) { + try { + addr2line = new Addr2line(addr2LinePath.toOSString(), path.toOSString()); + } catch (IOException e1) { + } + } + return addr2line; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.IToolsProvider#getCPPFilt() + */ + public CPPFilt getCPPFilt() { + IPath cppFiltPath = getCPPFiltPath(); + CPPFilt cppfilt = null; + if (cppFiltPath != null && ! cppFiltPath.isEmpty()) { + try { + cppfilt = new CPPFilt(cppFiltPath.toOSString()); + } catch (IOException e2) { + } + } + return cppfilt; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.IToolsProvider#getObjdump(org.eclipse.core.runtime.IPath) + */ + public Objdump getObjdump(IPath path) { + IPath objdumpPath = getObjdumpPath(); + String objdumpArgs = getObjdumpArgs(); + Objdump objdump = null; + if (objdumpPath != null && !objdumpPath.isEmpty()) { + try { + objdump = new Objdump(objdumpPath.toOSString(), objdumpArgs, path.toOSString()); + } catch (IOException e1) { + } + } + return objdump; + } + + ICExtensionReference getExtensionReference() { + return cextension.getExtensionReference(); + } + + IPath getAddr2LinePath() { + ICExtensionReference ref = getExtensionReference(); + String value = ref.getExtensionData("addr2line"); //$NON-NLS-1 + if (value == null || value.length() == 0) { + value = "addr2line"; //$NON-NLS-1 + } + return new Path(value); + } + + IPath getObjdumpPath() { + ICExtensionReference ref = getExtensionReference(); + String value = ref.getExtensionData("objdump"); //$NON-NLS-1 + if (value == null || value.length() == 0) { + value = "objdump"; //$NON-NLS-1 + } + return new Path(value); + } + + String getObjdumpArgs() { + ICExtensionReference ref = getExtensionReference(); + String value = ref.getExtensionData("objdumpArgs"); //$NON-NLS-1 + if (value == null || value.length() == 0) { + value = ""; //$NON-NLS-1 + } + return value; + } + + IPath getCPPFiltPath() { + ICExtensionReference ref = getExtensionReference(); + String value = ref.getExtensionData("c++filt"); //$NON-NLS-1 + if (value == null || value.length() == 0) { + value = "c++filt"; //$NON-NLS-1 + } + return new Path(value); + } + +} diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryFile.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryFile.java index a5056540278..08726d742ce 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryFile.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/BinaryFile.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.utils.Addr2line; import org.eclipse.cdt.utils.CPPFilt; import org.eclipse.cdt.utils.CygPath; import org.eclipse.cdt.utils.ICygwinToolsProvider; +import org.eclipse.cdt.utils.Objdump; import org.eclipse.cdt.utils.coff.PE.Attribute; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.PlatformObject; @@ -59,6 +60,13 @@ public abstract class BinaryFile extends PlatformObject implements IBinaryFile { return null; } + public Objdump getObjdump() { + if (toolsProvider != null) { + return toolsProvider.getObjdump(path); + } + return null; + } + /** * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getFile() */ @@ -77,9 +85,19 @@ public abstract class BinaryFile extends PlatformObject implements IBinaryFile { public InputStream getContents() { InputStream stream = null; if (path != null) { - try { - stream = new FileInputStream(path.toFile()); - } catch (IOException e) { + Objdump objdump = getObjdump(); + if (objdump != null) { + try { + byte[] contents = objdump.getOutput(); + stream = new ByteArrayInputStream(contents); + } catch (IOException e) { + // Nothing + } + } else { + try { + stream = new FileInputStream(path.toFile()); + } catch (IOException e) { + } } } if (stream == null) { diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinPEParser.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinPEParser.java index 6fdb6e873cf..dcf6e6c5b9b 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinPEParser.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinPEParser.java @@ -13,13 +13,13 @@ package org.eclipse.cdt.utils.coff.parser; import java.io.IOException; import org.eclipse.cdt.core.IBinaryParser; -import org.eclipse.cdt.core.ICExtensionReference; import org.eclipse.cdt.utils.Addr2line; import org.eclipse.cdt.utils.CPPFilt; import org.eclipse.cdt.utils.CygPath; +import org.eclipse.cdt.utils.CygwinToolsProvider; import org.eclipse.cdt.utils.ICygwinToolsProvider; +import org.eclipse.cdt.utils.Objdump; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; /** */ @@ -43,66 +43,31 @@ public class CygwinPEParser extends PEParser implements IBinaryParser, ICygwinTo return "Cygwin PE"; } - public IPath getAddr2LinePath() { - ICExtensionReference ref = getExtensionReference(); - String value = ref.getExtensionData("addr2line"); //$NON-NLS-1 - if (value == null || value.length() == 0) { - value = "addr2line"; //$NON-NLS-1 - } - return new Path(value); - } - - public IPath getCPPFiltPath() { - ICExtensionReference ref = getExtensionReference(); - String value = ref.getExtensionData("c++filt"); //$NON-NLS-1 - if (value == null || value.length() == 0) { - value = "c++filt"; //$NON-NLS-1 - } - return new Path(value); - } - - public IPath getCygPathPath() { - ICExtensionReference ref = getExtensionReference(); - String value = ref.getExtensionData("cygpath"); //$NON-NLS-1 - if (value == null || value.length() == 0) { - value = "cygpath"; //$NON-NLS-1 - } - return new Path(value); - } - - public Addr2line getAddr2Line(IPath execFile) { - IPath addr2LinePath = getAddr2LinePath(); - Addr2line addr2line = null; - if (addr2LinePath != null && !addr2LinePath.isEmpty()) { - try { - addr2line = new Addr2line(addr2LinePath.toOSString(), execFile.toOSString()); - } catch (IOException e1) { - } - } - return addr2line; - } - - public CPPFilt getCPPFilt() { - IPath cppFiltPath = getCPPFiltPath(); - CPPFilt cppfilt = null; - if (cppFiltPath != null && ! cppFiltPath.isEmpty()) { - try { - cppfilt = new CPPFilt(cppFiltPath.toOSString()); - } catch (IOException e2) { - } - } - return cppfilt; - } - + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.ICygwinToolsProvider#getCygPath() + */ public CygPath getCygPath() { - IPath cygPathPath = getCygPathPath(); - CygPath cygpath = null; - if (cygPathPath != null && !cygPathPath.isEmpty()) { - try { - cygpath = new CygPath(cygPathPath.toOSString()); - } catch (IOException e1) { - } - } - return cygpath; + return new CygwinToolsProvider(this).getCygPath(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.IToolsProvider#getAddr2Line(org.eclipse.core.runtime.IPath) + */ + public Addr2line getAddr2Line(IPath path) { + return new CygwinToolsProvider(this).getAddr2Line(path); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.IToolsProvider#getCPPFilt() + */ + public CPPFilt getCPPFilt() { + return new CygwinToolsProvider(this).getCPPFilt(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.utils.IToolsProvider#getObjdump(org.eclipse.core.runtime.IPath) + */ + public Objdump getObjdump(IPath path) { + return new CygwinToolsProvider(this).getObjdump(path); } } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryFile.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryFile.java index 08a219547e0..4c73b07cda0 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryFile.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/BinaryFile.java @@ -16,9 +16,10 @@ import java.io.IOException; import java.io.InputStream; import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; -import org.eclipse.cdt.utils.*; import org.eclipse.cdt.utils.Addr2line; import org.eclipse.cdt.utils.CPPFilt; +import org.eclipse.cdt.utils.IToolsProvider; +import org.eclipse.cdt.utils.Objdump; import org.eclipse.cdt.utils.elf.Elf.Attribute; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.PlatformObject; @@ -52,6 +53,12 @@ public abstract class BinaryFile extends PlatformObject implements IBinaryFile { return null; } + public Objdump getObjdump() { + if (toolsProvider != null) { + return toolsProvider.getObjdump(path); + } + return null; + } /** * @see org.eclipse.cdt.core.model.IBinaryParser.IBinaryFile#getFile() @@ -71,9 +78,19 @@ public abstract class BinaryFile extends PlatformObject implements IBinaryFile { public InputStream getContents() { InputStream stream = null; if (path != null) { - try { - stream = new FileInputStream(path.toFile()); - } catch (IOException e) { + Objdump objdump = getObjdump(); + if (objdump != null) { + try { + byte[] contents = objdump.getOutput(); + stream = new ByteArrayInputStream(contents); + } catch (IOException e) { + // Nothing + } + } else { + try { + stream = new FileInputStream(path.toFile()); + } catch (IOException e) { + } } } if (stream == null) { 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 474edfd8052..41cc2347686 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 @@ -13,17 +13,18 @@ package org.eclipse.cdt.utils.elf.parser; import java.io.IOException; import org.eclipse.cdt.core.IBinaryParser; -import org.eclipse.cdt.core.ICExtensionReference; -import org.eclipse.cdt.utils.*; import org.eclipse.cdt.utils.Addr2line; import org.eclipse.cdt.utils.CPPFilt; +import org.eclipse.cdt.utils.IToolsProvider; +import org.eclipse.cdt.utils.Objdump; +import org.eclipse.cdt.utils.ToolsProvider; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; /** */ public class GNUElfParser extends ElfParser implements IBinaryParser, IToolsProvider { + /** * @see org.eclipse.cdt.core.model.IBinaryParser#getBinary(IPath) */ @@ -42,46 +43,19 @@ public class GNUElfParser extends ElfParser implements IBinaryParser, IToolsProv return "GNU ELF"; } - public IPath getAddr2LinePath() { - ICExtensionReference ref = getExtensionReference(); - String value = ref.getExtensionData("addr2line"); //$NON-NLS-1 - if (value == null || value.length() == 0) { - value = "addr2line"; //$NON-NLS-1 - } - return new Path(value); - } - - public IPath getCPPFiltPath() { - ICExtensionReference ref = getExtensionReference(); - String value = ref.getExtensionData("c++filt"); //$NON-NLS-1 - if (value == null || value.length() == 0) { - value = "c++filt"; //$NON-NLS-1 - } - return new Path(value); - } public Addr2line getAddr2Line(IPath path) { - IPath addr2LinePath = getAddr2LinePath(); - Addr2line addr2line = null; - if (addr2LinePath != null && !addr2LinePath.isEmpty()) { - try { - addr2line = new Addr2line(addr2LinePath.toOSString(), path.toOSString()); - } catch (IOException e1) { - } - } - return addr2line; + ToolsProvider provider = new ToolsProvider(this); + return provider.getAddr2Line(path); + } + + public Objdump getObjdump(IPath path) { + ToolsProvider provider = new ToolsProvider(this); + return provider.getObjdump(path); } public CPPFilt getCPPFilt() { - IPath cppFiltPath = getCPPFiltPath(); - CPPFilt cppfilt = null; - if (cppFiltPath != null && ! cppFiltPath.isEmpty()) { - try { - cppfilt = new CPPFilt(cppFiltPath.toOSString()); - } catch (IOException e2) { - } - } - return cppfilt; + return new ToolsProvider(this).getCPPFilt(); } }