Search in sources :

Example 1 with CachegrindDescription

use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindDescription in project linuxtools by eclipse.

the class CachegrindParser method parseDescription.

private CachegrindDescription parseDescription(String line) throws IOException {
    CachegrindDescription desc = null;
    // $NON-NLS-1$
    String[] tokens = line.split(COLON + "\\s+");
    if (tokens.length == 3) {
        String name = tokens[1];
        tokens = tokens[2].split(COMMA + SPACE);
        if (tokens.length == 3) {
            desc = new CachegrindDescription(name);
        } else {
            ValgrindParserUtils.fail(line);
        }
    } else {
        ValgrindParserUtils.fail(line);
    }
    return desc;
}
Also used : CachegrindDescription(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindDescription)

Example 2 with CachegrindDescription

use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindDescription in project linuxtools by eclipse.

the class CachegrindParser method parse.

public void parse(CachegrindOutput output, File cgOut) throws IOException {
    try (BufferedReader br = new BufferedReader(new FileReader(cgOut))) {
        output.setPid(ValgrindParserUtils.parsePID(cgOut.getName(), CachegrindLaunchDelegate.OUT_PREFIX));
        String line;
        CachegrindFile curFl = null;
        CachegrindFunction curFn = null;
        while ((line = br.readLine()) != null) {
            if (line.startsWith(EVENTS + COLON)) {
                output.setEvents(ValgrindParserUtils.parseStrValue(line, COLON + SPACE).split(SPACE));
            } else if (line.startsWith(CMD + COLON)) {
            // continue
            } else if (line.startsWith(DESC + COLON)) {
                CachegrindDescription description = parseDescription(line);
                output.addDescription(description);
            } else if (line.startsWith(FL + EQUALS)) {
                curFl = new CachegrindFile(output, ValgrindParserUtils.parseStrValue(line, EQUALS));
                output.addFile(curFl);
            } else if (line.startsWith(FN + EQUALS)) {
                if (curFl != null) {
                    curFn = new CachegrindFunction(curFl, ValgrindParserUtils.parseStrValue(line, EQUALS));
                    curFl.addFunction(curFn);
                } else {
                    ValgrindParserUtils.fail(line);
                }
            } else if (line.startsWith(SUMMARY + COLON)) {
                long[] summary = parseData(line, ValgrindParserUtils.parseStrValue(line, COLON + SPACE).split(SPACE));
                output.setSummary(summary);
            } else {
                // line data
                String[] tokens = line.split(SPACE, 2);
                if (ValgrindParserUtils.isNumber(tokens[0])) {
                    int lineNo = Integer.parseInt(tokens[0]);
                    long[] data = parseData(line, tokens[1].split(SPACE));
                    if (curFn != null) {
                        curFn.addLine(new CachegrindLine(curFn, lineNo, data));
                    } else {
                        ValgrindParserUtils.fail(line);
                    }
                } else {
                    ValgrindParserUtils.fail(line);
                }
            }
        }
    }
}
Also used : CachegrindFile(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFile) CachegrindFunction(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFunction) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) CachegrindLine(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindLine) CachegrindDescription(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindDescription)

Aggregations

CachegrindDescription (org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindDescription)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 CachegrindFile (org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFile)1 CachegrindFunction (org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFunction)1 CachegrindLine (org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindLine)1