From 19cd0ff4701cd3f900c05d5620a786a5b1821aa8 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Tue, 14 Oct 2003 21:02:48 +0000 Subject: [PATCH] Always fetch the paths in the .cdtproject. --- .../cdt/utils/elf/parser/BinaryFile.java | 19 ++++++++-------- .../cdt/utils/elf/parser/BinaryObject.java | 16 +++++++++----- .../cdt/utils/elf/parser/GNUElfParser.java | 5 ++--- .../cdt/utils/elf/parser/IToolsProvider.java | 22 +++++++++++++++++++ 4 files changed, 43 insertions(+), 19 deletions(-) create mode 100644 core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/IToolsProvider.java 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 122537f5287..9b365aa02e5 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 @@ -26,27 +26,26 @@ import org.eclipse.core.runtime.PlatformObject; public abstract class BinaryFile extends PlatformObject implements IBinaryFile { protected IPath path; - protected IPath addr2linePath; - protected IPath cppfiltPath; + protected IToolsProvider toolsProvider; public BinaryFile(IPath p) { path = p; } - public void setAddr2LinePath(IPath p) { - addr2linePath = p; + public void setToolsProvider(IToolsProvider p) { + toolsProvider = p; } public IPath getAddr2LinePath() { - return addr2linePath; - } - - public void setCPPFiltPath(IPath p) { - cppfiltPath = p; + if (toolsProvider != null) + return toolsProvider.getAddr2LinePath(); + return null; } public IPath getCPPFiltPath() { - return cppfiltPath; + if (toolsProvider != null) + return toolsProvider.getCPPFiltPath(); + return null; } /** 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 a0dc9f8d66d..8548a85d14f 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 @@ -296,9 +296,11 @@ public class BinaryObject extends BinaryFile implements IBinaryObject { protected Addr2line getAddr2Line() { IPath addr2LinePath = getAddr2LinePath(); Addr2line addr2line = null; - try { - addr2line = new Addr2line(addr2LinePath.toOSString(), getPath().toOSString()); - } catch (IOException e1) { + if (addr2LinePath != null && !addr2LinePath.isEmpty()) { + try { + addr2line = new Addr2line(addr2LinePath.toOSString(), getPath().toOSString()); + } catch (IOException e1) { + } } return addr2line; } @@ -306,9 +308,11 @@ public class BinaryObject extends BinaryFile implements IBinaryObject { protected CPPFilt getCPPFilt() { IPath cppFiltPath = getCPPFiltPath(); CPPFilt cppfilt = null; - try { - cppfilt = new CPPFilt(cppFiltPath.toOSString()); - } catch (IOException e2) { + if (cppFiltPath != null && ! cppFiltPath.isEmpty()) { + 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 4f4322a6ebe..8cffeda4ab0 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 @@ -19,7 +19,7 @@ import org.eclipse.core.runtime.Path; /** */ -public class GNUElfParser extends ElfParser implements IBinaryParser { +public class GNUElfParser extends ElfParser implements IBinaryParser, IToolsProvider { /** * @see org.eclipse.cdt.core.model.IBinaryParser#getBinary(IPath) @@ -27,8 +27,7 @@ public class GNUElfParser extends ElfParser implements IBinaryParser { public IBinaryFile getBinary(IPath path) throws IOException { IBinaryFile binary = super.getBinary(path); if (binary instanceof BinaryFile) { - ((BinaryFile)binary).setAddr2LinePath(getAddr2LinePath()); - ((BinaryFile)binary).setCPPFiltPath(getCPPFiltPath()); + ((BinaryFile)binary).setToolsProvider(this); } return binary; } diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/IToolsProvider.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/IToolsProvider.java new file mode 100644 index 00000000000..56a855abdac --- /dev/null +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/IToolsProvider.java @@ -0,0 +1,22 @@ +/********************************************************************** + * 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.elf.parser; + +import org.eclipse.core.runtime.IPath; + +/** + */ +public interface IToolsProvider { + + IPath getAddr2LinePath(); + + IPath getCPPFiltPath(); +}