Support the selection of multiple events when OPerf is in use.

Change-Id: Ica4eb797f799f0c65096cefe96baf0796b719ac7
Reviewed-on: https://git.eclipse.org/r/20682
Reviewed-by: Roland Grunberg <rgrunber@redhat.com>
IP-Clean: Roland Grunberg <rgrunber@redhat.com>
Tested-by: Roland Grunberg <rgrunber@redhat.com>
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestLaunching.java b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestLaunching.java
index 4774885..6e82828 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestLaunching.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestLaunching.java
@@ -91,7 +91,7 @@
 		wc.setAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, false);
 		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_ENABLED(0), true);
 		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_COUNT(0), 100000);
-		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_EVENT(0),	"FAKE_EVENT"); //$NON-NLS-1$
+		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_EVENT(0, 0),	"FAKE_EVENT"); //$NON-NLS-1$
 		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_KERNEL(0), true);
 		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_USER(0), true);
 		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_UNIT_MASK(0), 0);
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestManualLaunching.java b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestManualLaunching.java
index 76337be..5319ff8 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestManualLaunching.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/TestManualLaunching.java
@@ -91,7 +91,7 @@
 		wc.setAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, false);
 		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_ENABLED(0), true);
 		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_COUNT(0), 100000);
-		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_EVENT(0),	"FAKE_EVENT"); //$NON-NLS-1$
+		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_EVENT(0, 0),	"FAKE_EVENT"); //$NON-NLS-1$
 		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_KERNEL(0), true);
 		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_USER(0), true);
 		wc.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_UNIT_MASK(0), 0);
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/OprofileTestingEventConfigTab.java b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/OprofileTestingEventConfigTab.java
index 38854e8..39044e5 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/OprofileTestingEventConfigTab.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch.tests/src/org/eclipse/linuxtools/oprofile/launch/tests/utils/OprofileTestingEventConfigTab.java
@@ -61,9 +61,6 @@
 	protected OprofileCounter[] getOprofileCounters(ILaunchConfiguration config) {
 		// setup and return mock counters
 		OprofileCounter[] ctrs = new OprofileCounter[] { getOprofileCounter(1) };
-		if (config != null) {
-			ctrs[0].loadConfiguration(config);
-		}
 		return ctrs;
 	}
 
@@ -96,7 +93,7 @@
 		// mock counter
 		OprofileCounter ctr = new OprofileCounter(i, events);
 		ctr.setCount(1);
-		ctr.setEvent(event);
+		ctr.setEvents(new OpEvent [] {event});
 
 		return ctr;
 	}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/OprofileLaunchPlugin.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/OprofileLaunchPlugin.java
index a704b13..0e13faf 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/OprofileLaunchPlugin.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/OprofileLaunchPlugin.java
@@ -52,11 +52,12 @@
 	// Counter Attributes \\
 	private static final String ATTR_COUNTER(int nr) { return ID_LAUNCH_PROFILE + ".COUNTER_" + nr; } 					//$NON-NLS-1$
 	public static final String ATTR_COUNTER_ENABLED(int nr)  { return ATTR_COUNTER(nr) + ".ENABLED"; } 					//$NON-NLS-1$
-	public static final String ATTR_COUNTER_EVENT(int nr) { return ATTR_COUNTER(nr)  + ".EVENT"; } 						//$NON-NLS-1$
+	public static final String ATTR_COUNTER_EVENT(int nr, int ev) { return ATTR_COUNTER(nr)  + ".EVENT " + ev; } 						//$NON-NLS-1$
 	public static final String ATTR_COUNTER_PROFILE_KERNEL(int nr) { return ATTR_COUNTER(nr) + ".PROFILE_KERNEL"; }		//$NON-NLS-1$
 	public static final String ATTR_COUNTER_PROFILE_USER(int nr) { return ATTR_COUNTER(nr) + ".PROFILE_USER"; } 		//$NON-NLS-1$
 	public static final String ATTR_COUNTER_COUNT(int nr) { return ATTR_COUNTER(nr) + ".COUNT"; } 						//$NON-NLS-1$
 	public static final String ATTR_COUNTER_UNIT_MASK(int nr) { return  ATTR_COUNTER(nr) + ".UNIT_MASK"; } 				//$NON-NLS-1$
