aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamilo Bernal2012-06-12 16:07:44 (EDT)
committerRoland Grunberg2012-06-13 11:07:50 (EDT)
commit03dc5ef0317d0ba3b98746480a0e02da62c1f958 (patch)
treed66ad703b1eed046c000c74d2e3b14163e24fd24
parent426ddc5bb829882ee9f84fe283ec4063205aeb90 (diff)
downloadorg.eclipse.linuxtools-03dc5ef0317d0ba3b98746480a0e02da62c1f958.zip
org.eclipse.linuxtools-03dc5ef0317d0ba3b98746480a0e02da62c1f958.tar.gz
org.eclipse.linuxtools-03dc5ef0317d0ba3b98746480a0e02da62c1f958.tar.bz2
Re-write of perf plug-in tests.
Tests were re-written to be less machine dependent. Pre-generated data files are under resource/*-event. In the tests assertions are made about these specific files, allowing for consistent results across machines. The parsing of the perf record (PerfCore.java: Record(...)) is now handled in isolation to allow for other types of input streams to be passed in (e.g. text files). This was also done for the annotation to make an explicit separation between parsing a report and an annotation. Tests involving unresolved symbols were removed, as the feature is not fully implemented (commented out,in PerfCore.java: getReportString(...)). checkChildrenStructure was modified to not accept elements with no children, as an even element can have no children. checkChildrenPercentages was modified to allow for acceptable percentage ranges to compensate for truncation errors.
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/resources/defaultevent-data/perf.databin0 -> 53276 bytes
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/resources/defaultevent-data/perf.data.err.log0
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/resources/defaultevent-data/perf.data.txt27
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/resources/multievent-data/perf.databin0 -> 109196 bytes
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/resources/multievent-data/perf.data.err.log0
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/resources/multievent-data/perf.data.txt58
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java242
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java185
8 files changed, 347 insertions, 165 deletions
diff --git a/perf/org.eclipse.linuxtools.perf.tests/resources/defaultevent-data/perf.data b/perf/org.eclipse.linuxtools.perf.tests/resources/defaultevent-data/perf.data
new file mode 100644
index 0000000..a627203
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf.tests/resources/defaultevent-data/perf.data
Binary files differ
diff --git a/perf/org.eclipse.linuxtools.perf.tests/resources/defaultevent-data/perf.data.err.log b/perf/org.eclipse.linuxtools.perf.tests/resources/defaultevent-data/perf.data.err.log
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf.tests/resources/defaultevent-data/perf.data.err.log
diff --git a/perf/org.eclipse.linuxtools.perf.tests/resources/defaultevent-data/perf.data.txt b/perf/org.eclipse.linuxtools.perf.tests/resources/defaultevent-data/perf.data.txt
new file mode 100644
index 0000000..8a24488
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf.tests/resources/defaultevent-data/perf.data.txt
@@ -0,0 +1,27 @@
+# ========
+# captured on: Fri Jun 8 11:08:34 2012
+# hostname : voip-10-15-18-77.yyz.redhat.com
+# os release : 3.3.7-1.fc16.x86_64
+# perf version : 3.3.7-1.fc16.x86_64
+# arch : x86_64
+# nrcpus online : 4
+# nrcpus avail : 4
+# cpudesc : Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz
+# cpuid : GenuineIntel,6,42,7
+# total memory : 8161284 kB
+# cmdline : /usr/bin/perf record -f /home/cabernal/runtime-EclipseApplication/hellotest/Debug/hellotest
+# event : name = cycles, type = 0, config = 0x0, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, id = { 155, 156, 157, 158 }
+# HEADER_CPU_TOPOLOGY info available, use -I to display
+# HEADER_NUMA_TOPOLOGY info available, use -I to display
+# ========
+#
+# Events: 898 cycles
+#
+# OverheadSamplesCommandShared ObjectSymbol
+99.01883hellotesthellotest [.] fib_rec
+0.861hellotest[kernel.kallsyms][k] cmpxchg_double_slab
+0.111hellotestld-2.14.90.so [.] do_lookup_x
+0.021hellotestperf [.] parse_events
+0.0012hellotest[kernel.kallsyms][k] native_write_msr_safe
+
+
diff --git a/perf/org.eclipse.linuxtools.perf.tests/resources/multievent-data/perf.data b/perf/org.eclipse.linuxtools.perf.tests/resources/multievent-data/perf.data
new file mode 100644
index 0000000..72cc86e
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf.tests/resources/multievent-data/perf.data
Binary files differ
diff --git a/perf/org.eclipse.linuxtools.perf.tests/resources/multievent-data/perf.data.err.log b/perf/org.eclipse.linuxtools.perf.tests/resources/multievent-data/perf.data.err.log
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf.tests/resources/multievent-data/perf.data.err.log
diff --git a/perf/org.eclipse.linuxtools.perf.tests/resources/multievent-data/perf.data.txt b/perf/org.eclipse.linuxtools.perf.tests/resources/multievent-data/perf.data.txt
new file mode 100644
index 0000000..ed39ed6
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf.tests/resources/multievent-data/perf.data.txt
@@ -0,0 +1,58 @@
+# ========
+# captured on: Thu Jun 7 11:35:15 2012
+# hostname : voip-10-15-18-77.yyz.redhat.com
+# os release : 3.3.7-1.fc16.x86_64
+# perf version : 3.3.7-1.fc16.x86_64
+# arch : x86_64
+# nrcpus online : 4
+# nrcpus avail : 4
+# cpudesc : Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz
+# cpuid : GenuineIntel,6,42,7
+# total memory : 8161284 kB
+# cmdline : /usr/bin/perf record -f -e cpu-clock -e task-clock -e page-faults -e minor-faults -e major-faults /home/cabernal/runtime-EclipseApplication/hellotest/Debug/hellotest
+# event : name = cpu-clock, type = 1, config = 0x0, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, id = { 129, 130, 131, 132 }
+# event : name = task-clock, type = 1, config = 0x1, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, id = { 133, 134, 135, 136 }
+# event : name = page-faults, type = 1, config = 0x2, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, id = { 137, 138, 139, 140 }
+# event : name = minor-faults, type = 1, config = 0x5, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, id = { 141, 142, 143, 144 }
+# event : name = major-faults, type = 1, config = 0x6, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, id = { 145, 146, 147, 148 }
+# HEADER_CPU_TOPOLOGY info available, use -I to display
+# HEADER_NUMA_TOPOLOGY info available, use -I to display
+# ========
+#
+# Events: 917 cpu-clock
+#
+# OverheadSamplesCommandShared ObjectSymbol
+100.00917hellotesthellotest[.] fib_rec
+
+
+# Events: 917 task-clock
+#
+# OverheadSamplesCommandShared ObjectSymbol
+100.00917hellotesthellotest[.] fib_rec
+
+
+# Events: 6 page-faults
+#
+# OverheadSamplesCommandShared ObjectSymbol
+93.681hellotestld-2.14.90.so [.] process_envvars
+4.741hellotestld-2.14.90.so [.] _start
+0.792hellotest[kernel.kallsyms][k] __clear_user
+0.401hellotestlibc-2.14.90.so [.] __strchr_sse2
+0.401hellotest[kernel.kallsyms][k] copy_user_generic_string
+
+
+# Events: 6 minor-faults
+#
+# OverheadSamplesCommandShared ObjectSymbol
+95.321hellotestld-2.14.90.so [.] memcmp
+3.581hellotestld-2.14.90.so [.] _start
+0.552hellotest[kernel.kallsyms][k] __clear_user
+0.281hellotestlibc-2.14.90.so [.] __strchr_sse2
+0.281hellotest[kernel.kallsyms][k] copy_user_generic_string
+
+
+# Events: 0 major-faults
+#
+# OverheadSamplesCommandShared ObjectSymbol
+
+
diff --git a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java
index 2c89964..99f4f83 100644
--- a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java
+++ b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java
@@ -10,8 +10,12 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.perf.tests;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import java.util.Stack;
import org.eclipse.core.runtime.CoreException;
@@ -40,6 +44,7 @@ public class ModelTest extends AbstractTest {
protected PerfLaunchConfigDelegate delegate;
protected ILaunch launch;
protected ILaunchConfigurationWorkingCopy wc;
+ protected Stack<Class<?>> stack;
@Override
protected void setUp() throws Exception {
@@ -51,6 +56,11 @@ public class ModelTest extends AbstractTest {
launch = new Launch(config, ILaunchManager.PROFILE_MODE, null);
wc = config.getWorkingCopy();
setProfileAttributes(wc);
+
+ Class<?>[] klassList = new Class<?>[] { PMSymbol.class, PMFile.class,
+ PMDso.class, PMCommand.class, PMEvent.class };
+ stack = new Stack<Class<?>>();
+ stack.addAll(Arrays.asList(klassList));
}
@Override
@@ -95,23 +105,114 @@ public class ModelTest extends AbstractTest {
}
}
- public void testcheckModelGenericStructure () {
- PerfCore.Report(config, null, null, null, "resources/perf.data",null);
- TreeParent invisibleRoot = PerfPlugin.getDefault().getModelRoot();
+ public void testModelDefaultGenericStructure() {
+ TreeParent invisibleRoot = buildModel(
+ "resources/defaultevent-data/perf.data",
+ "resources/defaultevent-data/perf.data.txt",
+ "resources/defaultevent-data/perf.data.err.log");
- // model class structure, left element contained in right element
- Class<?> [] klassList = new Class<?> [] {PMSymbol.class, PMFile.class, PMDso.class, PMCommand.class, PMEvent.class};
- Stack<Class<?>> stack = new Stack<Class<?>> ();
- stack.addAll(Arrays.asList(klassList));
+ checkChildrenStructure(invisibleRoot, stack);
+ }
+
+ public void testModelMultiEventGenericStructure() {
+ TreeParent invisibleRoot = buildModel(
+ "resources/multievent-data/perf.data",
+ "resources/multievent-data/perf.data.txt",
+ "resources/multievent-data/perf.data.err.log");
checkChildrenStructure(invisibleRoot, stack);
}
- public void testPercentages () {
- PerfCore.Report(config, null, null, null, "resources/perf.data",null);
- TreeParent invisibleRoot = PerfPlugin.getDefault().getModelRoot();
+ public void testPercentages() {
+ TreeParent invisibleRoot = buildModel(
+ "resources/defaultevent-data/perf.data",
+ "resources/defaultevent-data/perf.data.txt",
+ "resources/defaultevent-data/perf.data.err.log");
- checkChildrenPercentages (invisibleRoot, invisibleRoot.getPercent());
+ checkChildrenPercentages(invisibleRoot, invisibleRoot.getPercent());
+ }
+
+ public void testParserMultiEvent() {
+ TreeParent invisibleRoot = buildModel(
+ "resources/multievent-data/perf.data",
+ "resources/multievent-data/perf.data.txt",
+ "resources/multievent-data/perf.data.err.log");
+
+ assertEquals(invisibleRoot.getChildren().length, 5);
+
+ String cur = null;
+
+ for (TreeParent event : invisibleRoot.getChildren()) {
+
+ cur = event.getName();
+
+ // Assert specific properties extracted by the parser.
+ if ("cpu-clock".equals(cur)) {
+ assertTrue(event.hasChildren());
+ assertEquals(event.getChildren().length, 1);
+
+ TreeParent cmd = event.getChildren()[0];
+ assertEquals(cmd.getChildren().length, 1);
+
+ String[] cmdLabels = { "hellotest" };
+ checkCommadLabels(cmdLabels, cmd);
+ } else if ("task-clock".equals(cur)) {
+ assertTrue(event.hasChildren());
+ assertEquals(event.getChildren().length, 1);
+
+ TreeParent cmd = event.getChildren()[0];
+ assertEquals(cmd.getChildren().length, 1);
+
+ String[] cmdLabels = { "hellotest" };
+ checkCommadLabels(cmdLabels, cmd);
+ } else if ("page-faults".equals(cur)) {
+ assertTrue(event.hasChildren());
+ assertEquals(event.getChildren().length, 1);
+
+ TreeParent cmd = event.getChildren()[0];
+ assertEquals(cmd.getChildren().length, 3);
+
+ String[] cmdLabels = { "ld-2.14.90.so", "[kernel.kallsyms]",
+ "libc-2.14.90.so" };
+ checkCommadLabels(cmdLabels, cmd);
+ } else if ("minor-faults".equals(cur)) {
+ assertTrue(event.hasChildren());
+ assertEquals(event.getChildren().length, 1);
+
+ TreeParent cmd = event.getChildren()[0];
+ assertEquals(cmd.getChildren().length, 3);
+
+ String[] cmdLabels = { "ld-2.14.90.so", "[kernel.kallsyms]",
+ "libc-2.14.90.so" };
+ checkCommadLabels(cmdLabels, cmd);
+ } else if ("major-faults".equals(cur)) {
+ assertTrue(!event.hasChildren());
+ }
+
+ }
+ }
+
+ public void testParserDefaultEvent() {
+ TreeParent invisibleRoot = buildModel(
+ "resources/defaultevent-data/perf.data",
+ "resources/defaultevent-data/perf.data.txt",
+ "resources/defaultevent-data/perf.data.err.log");
+
+ // Assert specific properties extracted by the parser.
+ assertEquals(invisibleRoot.getChildren().length, 1);
+
+ TreeParent event = invisibleRoot.getChildren()[0];
+ assertEquals(event.getName(), "cycles");
+ assertTrue(event.hasChildren());
+ assertEquals(event.getChildren().length, 1);
+
+ TreeParent cmd = event.getChildren()[0];
+ assertTrue(cmd.hasChildren());
+ assertEquals(cmd.getChildren().length, 4);
+
+ String[] cmdLabels = { "hellotest", "[kernel.kallsyms]",
+ "ld-2.14.90.so", "perf" };
+ checkCommadLabels(cmdLabels, cmd);
}
/**
@@ -131,7 +232,7 @@ public class ModelTest extends AbstractTest {
// their children have defined percentages
// eg. the invisible root, and PMCommand
if (actualSum != 100 && sum != -1){
- assertEquals(sum, actualSum);
+ assertTrue(actualSum/sum <= 1.0 && actualSum/sum >= 0.99);
}
}
}
@@ -146,7 +247,6 @@ public class ModelTest extends AbstractTest {
}else{
// children of root must be instances of the top class on the stack
Class<?> klass = stack.pop();
- assertTrue(root.hasChildren());
for (TreeParent tp : root.getChildren()){
// tp.getClass() instanceof klass
assertTrue(klass.isAssignableFrom(tp.getClass()));
@@ -158,88 +258,44 @@ public class ModelTest extends AbstractTest {
}
}
- public void testModel_ResolvedOnly() throws CoreException {
- PerfCore.Report(config, null, null, null, "resources/perf.data",null);
-
- TreeParent invisibleRoot = PerfPlugin.getDefault().getModelRoot();
- assertTrue(invisibleRoot.hasChildren());
- assertEquals(1, invisibleRoot.getChildren().length);
- assertTrue(invisibleRoot.getChildren()[0] instanceof PMEvent);
-
- PMEvent ev = (PMEvent)invisibleRoot.getChildren()[0];
- assertEquals("cycles", ev.getName());
- assertTrue(ev.hasChildren());
- assertEquals(1, ev.getChildren().length);
- assertTrue(ev.getChildren()[0] instanceof PMCommand);
-
- PMCommand comm = (PMCommand)ev.getChildren()[0];
- assertTrue(comm.hasChildren());
- assertEquals(2, comm.getChildren().length);
-
- PMDso dso = (PMDso)comm.getChildren()[0];
- assertTrue(dso.hasChildren());
- assertEquals(1, dso.getChildren().length);
- assertTrue(dso.getChildren()[0] instanceof PMFile);
-
- PMFile file = (PMFile)dso.getChildren()[0];
- assertTrue(file.hasChildren());
- assertEquals(2, file.getChildren().length);
- assertTrue(file.getChildren()[0] instanceof PMSymbol);
-
- PMSymbol sym = ((PMSymbol)file.getChildren()[0]);
- assertTrue(sym.getFunctionName().equals("leftfib"));
- assertTrue(file.getChildren()[1] instanceof PMSymbol);
- sym = ((PMSymbol)file.getChildren()[1]);
- assertTrue(sym.getFunctionName().equals("rightfib"));
- }
-
- public void testModel_Unresolved() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- wc.setAttribute(PerfPlugin.ATTR_HideUnresolvedSymbols, false);
- config = wc.doSave();
-
- PerfCore.Report(config, null, null, null, "resources/perf.data",null);
-
- TreeParent invisibleRoot = PerfPlugin.getDefault().getModelRoot();
- assertTrue(invisibleRoot.hasChildren());
- assertEquals(1, invisibleRoot.getChildren().length);
- assertTrue(invisibleRoot.getChildren()[0] instanceof PMEvent);
-
- PMEvent ev = (PMEvent)invisibleRoot.getChildren()[0];
- assertEquals("cycles", ev.getName());
- assertTrue(ev.hasChildren());
- assertEquals(1, ev.getChildren().length);
- assertTrue(ev.getChildren()[0] instanceof PMCommand);
-
- PMCommand comm = (PMCommand)ev.getChildren()[0];
- assertTrue(comm.hasChildren());
- for (TreeParent x : comm.getChildren()) {
- assertTrue(x instanceof PMDso);
+ /**
+ * Build model based on perf data file report.
+ * @param perfDataLoc location of perf data file
+ * @param perfTextDataLoc location of perf data text file
+ * @param perfErrorDataLoc location of error log file
+ * @return tree model based on perf data report.
+ */
+ public TreeParent buildModel(String perfDataLoc, String perfTextDataLoc,
+ String perfErrorDataLoc) {
+ TreeParent invisibleRoot = new TreeParent("");
+ BufferedReader input = null;
+ BufferedReader error = null;
+
+ try {
+ input = new BufferedReader(new FileReader(perfTextDataLoc));
+ error = new BufferedReader(new FileReader(perfErrorDataLoc));
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail();
}
- assertEquals(2, comm.getChildren().length);
- assertEquals("fib", comm.getChildren()[0].getName());
- assertEquals("[kernel.kallsyms]", comm.getChildren()[1].getName());
-
- PMDso dso = (PMDso)comm.getChildren()[0];
-
- assertTrue(dso.hasChildren());
- assertEquals(1, dso.getChildren().length);
- assertTrue(dso.getChildren()[0] instanceof PMFile);
-
- PMFile file = (PMFile)dso.getChildren()[0];
- assertTrue(file.hasChildren());
- assertEquals(2, file.getChildren().length);
- assertTrue(file.getChildren()[0] instanceof PMSymbol);
-
- PMSymbol sym = ((PMSymbol)file.getChildren()[0]);
- assertTrue(sym.getFunctionName().equals("leftfib"));
- assertTrue(file.getChildren()[1] instanceof PMSymbol);
- sym = ((PMSymbol)file.getChildren()[1]);
- assertTrue(sym.getFunctionName().equals("rightfib"));
+ PerfCore.parseReport(config, null, null, perfDataLoc, null,
+ invisibleRoot, false, input, error);
+ return invisibleRoot;
}
-
- public void checkModel(boolean LoadUnresolved) {
-
+
+ /**
+ * Check whether the command labels in model rooted at cmd exist in
+ * list of labels cmdLabels.
+ * @param cmdLabels list of command labels
+ * @param cmd root of tree model
+ */
+ public void checkCommadLabels(String[] cmdLabels, TreeParent cmd) {
+ List<String> cmdList = new ArrayList<String>(Arrays.asList(cmdLabels));
+
+ for (TreeParent dso : cmd.getChildren()) {
+ assertTrue(cmdList.get(0).equals(dso.getName()));
+ cmdList.remove(0);
+ }
}
}
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java
index fcb575a..903aecc 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java
@@ -284,13 +284,10 @@ public class PerfCore {
BufferedReader input = null;
BufferedReader error = null;
- String line = null;
Process p = null;
- String items[];
- float percent;
-
+
if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
-
+
try {
if (workingDir == null) {
p = Runtime.getRuntime().exec(getReportString(config, perfDataLoc));
@@ -308,9 +305,34 @@ public class PerfCore {
e.printStackTrace();*/
}
- if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
+ PerfCore.parseReport(config, workingDir, monitor, perfDataLoc, print,
+ invisibleRoot, OldPerfVersion, input, error);
- line = null;
+ RefreshView();
+ }
+
+ /**
+ * Parse and build a tree model from the report of a perf data file
+ * @param config launch configuration
+ * @param workingDir working directory configuration
+ * @param monitor monitor
+ * @param perfDataLoc location of perf data file
+ * @param print print stream
+ * @param invisibleRoot root of the model
+ * @param OldPerfVersion boolean old perf version flag
+ * @param input input stream from perf data file report
+ * @param error output stream to where all standard error is written to
+ */
+ public static void parseReport(ILaunchConfiguration config,
+ File workingDir, IProgressMonitor monitor, String perfDataLoc,
+ PrintStream print, TreeParent invisibleRoot,
+ boolean OldPerfVersion, BufferedReader input, BufferedReader error) {
+ if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
+ String line = null;
+ String items[];
+ float percent;
+
+ Process p = null;
double samples;
String comm,dso,symbol;
boolean kernelFlag;
@@ -319,7 +341,7 @@ public class PerfCore {
PMDso currentDso = null;
PMFile currentFile = null;
PMSymbol currentSym = null;
- try {
+ try {
while (( line = input.readLine()) != null){
if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
// line containing report information
@@ -391,9 +413,9 @@ public class PerfCore {
} catch (CoreException e2) {
SourceLineNumbers = false;
}
-
+
if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
-
+
boolean hasProfileData = invisibleRoot.getChildren().length != 0;
if (SourceLineNumbers) {
@@ -407,9 +429,10 @@ public class PerfCore {
if ((!Kernel_SourceLineNumbers) && currentDso.isKernelDso()) continue;
for (TreeParent s : currentDso.getFile(PerfPlugin.STRINGS_UnfiledSymbols).getChildren()) {
if (!(s instanceof PMSymbol)) continue;
-
- if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
-
+
+ if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
+
+
currentSym = (PMSymbol)s;
String[] annotateCmd;
if (workingDir == null) {
@@ -427,62 +450,8 @@ public class PerfCore {
e.printStackTrace();
}
- if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
-
- boolean grabBlock = false;
- boolean blockStarted = false;
- String dsoName,lineRef;
- try {
- while (( line = input.readLine()) != null){
- if (line.startsWith("Sorted summary for file")) {
- grabBlock = true;
- dsoName = line.replace("Sorted summary for file ","");
- blockStarted = false;
- if ((workingDir != null) && (dsoName.startsWith("./"))) {
- if (workingDir.getAbsolutePath().endsWith("/")) {
- dsoName = workingDir.getAbsolutePath() + dsoName.substring(2); // path already ends with '/', so trim './'
- } else {
- dsoName = workingDir.getAbsolutePath() + dsoName.substring(1); // path doesn't have '/', so trim just the '.'
- }
- }
- currentDso.setPath(dsoName);
- } else if (line.startsWith("---")) {
- if (blockStarted) {
- blockStarted = false;
- grabBlock = false;
- } else {
- blockStarted = true;
- }
- } else if (grabBlock && blockStarted) {
- //process the line.
- items = line.trim().split(" +");
- if (items.length != 2) {
- continue;
- }
- percent = Float.parseFloat(items[0]);
- lineRef = items[1];
- items = lineRef.split(":");
- if (currentDso == null) {
- //if (PerfPlugin.DEBUG_ON) System.err.println("Parsed line ref without being in valid block, shouldn't happen.");
- break;
- } else {
- currentSym.addPercent(Integer.parseInt(items[1]), percent);
- // Symbol currently in 'Unfiled Symbols' but we now know the actual parent
- if (currentSym.getParent().getName().equals(PerfPlugin.STRINGS_UnfiledSymbols)) {
- currentSym.getParent().removeChild(currentSym);
- currentDso.getFile(items[0]).addChild(currentSym);
- // Symbol has 2 (or more) parents
- } else if (!((PMFile)currentSym.getParent()).getPath().equals(items[0])) {
- currentSym.markConflict();
- currentSym.getParent().removeChild(currentSym);
- currentDso.getFile(PerfPlugin.STRINGS_MultipleFilesForSymbol).addChild(currentSym);
- }
- }
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
+ PerfCore.parseAnnotation(monitor, input,
+ workingDir, currentDso, currentSym);
}
if (currentDso.getFile(PerfPlugin.STRINGS_UnfiledSymbols).getChildren().length == 0) {
@@ -501,9 +470,81 @@ public class PerfCore {
print.println("No profile data generated to be displayed.");
}
}
- RefreshView();
- }
-
+ }
+
+ /**
+ * Parse annotation file for a dso given a symbol
+ * @param monitor monitor
+ * @param input annotation file input stream
+ * @param workingDir working directory configuration
+ * @param currentDso dso
+ * @param currentSym symbol
+ */
+ public static void parseAnnotation(IProgressMonitor monitor,
+ BufferedReader input, File workingDir, PMDso currentDso,
+ PMSymbol currentSym) {
+ if (monitor != null && monitor.isCanceled()) { RefreshView(); return; }
+
+ boolean grabBlock = false;
+ boolean blockStarted = false;
+ String dsoName,lineRef;
+ String line = null;
+ String items[];
+ float percent;
+
+ try {
+ while (( line = input.readLine()) != null){
+ if (line.startsWith("Sorted summary for file")) {
+ grabBlock = true;
+ dsoName = line.replace("Sorted summary for file ","");
+ blockStarted = false;
+ if ((workingDir != null) && (dsoName.startsWith("./"))) {
+ if (workingDir.getAbsolutePath().endsWith("/")) {
+ dsoName = workingDir.getAbsolutePath() + dsoName.substring(2); // path already ends with '/', so trim './'
+ } else {
+ dsoName = workingDir.getAbsolutePath() + dsoName.substring(1); // path doesn't have '/', so trim just the '.'
+ }
+ }
+ currentDso.setPath(dsoName);
+ } else if (line.startsWith("---")) {
+ if (blockStarted) {
+ blockStarted = false;
+ grabBlock = false;
+ } else {
+ blockStarted = true;
+ }
+ } else if (grabBlock && blockStarted) {
+ //process the line.
+ items = line.trim().split(" +");
+ if (items.length != 2) {
+ continue;
+ }
+ percent = Float.parseFloat(items[0]);
+ lineRef = items[1];
+ items = lineRef.split(":");
+ if (currentDso == null) {
+ //if (PerfPlugin.DEBUG_ON) System.err.println("Parsed line ref without being in valid block, shouldn't happen.");
+ break;
+ } else {
+ currentSym.addPercent(Integer.parseInt(items[1]), percent);
+ // Symbol currently in 'Unfiled Symbols' but we now know the actual parent
+ if (currentSym.getParent().getName().equals(PerfPlugin.STRINGS_UnfiledSymbols)) {
+ currentSym.getParent().removeChild(currentSym);
+ currentDso.getFile(items[0]).addChild(currentSym);
+ // Symbol has 2 (or more) parents
+ } else if (!((PMFile)currentSym.getParent()).getPath().equals(items[0])) {
+ currentSym.markConflict();
+ currentSym.getParent().removeChild(currentSym);
+ currentDso.getFile(PerfPlugin.STRINGS_MultipleFilesForSymbol).addChild(currentSym);
+ }
+ }
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
public static void RefreshView()
{
Display.getDefault().syncExec(new Runnable() {