blob: 6fdb6e873cf1cccad516f70137b54e9f2cc5c95d [file] [log] [blame]
/**********************************************************************
* 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.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.ICygwinToolsProvider;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/**
*/
public class CygwinPEParser extends PEParser implements IBinaryParser, ICygwinToolsProvider {
/**
* @see org.eclipse.cdt.core.model.IBinaryParser#getBinary(IPath)
*/
public IBinaryFile getBinary(IPath path) throws IOException {
IBinaryFile binary = super.getBinary(path);
if (binary instanceof BinaryFile) {
((BinaryFile)binary).setToolsProvider(this);
}
return binary;
}
/**
* @see org.eclipse.cdt.core.model.IBinaryParser#getFormat()
*/
public String getFormat() {
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;
}
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;
}
}