+	public static final String ATTR_NUMBER_OF_EVENTS(int nr) { return ATTR_COUNTER(nr) + ".EVENTS"; }					//$NON-NLS-1$
 
 
 	public static final String ICON_PATH = "icons/"; //$NON-NLS-1$
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java
index 1cedde2..94711f1 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/AbstractEventConfigTab.java
@@ -30,6 +30,7 @@
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.linuxtools.internal.oprofile.core.Oprofile.OprofileProject;
 import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin;
 import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent;
 import org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask;
@@ -229,7 +230,8 @@
 					counters[i].loadConfiguration(config);
 
 					for (CounterSubTab counterSubTab : counterSubTabs){
-						if(counterSubTab.enabledCheck.getSelection() && counterSubTab.eventList.getList().getSelectionIndex() == -1){
+						int nr = counterSubTab.counter.getNumber();
+						if(counterSubTab.enabledCheck.getSelection() && config.getAttribute(OprofileLaunchPlugin.ATTR_NUMBER_OF_EVENTS(nr), 0) == 0){
 							valid = false;
 						}
 					}
@@ -237,22 +239,25 @@
 					if (counters[i].getEnabled()) {
 						++numEnabledEvents;
 
-						if (counters[i].getEvent() == null) {
-							valid = false;
-							break;
-						}
+						for (OpEvent event : counters[i].getEvents()) {
+							if (event == null) {
+								valid = false;
+								break;
+							}
 
-						// First check min count
-						int min = counters[i].getEvent().getMinCount();
-						if (counters[i].getCount() < min) {
-							valid = false;
-							break;
-						}
+							// First check min count
+							int min = event.getMinCount();
+							if (counters[i].getCount() < min) {
+								valid = false;
+								break;
+							}
 
-						// Next ask oprofile if it is valid
-						if (!checkEventSetupValidity(counters[i].getNumber(), counters[i].getEvent().getText(), counters[i].getEvent().getUnitMask().getMaskValue())) {
-							valid = false;
-							break;
+							// Next ask oprofile if it is valid
+							if (!checkEventSetupValidity(
+									counters[i].getNumber(), event.getText(), event.getUnitMask().getMaskValue())) {
+								valid = false;
+								break;
+							}
 						}
 					}
 				}
@@ -564,7 +569,13 @@
 				}
 			});
 
