@Override protected boolean preExec(LaunchOptions options, OprofileDaemonEvent[] daemonEvents) { // set up and launch the oprofile daemon try { // Set current project to allow using the oprofile path that // was chosen for the project Oprofile.setCurrentProject(getProject()); if (!oprofileStatus()) return false; // kill the daemon (it shouldn't be running already, but to be safe) oprofileShutdown(); // reset data from the (possibly) existing default session, // otherwise multiple runs will combine samples and results // won't make much sense oprofileReset(); // setup the events and other parameters oprofileSetupDaemon(options.getOprofileDaemonOptions(), daemonEvents); // start the daemon & collection of samples // note: since the daemon is only profiling for the specific image we told // it to, no matter to start the daemon before the binary itself is run oprofileStartCollection(); } catch (OpcontrolException oe) { OprofileCorePlugin.showErrorDialog("opcontrolProvider", oe); // $NON-NLS-1$ return false; } return true; }
/** * Constructs all of the counters in the given launch configuration. * * @param config the launch configuration * @return an array of all counters */ public static OprofileCounter[] getCounters(ILaunchConfiguration config) { OprofileCounter[] ctrs = new OprofileCounter[Oprofile.getNumberOfCounters()]; for (int i = 0; i < ctrs.length; i++) { ctrs[i] = new OprofileCounter(i); if (config != null) ctrs[i].loadConfiguration(config); } return ctrs; }
/** * Constructor for OprofileCounter. * * @param nr the counter number */ public OprofileCounter(int nr) { _number = nr; _enabled = false; _eventList = Oprofile.getEvents(_number); _daemonEvent = new OprofileDaemonEvent(); }