diff options
author | Wainer S. Moschetta | 2011-12-26 15:27:45 +0000 |
---|---|---|
committer | Otavio Pontes | 2011-12-27 11:42:00 +0000 |
commit | 63afc3c97a7df4ebf67662145f7b9b6d4af68038 (patch) | |
tree | dee3911e6afef2a9e76b1b060d848b2057ebc3c2 | |
parent | d94bf7de749e400a420d18aacdf2a96661d6e61a (diff) | |
download | org.eclipse.linuxtools-63afc3c97a7df4ebf67662145f7b9b6d4af68038.tar.gz org.eclipse.linuxtools-63afc3c97a7df4ebf67662145f7b9b6d4af68038.tar.xz org.eclipse.linuxtools-63afc3c97a7df4ebf67662145f7b9b6d4af68038.zip |
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 <wainersm@linux.vnet.ibm.com>
-rw-r--r-- | perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfCore.java | 8 | ||||
-rw-r--r-- | perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfPlugin.java | 1 |
2 files changed, 4 insertions, 5 deletions
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<String> 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): "; |