Search in sources :

Example 11 with IBinaryObject

use of org.eclipse.cdt.core.IBinaryParser.IBinaryObject in project linuxtools by eclipse.

the class STSymbolManager method getBinaryObject.

/**
 * Gets the IBinaryObject corresponding to the given path (absolute path in filesystem). If a IBinaryObject
 * corresponding to the given path has been already built by eclipse, return it. Otherwise build a new
 * IBinaryObject, according to project preferences. Note that it may return null if the path is invalid, or is not a
 * valid binary file.
 * @param path
 * @param defaultparser
 * @return a IBinaryObject
 */
private IBinaryObject getBinaryObject(IPath path, IBinaryParser defaultparser) {
    IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
    List<IBinaryParser> parsers;
    if (c != null) {
        IBinaryObject object = getAlreadyExistingBinaryObject(c);
        if (object != null) {
            return object;
        }
        parsers = getBinaryParser(c.getProject());
    } else {
        parsers = new LinkedList<>();
    }
    if (defaultparser == null) {
        try {
            defaultparser = CCorePlugin.getDefault().getDefaultBinaryParser();
        } catch (CoreException e) {
            Activator.getDefault().getLog().log(e.getStatus());
        }
    }
    if (defaultparser != null) {
        parsers.add(defaultparser);
    }
    IBinaryObject ret = buildBinaryObject(path, parsers);
    if (ret == null) {
        // trying all BinaryParsers...
        parsers.clear();
        IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID);
        for (IExtension extension : extensionPoint.getExtensions()) {
            if (extension != null) {
                IConfigurationElement[] element = extension.getConfigurationElements();
                for (IConfigurationElement element2 : element) {
                    if (element2.getName().equalsIgnoreCase("cextension")) {
                        // $NON-NLS-1$
                        IBinaryParser parser;
                        try {
                            // $NON-NLS-1$
                            parser = (IBinaryParser) element2.createExecutableExtension("run");
                            parsers.add(parser);
                        } catch (CoreException e) {
                        }
                    }
                }
            }
        }
        ret = buildBinaryObject(path, parsers);
    }
    return ret;
}
Also used : IBinaryParser(org.eclipse.cdt.core.IBinaryParser) IFile(org.eclipse.core.resources.IFile) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) IBinaryObject(org.eclipse.cdt.core.IBinaryParser.IBinaryObject) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 12 with IBinaryObject

use of org.eclipse.cdt.core.IBinaryParser.IBinaryObject in project linuxtools by eclipse.

the class STSymbolManager method validateBinary.

/**
 * Validate the binary file. In particular, verify that this binary file can be decoded.
 * @param o
 * @return the binary object, or null.
 */
private IBinaryObject validateBinary(IBinaryFile o) {
    if (o instanceof IBinaryObject) {
        IBinaryObject object = (IBinaryObject) o;
        // 
        String s = object.getCPU();
        if (s != null && !s.isEmpty()) {
            return object;
        }
    }
    return null;
}
Also used : IBinaryObject(org.eclipse.cdt.core.IBinaryParser.IBinaryObject)

Aggregations

IBinaryObject (org.eclipse.cdt.core.IBinaryParser.IBinaryObject)12 Path (org.eclipse.core.runtime.Path)5 IOException (java.io.IOException)3 IAddress (org.eclipse.cdt.core.IAddress)3 IPath (org.eclipse.core.runtime.IPath)3 GmonDecoder (org.eclipse.linuxtools.internal.gprof.parser.GmonDecoder)3 File (java.io.File)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 LineNumberReader (java.io.LineNumberReader)1 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 IAddressFactory (org.eclipse.cdt.core.IAddressFactory)1 IBinaryParser (org.eclipse.cdt.core.IBinaryParser)1 ISymbol (org.eclipse.cdt.core.IBinaryParser.ISymbol)1