aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamilo Bernal2013-03-06 14:40:06 (EST)
committerRoland Grunberg2013-03-07 10:56:28 (EST)
commit559a9fede192a24e56bf4b9f99d69f67857f6081 (patch)
tree285ff30aa9690872c3fd13700eaa29405bbb4e62
parent3305e4f915ecba324dc901a24eca20a59d4b9c67 (diff)
downloadorg.eclipse.linuxtools-559a9fede192a24e56bf4b9f99d69f67857f6081.zip
org.eclipse.linuxtools-559a9fede192a24e56bf4b9f99d69f67857f6081.tar.gz
org.eclipse.linuxtools-559a9fede192a24e56bf4b9f99d69f67857f6081.tar.bz2
Support events selection for perf stat.refs/changes/03/10903/8
* Added events field to StatData. * Added test for events parsing. * The perf stat functionality does not depend on perf report/record/ annotate, so there's no need to run these during a stat run. * Disable options not related to perf stat accordingly. Change-Id: I28b767046be016851843b8d1e42e7977c5404fa9 Reviewed-on: https://git.eclipse.org/r/10903 Tested-by: Hudson CI Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/DataManipulatorTest.java29
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/SaveSessionTest.java2
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/StatData.java10
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java206
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOptionsTab.java41
5 files changed, 175 insertions, 113 deletions
diff --git a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/DataManipulatorTest.java b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/DataManipulatorTest.java
index a6a0d84..02ce8fb 100644
--- a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/DataManipulatorTest.java
+++ b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/DataManipulatorTest.java
@@ -41,7 +41,7 @@ public class DataManipulatorTest extends TestCase {
final int runCount = 3;
StubStatData sData = new StubStatData(
- "stat data", binary, args, runCount); //$NON-NLS-1$
+ "stat data", binary, args, runCount, null); //$NON-NLS-1$
sData.parse();
String expected = "perf stat -r " + runCount + " " + binary; //$NON-NLS-1$
@@ -52,6 +52,29 @@ public class DataManipulatorTest extends TestCase {
assertEquals(expected, sData.getPerfData().trim());
}
+ public void testEchoStatDataEvents() {
+ final String binary = "a/b/c.out";
+ final String[] args = new String[] { "arg1", "arg2", "arg3" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ final String[] events = new String[] { "event1", "event2", "event3" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ final int runCount = 3;
+
+ StubStatData sData = new StubStatData(
+ "stat data", binary, args, runCount, events); //$NON-NLS-1$
+ sData.parse();
+
+ String expected = "perf stat -r " + runCount; //$NON-NLS-1$
+ for(String event : events){
+ expected += " -e " + event; //$NON-NLS-1$
+ }
+
+ expected = expected + " " + binary; //$NON-NLS-1$
+ for (int i = 0; i < args.length; i++) {
+ expected += " " + args[i]; //$NON-NLS-1$
+ }
+
+ assertEquals(expected, sData.getPerfData().trim());
+ }
+
/**
* Used for testing SourceDisassemblyData
*/
@@ -77,8 +100,8 @@ public class DataManipulatorTest extends TestCase {
private class StubStatData extends StatData {
public StubStatData(String title, String cmd, String[] args,
- int runCount) {
- super(title, cmd, args, runCount);
+ int runCount, String[] events) {
+ super(title, cmd, args, runCount, events);
}
@Override
diff --git a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/SaveSessionTest.java b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/SaveSessionTest.java
index 39f8192..f00c4bf 100644
--- a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/SaveSessionTest.java
+++ b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/SaveSessionTest.java
@@ -78,7 +78,7 @@ public class SaveSessionTest extends TestCase {
assertFalse(handler.verifyData());
PerfPlugin.getDefault().setStatData(
- new StatData("title", "prog", new String[] {}, 1) { //$NON-NLS-1$ //$NON-NLS-2$
+ new StatData("title", "prog", new String[] {}, 1, null) { //$NON-NLS-1$ //$NON-NLS-2$
@Override
public String getPerfData() {
return PERF_STATS_FILE_PATH;
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/StatData.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/StatData.java
index a43747d..64bbf44 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/StatData.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/StatData.java
@@ -23,12 +23,14 @@ public class StatData extends AbstractDataManipulator {
private String prog;
private String [] args;
private int runCount;
+ private String [] events;
- public StatData(String title, String prog, String [] args, int runCount) {
+ public StatData(String title, String prog, String [] args, int runCount, String[] events) {
super(title);
this.prog = prog;
this.args = args;
this.runCount = runCount;
+ this.events = events;
}
@Override
@@ -45,6 +47,12 @@ public class StatData extends AbstractDataManipulator {
ret.add("-r"); //$NON-NLS-1$
ret.add(String.valueOf(runCount));
}
+ if (events != null) {
+ for (String event : events) {
+ ret.add("-e"); //$NON-NLS-1$
+ ret.add(event);
+ }
+ }
ret.add(prog);
ret.addAll(Arrays.asList(args));
return ret.toArray(new String [0]);
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java
index 2ceea5b..62885b5 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java
@@ -8,9 +8,9 @@
*
* Contributors:
* Kent Sebastian <ksebasti@redhat.com> - initial API and implementation
- * Keith Seitz <keiths@redhat.com> - setup code in launch the method, initially
+ * Keith Seitz <keiths@redhat.com> - setup code in launch the method, initially
* written in the now-defunct OprofileSession class
- * QNX Software Systems and others - the section of code marked in the launch
+ * QNX Software Systems and others - the section of code marked in the launch
* method, and the exec method
* Thavidu Ranatunga (IBM) - This code is based on the AbstractOprofileLauncher
* class code for the OProfile plugin. Part of that was originally adapted
@@ -63,115 +63,125 @@ public class PerfLaunchConfigDelegate extends ProfileLaunchConfigurationDelegate
IStatus status = new Status(IStatus.ERROR, PerfPlugin.PLUGIN_ID, "Error: Perf was not found on PATH"); //$NON-NLS-1$
throw new CoreException(status);
}
-
+
//Find the binary path
IPath exePath = CDebugUtils.verifyProgramPath( config );
-
- //Get working directory
- File wd = getWorkingDirectory( config );
- if ( wd == null ) {
- wd = new File( System.getProperty( "user.home", "." ) ); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
+
// Build the commandline string to run perf recording the given project
// Program args from launch config.
String arguments[] = getProgramArgumentsArray(config);
- ArrayList<String> command = new ArrayList<String>();
- // Get the base commandline string (with flags/options based on config)
- command.addAll(Arrays.asList(PerfCore.getRecordString(config)));
- // Add the path to the executable
- command.add(exePath.toOSString());
- command.addAll(Arrays.asList( arguments));
- String[] commandArray = command.toArray(new String[] {});
- boolean usePty = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
-
- Process process;
- try {
- //Spawn the process
- process = execute( commandArray, getEnvironment( config ), wd, usePty );
- createNewProcess( launch, process, commandArray[0] ); //Spawn IProcess using Debug plugin (CDT)
-
- //Wait for recording to complete.
- process.waitFor();
- PrintStream print = null;
- if (config.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true)) {
- //Get the console to output to.
- //This may not be the best way to accomplish this but it shall do for now.
- ConsolePlugin plugin = ConsolePlugin.getDefault();
- IConsoleManager conMan = plugin.getConsoleManager();
- IConsole[] existing = conMan.getConsoles();
- IOConsole binaryOutCons = null;
-
- // Find the console
- for(IConsole x : existing) {
- if (x.getName().contains(renderProcessLabel(commandArray[0]))) {
- binaryOutCons = (IOConsole)x;
+
+ if (config.getAttribute(PerfPlugin.ATTR_ShowStat,
+ PerfPlugin.ATTR_ShowStat_default)) {
+
+ int runCount = config.getAttribute(PerfPlugin.ATTR_StatRunCount,
+ PerfPlugin.ATTR_StatRunCount_default);
+ StringBuffer args = new StringBuffer();
+ for (String arg : arguments) {
+ args.append(arg);
+ args.append(" "); //$NON-NLS-1$
+ }
+ String title = renderProcessLabel("Performance counter stats for "
+ + exePath.toOSString()
+ + " " + args.toString() //$NON-NLS-1$
+ + " (" + runCount + " runs)" ); //$NON-NLS-1$ /$NON-NLS-2$
+
+ StatData sd = null;
+ if(!config.getAttribute(PerfPlugin.ATTR_DefaultEvent, PerfPlugin.ATTR_DefaultEvent_default)){
+ // gather selected events
+ Object[] configEvents = config.getAttribute(PerfPlugin.ATTR_SelectedEvents, PerfPlugin.ATTR_SelectedEvents_default).toArray();
+ String[] statEvents = Arrays.asList(configEvents).toArray(new String[]{});
+
+ sd = new StatData(title, exePath.toOSString(), arguments, runCount, statEvents);
+ } else{
+ sd = new StatData(title, exePath.toOSString(), arguments, runCount, null);
+ }
+ sd.parse();
+ PerfPlugin.getDefault().setStatData(sd);
+ StatView.refreshView();
+ } else {
+ //Get working directory
+ File wd = getWorkingDirectory( config );
+ if ( wd == null ) {
+ wd = new File( System.getProperty( "user.home", "." ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ ArrayList<String> command = new ArrayList<String>();
+ // Get the base commandline string (with flags/options based on config)
+ command.addAll(Arrays.asList(PerfCore.getRecordString(config)));
+ // Add the path to the executable
+ command.add(exePath.toOSString());
+ command.addAll(Arrays.asList( arguments));
+ String[] commandArray = command.toArray(new String[] {});
+ boolean usePty = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_USE_TERMINAL, ICDTLaunchConfigurationConstants.USE_TERMINAL_DEFAULT);
+
+ Process process;
+ try {
+ //Spawn the process
+ process = execute( commandArray, getEnvironment( config ), wd, usePty );
+ createNewProcess( launch, process, commandArray[0] ); //Spawn IProcess using Debug plugin (CDT)
+
+ //Wait for recording to complete.
+ process.waitFor();
+ PrintStream print = null;
+ if (config.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true)) {
+ //Get the console to output to.
+ //This may not be the best way to accomplish this but it shall do for now.
+ ConsolePlugin plugin = ConsolePlugin.getDefault();
+ IConsoleManager conMan = plugin.getConsoleManager();
+ IConsole[] existing = conMan.getConsoles();
+ IOConsole binaryOutCons = null;
+
+ // Find the console
+ for(IConsole x : existing) {
+ if (x.getName().contains(renderProcessLabel(commandArray[0]))) {
+ binaryOutCons = (IOConsole)x;
+ }
}
- }
- // If can't be found get the most recent opened, this should probably never happen.
- if ((binaryOutCons == null) && (existing.length != 0)) {
- if (existing[existing.length - 1] instanceof IOConsole)
- binaryOutCons = (IOConsole)existing[existing.length - 1];
- }
-
- //Get the printstream via the outputstream.
- //Get ouput stream
- OutputStream outputTo;
- if (binaryOutCons != null) {
- outputTo = binaryOutCons.newOutputStream();
- print = new PrintStream(outputTo);
-
- for (int i = 0; i < commandArray.length; i++) {
- print.print(commandArray[i] + " ");
+ // If can't be found get the most recent opened, this should probably never happen.
+ if ((binaryOutCons == null) && (existing.length != 0)) {
+ if (existing[existing.length - 1] instanceof IOConsole)
+ binaryOutCons = (IOConsole)existing[existing.length - 1];
}
- // Print Message
- print.println();
- print.println("Analysing recorded perf.data, please wait...");
- // Possibly should pass this (the console reference) on to
- // PerfCore.Report if theres anything we ever want to spit
- // out to user.
+ //Get the printstream via the outputstream.
+ //Get ouput stream
+ OutputStream outputTo;
+ if (binaryOutCons != null) {
+ outputTo = binaryOutCons.newOutputStream();
+ print = new PrintStream(outputTo);
+
+ for (int i = 0; i < commandArray.length; i++) {
+ print.print(commandArray[i] + " ");
+ }
+
+ // Print Message
+ print.println();
+ print.println("Analysing recorded perf.data, please wait...");
+ // Possibly should pass this (the console reference) on to
+ // PerfCore.Report if theres anything we ever want to spit
+ // out to user.
+ }
}
- }
-
- //(Only for testing this line..) PerfCore.Report(config, null, null, null, "/home/thavidu/dev/eclipse-oprof2-workspace/org.eclipse.linuxtools.internal.perf.tests/resources/perf.data");
- IPath workingDir = Path.fromOSString(wd.toURI().getPath());
- PerfCore.Report(config, getEnvironment(config), workingDir, monitor, null, print);
- PerfCore.RefreshView(renderProcessLabel(exePath.toOSString()));
-
- String title;
- if (config.getAttribute(PerfPlugin.ATTR_ShowSourceDisassembly,
- PerfPlugin.ATTR_ShowSourceDisassembly_default)) {
- title = renderProcessLabel(workingDir + "perf.data"); //$NON-NLS-1$
- SourceDisassemblyData sdData = new SourceDisassemblyData(title, workingDir);
- sdData.parse();
- PerfPlugin.getDefault().setSourceDisassemblyData(sdData);
- SourceDisassemblyView.refreshView();
- }
- if (config.getAttribute(PerfPlugin.ATTR_ShowStat,
- PerfPlugin.ATTR_ShowStat_default)) {
+ //(Only for testing this line..) PerfCore.Report(config, null, null, null, "/home/thavidu/dev/eclipse-oprof2-workspace/org.eclipse.linuxtools.internal.perf.tests/resources/perf.data");
+ IPath workingDir = Path.fromOSString(wd.toURI().getPath());
+ PerfCore.Report(config, getEnvironment(config), workingDir, monitor, null, print);
+ PerfCore.RefreshView(renderProcessLabel(exePath.toOSString()));
- int runCount = config.getAttribute(PerfPlugin.ATTR_StatRunCount,
- PerfPlugin.ATTR_StatRunCount_default);
- StringBuffer args = new StringBuffer();
- for (String arg : arguments) {
- args.append(arg);
- args.append(" "); //$NON-NLS-1$
+ if (config.getAttribute(PerfPlugin.ATTR_ShowSourceDisassembly,
+ PerfPlugin.ATTR_ShowSourceDisassembly_default)) {
+ String title = renderProcessLabel(workingDir + "perf.data"); //$NON-NLS-1$
+ SourceDisassemblyData sdData = new SourceDisassemblyData(title, workingDir);
+ sdData.parse();
+ PerfPlugin.getDefault().setSourceDisassemblyData(sdData);
+ SourceDisassemblyView.refreshView();
}
- title = renderProcessLabel("Performance counter stats for "
- + exePath.toOSString()
- + " " + args.toString() //$NON-NLS-1$
- + " (" + runCount + " runs)" ); //$NON-NLS-1$ /$NON-NLS-2$
- StatData sd = new StatData(title, exePath.toOSString(), arguments, runCount);
- sd.parse();
- PerfPlugin.getDefault().setStatData(sd);
- StatView.refreshView();
- }
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
}
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOptionsTab.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOptionsTab.java
index 6f44c8f..ee053df 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOptionsTab.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOptionsTab.java
@@ -150,11 +150,7 @@ public class PerfOptionsTab extends AbstractLaunchConfigurationTab {
chkShowStat.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent se) {
- if (chkShowStat.getSelection()) {
- statRunCount.setEnabled(true);
- }else{
- statRunCount.setEnabled(false);
- }
+ handleShowStatSelection();
}
});
statRunCount = new Spinner(showStatComp, SWT.BORDER);
@@ -223,6 +219,19 @@ public class PerfOptionsTab extends AbstractLaunchConfigurationTab {
updateLaunchConfigurationDialog();
}
+ /**
+ * Handle selection of show stat button
+ */
+ private void handleShowStatSelection() {
+ if (chkShowStat.getSelection()) {
+ statRunCount.setEnabled(true);
+ toggleButtonsEnablement(false);
+ } else {
+ statRunCount.setEnabled(false);
+ toggleButtonsEnablement(true);
+ }
+ }
+
// Displays a file dialog to allow the user to select the kernel image file
private void showFileDialog(Shell shell) {
FileDialog fDialog = new FileDialog(shell, SWT.OPEN);
@@ -253,6 +262,22 @@ public class PerfOptionsTab extends AbstractLaunchConfigurationTab {
}
}
+ /**
+ * Toggle enablement of all buttons, excluding the stat button.
+ * @param enable enablement of buttons
+ */
+ public void toggleButtonsEnablement(boolean enable) {
+ txtKernelLocation.setEnabled(enable);
+ chkRecordRealtime.setEnabled(enable);
+ chkRecordVerbose.setEnabled(enable);
+ chkSourceLineNumbers.setEnabled(enable);
+ chkKernelSourceLineNumbers.setEnabled(enable);
+ chkMultiplexEvents.setEnabled(enable);
+ chkModuleSymbols.setEnabled(enable);
+ chkHideUnresolvedSymbols.setEnabled(enable);
+ chkShowSourceDisassembly.setEnabled(enable);
+ }
+
@Override
public String getName() {
return "Perf Options";
@@ -275,11 +300,7 @@ public class PerfOptionsTab extends AbstractLaunchConfigurationTab {
chkShowStat.setSelection(config.getAttribute(PerfPlugin.ATTR_ShowStat, PerfPlugin.ATTR_ShowStat_default));
int runCount = config.getAttribute(PerfPlugin.ATTR_StatRunCount, PerfPlugin.ATTR_StatRunCount_default);
statRunCount.setSelection(runCount);
- if (runCount == 1) {
- statRunCount.setEnabled(false);
- } else {
- statRunCount.setEnabled(true);
- }
+ handleShowStatSelection();
} catch (CoreException e) {
// do nothing
}