-			eventList = new ListViewer(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
+			int options =  SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER;
+			if (OprofileProject.getProfilingBinary().equals(OprofileProject.OPERF_BINARY)) {
+				options |= SWT.MULTI;
+			} else {
+				options |= SWT.SINGLE;
+			}
+			eventList = new ListViewer(parent, options);
 			eventList.getList().setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
 
 			eventList.setLabelProvider(new ILabelProvider(){
@@ -712,18 +723,18 @@
 			boolean enabled = counter.getEnabled();
 			enabledCheck.setSelection(enabled);
 
-			if (counter.getEvent() == null) {
+			if (counter.getEvents().length == 0 || counter.getEvents()[0] == null) {
 				// Default to first in list
-				counter.setEvent(counter.getValidEvents()[0]);
+				counter.setEvents(new OpEvent [] {counter.getValidEvents()[0]});
 			}
 
 			//load default states
 			profileKernelCheck.setSelection(counter.getProfileKernel());
 			profileUserCheck.setSelection(counter.getProfileUser());
 			countText.setText(Integer.toString(counter.getCount()));
-			eventDescText.setText(counter.getEvent().getTextDescription());
-			unitMaskViewer.displayEvent(counter.getEvent());
-			eventList.setSelection(new StructuredSelection(counter.getEvent()));
+			eventDescText.setText(counter.getEvents()[0].getTextDescription());
+			unitMaskViewer.displayEvent(counter.getEvents()[0]);
+			eventList.setSelection(new StructuredSelection(counter.getEvents()));
 		}
 
 		/**
@@ -768,21 +779,33 @@
 		 * and updates the UnitMask and event description text box.
 		 */
 		private void handleEventListSelectionChange() {
-			int index = eventList.getList().getSelectionIndex();
-			if (index != -1){
-				OpEvent event = (OpEvent) eventList.getElementAt(index);
-				counter.setEvent(event);
-				eventDescText.setText(event.getTextDescription());
-				unitMaskViewer.displayEvent(event);
+			int [] indices = eventList.getList().getSelectionIndices();
+			if (indices.length != 0) {
+				ArrayList<OpEvent> tmp = new ArrayList<OpEvent> ();
+				for (int index : indices) {
+					OpEvent event = (OpEvent) eventList.getElementAt(index);
+					tmp.add(event);
+					eventDescText.setText(event.getTextDescription());
+					unitMaskViewer.displayEvent(event);
+				}
 
-				// Check the min count to update the error message (events can have
+				// Check the min count to update the error message (events
+				// can have
 				// different minimum reset counts)
-				int min = counter.getEvent().getMinCount();
-				if ((counter.getCount() < min) && (!defaultEventCheck.getSelection())){
+				int min = Integer.MIN_VALUE;
+				for (OpEvent ev : tmp) {
+					// We want the largest of the min values
+					if (ev.getMinCount() > min) {
+						min = ev.getMinCount();
+					}
+				}
+				if ((counter.getCount() < min)
+						&& (!defaultEventCheck.getSelection())) {
 					setErrorMessage(getMinCountErrorMessage(min));
 				}
+
+				counter.setEvents(tmp.toArray(new OpEvent[0]));
 			} else {
-				counter.setEvent(null);
 				eventDescText.setText(""); //$NON-NLS-1$
 				if(unitMaskViewer != null){
 					unitMaskViewer.displayEvent(null);
@@ -821,7 +844,13 @@
 				counter.setCount(count);
 
 				// Check minimum count
-				int min = counter.getEvent().getMinCount();
+				int min = Integer.MIN_VALUE;
+				for (OpEvent event : counter.getEvents()) {
+					// We want the largest of the min values
+					if (event != null && event.getMinCount() > min) {
+						min = event.getMinCount();
+					}
+				}
 				if ((count < min) && (!defaultEventCheck.getSelection())) {
 					errorMessage = getMinCountErrorMessage(min);
 				}
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileCounter.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileCounter.java
index a8d25fc..e941472 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileCounter.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileCounter.java
@@ -13,6 +13,8 @@
 package org.eclipse.linuxtools.internal.oprofile.launch.configuration;
 
 import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.debug.core.ILaunchConfiguration;
@@ -38,8 +40,8 @@
 	// Is this counter enabled?
 	private boolean _enabled;
 	
-	// The event to collect on this counter
-	private OprofileDaemonEvent daemonEvent;
+	// The event(s) to collect on this counter
+	private OprofileDaemonEvent[] daemonEvent;
 	
 	// List of valid events on this counter
 	private OpEvent[] eventList = null;
@@ -61,7 +63,7 @@
 		number = nr;
 		_enabled = false;
 		eventList = events;
-		daemonEvent = new OprofileDaemonEvent();
+		daemonEvent = new OprofileDaemonEvent [] {new OprofileDaemonEvent()};
 	}
 
 	/**
@@ -93,8 +95,20 @@
 	 * Method setEvent.
 	 * @param event	the event for this counter
 	 */
-	public void setEvent(OpEvent event) {
-		daemonEvent.setEvent(event);
+	public void setEvents(OpEvent [] events) {
+		OprofileDaemonEvent [] newDaemonEvent = new OprofileDaemonEvent[events.length];
+		for (int i = 0; i < events.length; i++) {
+			if (i > daemonEvent.length - 1) {
+				OprofileDaemonEvent de = new OprofileDaemonEvent();
+				de.setEvent(events[i]);
+				de.setResetCount(daemonEvent[0].getResetCount());
+				newDaemonEvent[i] = de;
+			} else {
+				daemonEvent[i].setEvent(events[i]);
+				newDaemonEvent[i] = daemonEvent[i];
+			}
+		}
+		daemonEvent = newDaemonEvent;
 	}
 	
 	/**
@@ -102,7 +116,9 @@
 	 * @param profileKernel	whether this counter should count kernel events
 	 */
 	public void setProfileKernel(boolean profileKernel) {
-		daemonEvent.setProfileKernel(profileKernel);
+		for (int i = 0; i < daemonEvent.length; i++) {
+			daemonEvent[i].setProfileKernel(profileKernel);
+		}
 	}
 	
 	/**
@@ -110,7 +126,9 @@
 	 * @param profileUser	whether this counter should count user events
 	 */
 	public void setProfileUser(boolean profileUser) {
-		daemonEvent.setProfileUser(profileUser);
+		for (int i = 0; i < daemonEvent.length; i++) {
+			daemonEvent[i].setProfileUser(profileUser);
+		}
 	}
 	
 	/**
@@ -118,7 +136,9 @@
 	 * @param count	the number of events between samples for this counter
 	 */
 	public void setCount(int count) {
-		daemonEvent.setResetCount(count);
+		for (int i = 0; i < daemonEvent.length; i++) {
+			daemonEvent[i].setResetCount(count);
+		}
 	}
 	
 	/**
@@ -128,13 +148,17 @@
 	 */
 	public void saveConfiguration(ILaunchConfigurationWorkingCopy config) {
 		config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_ENABLED(number), _enabled);
-		if (daemonEvent.getEvent() != null) {
-			config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_EVENT(number), daemonEvent.getEvent().getText());
-			config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_UNIT_MASK(number), daemonEvent.getEvent().getUnitMask().getMaskValue());
+		config.setAttribute(OprofileLaunchPlugin.ATTR_NUMBER_OF_EVENTS(number), daemonEvent.length);
+
+		for (int i = 0; i < daemonEvent.length; i++) {
+			if (daemonEvent[i].getEvent() != null) {
+				config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_EVENT(number, i), daemonEvent[i].getEvent().getText());
+				config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_UNIT_MASK(number), daemonEvent[i].getEvent().getUnitMask().getMaskValue());
+			}
+			config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_KERNEL(number), daemonEvent[i].getProfileKernel());
+			config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_USER(number), daemonEvent[i].getProfileUser());
+			config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_COUNT(number), daemonEvent[i].getResetCount());
 		}
-		config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_KERNEL(number), daemonEvent.getProfileKernel());
-		config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_USER(number), daemonEvent.getProfileUser());
-		config.setAttribute(OprofileLaunchPlugin.ATTR_COUNTER_COUNT(number), daemonEvent.getResetCount());
 	}
 	
 	/**
@@ -144,29 +168,33 @@
 	public void loadConfiguration(ILaunchConfiguration config) {
 		try {
 			_enabled = config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_ENABLED(number), false);
+			int numEvents = config.getAttribute(OprofileLaunchPlugin.ATTR_NUMBER_OF_EVENTS(number), 1);
+			daemonEvent = new OprofileDaemonEvent[numEvents];
 
-			String str = config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_EVENT(number), ""); //$NON-NLS-1$
-			daemonEvent.setEvent(_eventFromString(str));
+			for (int i = 0; i < numEvents; i++) {
+				String str = config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_EVENT(number, i), ""); //$NON-NLS-1$
+				int maskValue = config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_UNIT_MASK(number), OpUnitMask.SET_DEFAULT_MASK);
 
-			if (daemonEvent.getEvent() == null) {
-				return;
+				daemonEvent[i] = new OprofileDaemonEvent();
+				daemonEvent[i].setEvent(_eventFromString(str));
+
+				if (daemonEvent[i].getEvent() == null) {
+					continue;
+				}
+
+				daemonEvent[i].getEvent().getUnitMask().setMaskValue(maskValue);
+				daemonEvent[i].setProfileKernel(config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_KERNEL(number), false));
+				daemonEvent[i].setProfileUser(config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_USER(number), false));
+
+				daemonEvent[i].setResetCount(config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_COUNT(number), OprofileDaemonEvent.COUNT_UNINITIALIZED));
 			}
-			
-			
-			int maskValue =  config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_UNIT_MASK(number), OpUnitMask.SET_DEFAULT_MASK);
-			daemonEvent.getEvent().getUnitMask().setMaskValue(maskValue);
-			
-			daemonEvent.setProfileKernel(config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_KERNEL(number), false));
-			daemonEvent.setProfileUser(config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_PROFILE_USER(number), false));
-			
-			daemonEvent.setResetCount(config.getAttribute(OprofileLaunchPlugin.ATTR_COUNTER_COUNT(number), OprofileDaemonEvent.COUNT_UNINITIALIZED));
 		} catch (CoreException ce) {
 			
 		}
 	}
 	
 	public OpUnitMask getUnitMask() {
-		OpEvent event = daemonEvent.getEvent();
+		OpEvent event = daemonEvent[0].getEvent();
 		
 		if (event != null) {
 			return event.getUnitMask();
@@ -204,8 +232,12 @@
 	 * Method getEvent.
 	 * @return the event for this counter
 	 */
