Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamilo Bernal2013-03-06 19:40:06 +0000
committerRoland Grunberg2013-03-07 15:56:28 +0000
commit559a9fede192a24e56bf4b9f99d69f67857f6081 (patch)
tree285ff30aa9690872c3fd13700eaa29405bbb4e62 /perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal
parent3305e4f915ecba324dc901a24eca20a59d4b9c67 (diff)
downloadorg.eclipse.linuxtools-559a9fede192a24e56bf4b9f99d69f67857f6081.tar.gz
org.eclipse.linuxtools-559a9fede192a24e56bf4b9f99d69f67857f6081.tar.xz
org.eclipse.linuxtools-559a9fede192a24e56bf4b9f99d69f67857f6081.zip
Support events selection for perf stat.
* 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>
Diffstat (limited to 'perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal')
-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
3 files changed, 148 insertions, 109 deletions
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 a43747d3be..64bbf44048 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 2ceea5b65b..62885b5813 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 6f44c8fc9f..ee053df710 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
}

Back to the top