From 63afc3c97a7df4ebf67662145f7b9b6d4af68038 Mon Sep 17 00:00:00 2001 From: Wainer S. Moschetta Date: Mon, 26 Dec 2011 13:27:45 -0200 Subject: Perf: refactoring on events parser. Fixes bug #367555 Events parser used to rely on line length of 'perf list' output. However, length might change between perf versions. This patch changes events parser to use regex instead. Signed-off-by: Wainer S. Moschetta --- .../src/org/eclipse/linuxtools/perf/PerfCore.java | 8 ++++---- .../src/org/eclipse/linuxtools/perf/PerfPlugin.java | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'perf/org.eclipse.linuxtools.perf') diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfCore.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfCore.java index f135bf5dfe..9613a929b7 100644 --- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfCore.java +++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfCore.java @@ -98,16 +98,16 @@ public class PerfCore { String cat; if (line.contains(PerfPlugin.STRINGS_HWBREAKPOINTS)) { cat = PerfPlugin.STRINGS_HWBREAKPOINTS; - event = line.substring(1,line.indexOf("[", PerfPlugin.MagicPerfListNumber)).trim(); + event = line.substring(1,line.indexOf("[", 0)).trim(); } else if (line.contains(PerfPlugin.STRINGS_RAWHWEvents)) { cat = PerfPlugin.STRINGS_RAWHWEvents; - event = line.substring(1,line.indexOf("[", PerfPlugin.MagicPerfListNumber)).trim(); + event = line.substring(1,line.indexOf("[", 0)).trim(); } else { - event = line.substring(1,PerfPlugin.MagicPerfListNumber).trim(); //magic number but corresponds with parse-events.c in Perf. + event = line.substring(1,line.indexOf("[", 0)).trim(); if (event.contains("OR")) { event = event.split("OR")[0]; //filter out the abbreviations. } - cat = line.substring(PerfPlugin.MagicPerfListNumber + 1).split("\\]")[0].trim(); + cat = line.replaceFirst(".*\\[(.+)\\]", "$1").trim(); } ArrayList catevs = events.get(cat); if (catevs == null) { diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfPlugin.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfPlugin.java index 4b9242df8c..eca55057cf 100644 --- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfPlugin.java +++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfPlugin.java @@ -65,7 +65,6 @@ public class PerfPlugin extends AbstractUIPlugin { public static final List ATTR_RawHwEvents_default = null; public static final String ATTR_HwBreakpointEvents = "org.eclipse.linuxtools.perf.attr.HwBreakpointEvents"; public static final List ATTR_HwBreakpointEvents_default = null; - public static final int MagicPerfListNumber = 45; //Strings public static final String STRINGS_Kernel_Location = "Location of kernel image file (optional): "; -- cgit v1.2.3