summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorWainer S. Moschetta2011-12-26 10:27:45 (EST)
committer Otavio Pontes2011-12-27 06:42:00 (EST)
commit63afc3c97a7df4ebf67662145f7b9b6d4af68038 (patch)
treedee3911e6afef2a9e76b1b060d848b2057ebc3c2
parentd94bf7de749e400a420d18aacdf2a96661d6e61a (diff)
downloadorg.eclipse.linuxtools-63afc3c97a7df4ebf67662145f7b9b6d4af68038.zip
org.eclipse.linuxtools-63afc3c97a7df4ebf67662145f7b9b6d4af68038.tar.gz
org.eclipse.linuxtools-63afc3c97a7df4ebf67662145f7b9b6d4af68038.tar.bz2
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.java8
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfPlugin.java1
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 f135bf5..9613a92 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 4b9242d..eca5505 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): ";