-	public OpEvent getEvent() {
-		return daemonEvent.getEvent();
+	public OpEvent [] getEvents() {
+		List<OpEvent> res = new ArrayList<OpEvent> ();
+		for (OprofileDaemonEvent de : daemonEvent) {
+			res.add(de.getEvent());
+		}
+		return res.toArray(new OpEvent[0]);
 	}
 	
 	/**
@@ -213,7 +245,7 @@
 	 * @return whether this counter is counting kernel events
 	 */
 	public boolean getProfileKernel() {
-		return daemonEvent.getProfileKernel();
+		return daemonEvent[0].getProfileKernel();
 	}
 	
 	/**
@@ -221,7 +253,7 @@
 	 * @return whether this counter is counting user events
 	 */
 	public boolean getProfileUser() {
-		return daemonEvent.getProfileUser();
+		return daemonEvent[0].getProfileUser();
 	}
 
 	/**
@@ -229,7 +261,7 @@
 	 * @return the number of events between samples for this counter
 	 */
 	public int getCount() {
-		return daemonEvent.getResetCount();
+		return daemonEvent[0].getResetCount();
 	}
 	
 	/**
@@ -245,7 +277,7 @@
 	 * <B>Not</B> valid if this counter is not enabled!
 	 * @return the OprofileDaemonEvent
 	 */
-	public OprofileDaemonEvent getDaemonEvent() {
+	public OprofileDaemonEvent [] getDaemonEvents() {
 		return daemonEvent;
 	}
 
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java
index 9d6969d..2e6a30c 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/AbstractOprofileLaunchConfigurationDelegate.java
@@ -80,8 +80,10 @@
 			OprofileCounter[] counters = oprofileCounters(config);
 
 			for (int i = 0; i < counters.length; ++i) {
-				if (counters[i].getEnabled())
-					events.add(counters[i].getDaemonEvent());
+				if (counters[i].getEnabled()) {
+					OprofileDaemonEvent[] counterEvents  = counters[i].getDaemonEvents();
+					events.addAll(Arrays.asList(counterEvents));
+				}
 			}
 
 			daemonEvents = new OprofileDaemonEvent[events.size()];