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;
}
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);
}
}
}
}
}
Aggregations