From d592d691aaa79832843e991734a3ef2c1a819c40 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Wed, 20 Jul 2011 09:25:29 -0400 Subject: [PATCH] Bug 346320: Add support for fast tracepoints --- .../ui/launching/GdbDebuggerPage.java | 83 +- .../ui/launching/LaunchUIMessages.properties | 5 + .../gdb/IGDBLaunchConfigurationConstants.java | 36 +- .../dsf/gdb/service/GDBBreakpoints_7_2.java | 110 +- .../gdb/service/GdbDebugServicesFactory.java | 8 +- .../service/command/output/MIBreakpoint.java | 25 +- .../data/launch/src/TracepointTestApp.cc | 72 +- .../GDBRemoteTracepointsTest_7_0.java | 1771 ++++++++++------- .../GDBRemoteTracepointsTest_7_2.java | 3 + 9 files changed, 1380 insertions(+), 733 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java index 9b256bdc9a1..f4f91de6799 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java @@ -9,6 +9,7 @@ * QNX Software Systems - Initial API and implementation * Ericsson - Modified for DSF * Sergey Prigogin (Google) + * Marc Khouzam (Ericsson) - Support for fast tracepoints (Bug 346320) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.launching; @@ -30,9 +31,11 @@ import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; @@ -53,6 +56,14 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { protected Button fReverseCheckBox; protected Button fUpdateThreadlistOnSuspend; protected Button fDebugOnFork; + + /** + * A combo box to let the user choose if fast tracepoints should be used or not. + */ + protected Combo fTracepointModeCombo; + protected static final String TP_FAST_ONLY = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_fast"); //$NON-NLS-1$ + protected static final String TP_SLOW_ONLY = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_slow"); //$NON-NLS-1$ + protected static final String TP_AUTOMATIC = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_auto"); //$NON-NLS-1$ private IMILaunchConfigurationComponent fSolibBlock; private boolean fIsInitializing = false; @@ -82,7 +93,9 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT); configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_DEBUG_ON_FORK, IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_ON_FORK_DEFAULT); - + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE, + IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT); + if (fSolibBlock != null) fSolibBlock.setDefaults(configuration); } @@ -141,10 +154,46 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { fReverseCheckBox.setSelection(reverseEnabled); fUpdateThreadlistOnSuspend.setSelection(updateThreadsOnSuspend); fDebugOnFork.setSelection(debugOnFork); - + + updateTracepointModeFromConfig(configuration); + setInitializing(false); } + protected void updateTracepointModeFromConfig(ILaunchConfiguration config) { + if (fTracepointModeCombo != null) { + String tracepointMode = getStringAttr(config, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE, + IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT); + + if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_SLOW_ONLY)) { + fTracepointModeCombo.setText(TP_SLOW_ONLY); + } else if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_ONLY)) { + fTracepointModeCombo.setText(TP_FAST_ONLY); + } else if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW)) { + fTracepointModeCombo.setText(TP_AUTOMATIC); + } else { + assert false : "Unknown Tracepoint Mode: " + tracepointMode; //$NON-NLS-1$ + fTracepointModeCombo.setText(TP_SLOW_ONLY); + } + } + } + + protected String getSelectedTracepointMode() { + if (fTracepointModeCombo != null) { + int selectedIndex = fTracepointModeCombo.getSelectionIndex(); + if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_SLOW_ONLY)) { + return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_SLOW_ONLY; + } else if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_FAST_ONLY)) { + return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_ONLY; + } else if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_AUTOMATIC)) { + return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW; + } else { + assert false : "Unknown Tracepoint mode: " + fTracepointModeCombo.getItem(selectedIndex); //$NON-NLS-1$ + } + } + return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT; + } + public void performApply(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, fGDBCommandText.getText().trim()); @@ -158,6 +207,12 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { fUpdateThreadlistOnSuspend.getSelection()); configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_DEBUG_ON_FORK, fDebugOnFork.getSelection()); + + if (fTracepointModeCombo != null) { + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE, + getSelectedTracepointMode()); + } + if (fSolibBlock != null) fSolibBlock.performApply(configuration); } @@ -307,6 +362,30 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { PlatformUI.getWorkbench().getHelpSystem().setHelp(fUpdateThreadlistOnSuspend, GdbUIPlugin.PLUGIN_ID + ".update_threadlist_button_context"); //$NON-NLS-1$ fDebugOnFork = addCheckbox(subComp, LaunchUIMessages.getString("GDBDebuggerPage.Automatically_debug_forked_processes")); //$NON-NLS-1$ + + createTracepointModeCombo(subComp); + } + + protected void createTracepointModeCombo(Composite parent) { + // Add a combo to choose the type of tracepoint mode to use + Label label = ControlFactory.createLabel(parent, LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_label")); //$NON-NLS-1$ + label.setLayoutData(new GridData()); + + fTracepointModeCombo = new Combo(parent, SWT.READ_ONLY | SWT.DROP_DOWN); + fTracepointModeCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1)); + fTracepointModeCombo.add(TP_SLOW_ONLY); + fTracepointModeCombo.add(TP_FAST_ONLY); + fTracepointModeCombo.add(TP_AUTOMATIC); + + fTracepointModeCombo.addSelectionListener(new SelectionListener() { + public void widgetSelected(SelectionEvent e) { + updateLaunchConfigurationDialog(); + } + + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + fTracepointModeCombo.select(0); } public void createSolibTab(TabFolder tabFolder) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties index e31b056304e..4f51027f4a8 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties @@ -8,6 +8,7 @@ # Contributors: # QNX Software Systems - initial API and implementation # Ericsson - Updated for DSF +# Marc Khouzam (Ericsson) - Support for fast tracepoints (Bug 346320) ############################################################################### GDBDebuggerPage.gdb_executable_not_specified=Debugger executable must be specified. @@ -25,6 +26,10 @@ GDBDebuggerPage.nonstop_mode=Non-stop mode (Note: Requires non-stop GDB) GDBDebuggerPage.reverse_Debugging=Enable Reverse Debugging at startup (Note: Requires Reverse GDB) GDBDebuggerPage.update_thread_list_on_suspend=Force thread list update on suspend GDBDebuggerPage.Automatically_debug_forked_processes=Automatically debug forked processes (Note: Requires Multi Process GDB) +GDBDebuggerPage.tracepoint_mode_label=Tracepoint mode: +GDBDebuggerPage.tracepoint_mode_fast=Fast +GDBDebuggerPage.tracepoint_mode_slow=Slow +GDBDebuggerPage.tracepoint_mode_auto=Automatic StandardGDBDebuggerPage.0=Debugger executable must be specified. StandardGDBDebuggerPage.1=GDB Debugger Options StandardGDBDebuggerPage.2=Main diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java index 54233ba38dd..ebea21e6d59 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java @@ -7,6 +7,7 @@ * * Contributors: * Ericsson - initial API and implementation + * Marc Khouzam (Ericsson) - Support for fast tracepoints (Bug 346320) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb; @@ -104,7 +105,13 @@ public class IGDBLaunchConfigurationConstants { * @since 4.0 */ public static final String ATTR_DEBUGGER_DEBUG_ON_FORK = GdbPlugin.PLUGIN_ID + ".DEBUG_ON_FORK"; //$NON-NLS-1$ - + + /** + * Launch configuration attribute key. The value is a String specifying the type of Tracepoint mode + * that should be used for this launch. + * @since 4.1 + */ + public static final String ATTR_DEBUGGER_TRACEPOINT_MODE = GdbPlugin.PLUGIN_ID + ".TRACEPOINT_MODE"; //$NON-NLS-1$ /** * Launch configuration attribute value. The key is ATTR_DEBUG_NAME. @@ -174,6 +181,33 @@ public class IGDBLaunchConfigurationConstants { * @since 4.0 */ public static final boolean DEBUGGER_DEBUG_ON_FORK_DEFAULT = false; + + /** + * Possible attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE. + * Indicates that only slow tracepoints should be used. + * @since 4.1 + */ + public static final String DEBUGGER_TRACEPOINT_SLOW_ONLY = "TP_SLOW_ONLY"; //$NON-NLS-1$ + /** + * Possible attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE. + * Indicates that only fast tracepoints should be used. + * @since 4.1 + */ + public static final String DEBUGGER_TRACEPOINT_FAST_ONLY = "TP_FAST_ONLY"; //$NON-NLS-1$ + + /** + * Possible attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE. + * Indicates that slow tracepoints should be used whenever a fast tracepoint + * cannot be inserted. + * @since 4.1 + */ + public static final String DEBUGGER_TRACEPOINT_FAST_THEN_SLOW = "TP_FAST_THEN_SLOW"; //$NON-NLS-1$ + + /** + * Default attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE. + * @since 4.1 + */ + public static final String DEBUGGER_TRACEPOINT_MODE_DEFAULT = DEBUGGER_TRACEPOINT_SLOW_ONLY; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java index add70750871..0fdb7b704a6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java @@ -7,6 +7,7 @@ * * Contributors: * Ericsson - Initial API and implementation + * Marc Khouzam (Ericsson) - Support for fast tracepoints (Bug 346320) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.service; @@ -20,24 +21,32 @@ import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.debug.service.IBreakpoints; import org.eclipse.cdt.dsf.debug.service.IBreakpointsExtension; +import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.mi.service.IMICommandControl; import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData; import org.eclipse.cdt.dsf.mi.service.MIBreakpoints; import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo; import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.ILaunch; /** * Breakpoint service for GDB 7.2. * It support MI for tracepoints. + * It also support for fast vs slow tracepoints. * * @since 4.1 */ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0 { private IMICommandControl fConnection; + + private enum TracepointMode { FAST_THEN_SLOW, FAST_ONLY, SLOW_ONLY }; + + private TracepointMode fTracepointMode = TracepointMode.SLOW_ONLY; public GDBBreakpoints_7_2(DsfSession session) { super(session); @@ -60,6 +69,8 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0 // Get the services references fConnection = getServicesTracker().getService(IMICommandControl.class); + setTracepointMode(); + // Register this service register(new String[] { IBreakpoints.class.getName(), IBreakpointsExtension.class.getName(), @@ -76,36 +87,50 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0 unregister(); super.shutdown(requestMonitor); } + + private void setTracepointMode() { + ILaunch launch = (ILaunch)getSession().getModelAdapter(ILaunch.class); + String tpMode = IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT; + try { + tpMode = launch.getLaunchConfiguration().getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE, + IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT); + } catch (CoreException e) { + } - /** - * Add a tracepoint using MI - */ - @Override - protected void addTracepoint(final IBreakpointsTargetDMContext context, final Map attributes, final DataRequestMonitor drm) - { + if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_ONLY)) { + fTracepointMode = TracepointMode.FAST_ONLY; + } else if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_SLOW_ONLY)) { + fTracepointMode = TracepointMode.SLOW_ONLY; + } else if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW)) { + fTracepointMode = TracepointMode.FAST_THEN_SLOW; + } else { + assert false : "Invalid tracepoint mode: " + tpMode; //$NON-NLS-1$ + fTracepointMode = TracepointMode.SLOW_ONLY; + } + } + + protected void sendTracepointCommand(final IBreakpointsTargetDMContext context, final Map attributes, boolean isFastTracepoint, final DataRequestMonitor drm) { // Select the context breakpoints map final Map contextBreakpoints = getBreakpointMap(context); if (contextBreakpoints == null) { - drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null)); - drm.done(); + drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null)); + drm.done(); return; } // Extract the relevant parameters (providing default values to avoid potential NPEs) final String location = formatLocation(attributes); if (location.equals(NULL_STRING)) { - drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null)); - drm.done(); + drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null)); + drm.done(); return; } - final Boolean enabled = (Boolean) getProperty(attributes, MIBreakpoints.IS_ENABLED, true); - final Boolean isHardware = (Boolean) getProperty(attributes, MIBreakpointDMData.IS_HARDWARE, false); final String condition = (String) getProperty(attributes, MIBreakpoints.CONDITION, NULL_STRING); fConnection.queueCommand( - fConnection.getCommandFactory().createMIBreakInsert(context, false, isHardware, condition, 0, location, 0, !enabled, true), + fConnection.getCommandFactory().createMIBreakInsert(context, false, isFastTracepoint, condition, 0, location, 0, !enabled, true), new DataRequestMonitor(getExecutor(), drm) { @Override protected void handleSuccess() { @@ -127,20 +152,20 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0 contextBreakpoints.put(reference, newBreakpoint); // Format the return value - MIBreakpointDMContext dmc = new MIBreakpointDMContext(GDBBreakpoints_7_2.this, new IDMContext[] { context }, reference); - drm.setData(dmc); + MIBreakpointDMContext dmc = new MIBreakpointDMContext(GDBBreakpoints_7_2.this, new IDMContext[] { context }, reference); + drm.setData(dmc); - // Flag the event - getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties()); - - // Tracepoints are created with no passcount (passcount are not - // the same thing as ignore-count, which is not supported by - // tracepoints). We have to set the passcount manually now. - // Same for commands. - Map delta = new HashMap(); - delta.put(MIBreakpoints.PASS_COUNT, getProperty(attributes, MIBreakpoints.PASS_COUNT, 0)); - delta.put(MIBreakpoints.COMMANDS, getProperty(attributes, MIBreakpoints.COMMANDS, "")); //$NON-NLS-1$ - modifyBreakpoint(dmc, delta, drm, false); + // Flag the event + getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties()); + + // Tracepoints are created with no passcount (passcount are not + // the same thing as ignore-count, which is not supported by + // tracepoints). We have to set the passcount manually now. + // Same for commands. + Map delta = new HashMap(); + delta.put(MIBreakpoints.PASS_COUNT, getProperty(attributes, MIBreakpoints.PASS_COUNT, 0)); + delta.put(MIBreakpoints.COMMANDS, getProperty(attributes, MIBreakpoints.COMMANDS, "")); //$NON-NLS-1$ + modifyBreakpoint(dmc, delta, drm, false); } @Override @@ -150,4 +175,37 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0 } }); } + /** + * Add a tracepoint using MI. We have three settings: + * 1- set only a fast tracepoint but if it fails, set a slow tracepoint + * 2- only set a fast tracepoint even if it fails + * 3- only set a slow tracepoint even if a fast tracepoint could have been used + */ + @Override + protected void addTracepoint(final IBreakpointsTargetDMContext context, final Map attributes, final DataRequestMonitor drm) { + // Unless we should only set slow tracepoints, we try to set a fast tracepoint. + boolean isFastTracepoint = fTracepointMode != TracepointMode.SLOW_ONLY; + + sendTracepointCommand(context, attributes, isFastTracepoint, new DataRequestMonitor(ImmediateExecutor.getInstance(), drm) { + @Override + protected void handleSuccess() { + // Tracepoint was set successfully. + drm.setData(getData()); + drm.done(); + } + @Override + protected void handleError() { + // Tracepoint failed to be set. + if (fTracepointMode == TracepointMode.FAST_THEN_SLOW) { + // In this case, we failed to set a fast tracepoint, but we should try to set a slow one. + sendTracepointCommand(context, attributes, false, drm); + } else { + // We either failed to set a fast tracepoint and we should not try to set a slow one, + // or we failed to set a slow one. Either way, we are done. + drm.setStatus(getStatus()); + drm.done(); + } + } + }); + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java index cd62c78403f..8af2b962ee4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java @@ -100,7 +100,9 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory { @Override protected IBreakpoints createBreakpointService(DsfSession session) { - if (GDB_7_2_VERSION.compareTo(fVersion) <= 0) { + // This service is available for GDB 7.2 but there is a pre-release of GDB that + // supports the same features and has version of 6.8.50.20090414 + if (GDB_7_2_VERSION.compareTo(fVersion) <= 0 || "6.8.50.20090414".equals(fVersion)) { //$NON-NLS-1$ return new GDBBreakpoints_7_2(session); } if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) { @@ -192,8 +194,8 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory { /** @since 3.0 */ protected IGDBTraceControl createTraceControlService(DsfSession session, ILaunchConfiguration config) { - // This service is available for GDB 7.2. But until that GDB is itself available - // there is a pre-release that has a version of 6.8.50.20090414 + // This service is available for GDB 7.2 but there is a pre-release of GDB that + // supports the same features and has version of 6.8.50.20090414 if (GDB_7_2_VERSION.compareTo(fVersion) <= 0 || "6.8.50.20090414".equals(fVersion)) { //$NON-NLS-1$ return new GDBTraceControl_7_2(session, config); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java index ab7d87cea57..6c67e986119 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java @@ -17,6 +17,8 @@ package org.eclipse.cdt.dsf.mi.service.command.output; import java.util.StringTokenizer; +import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.TracepointActionManager; + /** * Contain info about the GDB/MI breakpoint. * @@ -497,8 +499,29 @@ public class MIBreakpoint { cond = str; } else if (var.equals("pending")) { //$NON-NLS-1$ // Only supported starting with GDB 6.8 - pending = true; + pending = true; + } else if (var.equals("script")) { //$NON-NLS-1$ + if (value instanceof MITuple) { + parseCommands((MITuple)value); + } } } } + + void parseCommands(MITuple tuple) { + MIValue[] values = tuple.getMIValues(); + StringBuffer cmds = new StringBuffer(); + for (int i = 0; i < values.length; i++) { + MIValue value = values[i]; + if (value != null && value instanceof MIConst) { + if (i > 0) { + // Insert a delimiter + cmds.append(TracepointActionManager.TRACEPOINT_ACTION_DELIMITER); + } + cmds.append(((MIConst)value).getCString()); + } + } + setCommands(cmds.toString()); + + } } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/TracepointTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/TracepointTestApp.cc index 1c6802d73f7..5bfe8649f95 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/TracepointTestApp.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/TracepointTestApp.cc @@ -1,4 +1,12 @@ +#ifdef __MINGW32__ + #include // MinGW has no POSIX support; use MSVC runtime +#else + #include +#endif #include +#include +#include "Sleep.h" +#define NUM_THREADS 5 int gIntVar = 543; double gDoubleVar = 543.543; @@ -52,8 +60,21 @@ public: Z z; }; -void testTracepoints() { - printf("Running TracepointTest App\n"); +#ifdef __MINGW32__ +typedef unsigned int TID; +#else +typedef pthread_t TID; +#endif + + +#ifdef __MINGW32__ +unsigned int __stdcall testTracepoints(void *threadid) +#else +void *testTracepoints(void *threadid) +#endif +{ + int tid = (int)threadid; + printf("Hello World! It's me, thread #%d!\n", tid); int lIntVar = 12345; double lDoubleVar = 12345.12345; @@ -81,16 +102,53 @@ void testTracepoints() { counter++; } - counter = 185; + printf("counter is now #%d!\n", counter); // Large loop - for (counter=0; counter<10000;) { + for (; counter<10000;) { counter++; } -} -int main() { - testTracepoints(); + SLEEP(2); // keep this thread around for a bit; the tests will check for its existence while the main thread is stopped at a breakpoint + +#ifdef __MINGW32__ return 0; +#else + pthread_exit(NULL); +#endif +} + +int main() +{ + TID threads[NUM_THREADS]; + int t; + for(t=0; t < NUM_THREADS; t++) + { + printf("In main: creating thread %d\n", t); +#ifdef __MINGW32__ + { + uintptr_t rc = _beginthreadex(NULL, 0, testTracepoints, (void*)t, 0, &threads[t]); + SLEEP(1); // debugger should for sure receive thread creation event after stepping over this sleep; not guaranteed to happen simply stepping over the thread creation call + if (rc == 0) + { + printf("ERROR; _beginthreadex() failed. errno = %d\n", errno); + exit(-1); + } + } +#else + { + int rc = pthread_create(&threads[t], NULL, testTracepoints, (void *)t); + SLEEP(1); // debugger should for sure receive thread creation event after stepping over this sleep; not guaranteed to happen simply stepping over the thread creation call + if (rc) + { + printf("ERROR; return code from pthread_create() is %d\n", rc); + exit(-1); + } + } +#endif + } + + SLEEP(2); // keep this thread around for a bit + return 0; } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java index 5370d37bad3..e4934649e8e 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java @@ -30,6 +30,9 @@ import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContex import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsUpdatedEvent; import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; +import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.CollectAction; +import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.EvaluateAction; +import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.TracepointActionManager; import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData; import org.eclipse.cdt.dsf.mi.service.MIBreakpoints; import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; @@ -52,110 +55,147 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { @BeforeClass public static void beforeClassMethod_7_0() { setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_0); - + setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/TracepointTestApp.exe"); - + // GDB tracepoints are only supported on a remote target (e.g., using gdbserver) setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, - IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); + IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); + + // To test both fast and slow tracepoint we just the FAST_THEN_SLOW setting + setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE, + IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW); } - + private DsfSession fSession; private DsfServicesTracker fServicesTracker; private IBreakpoints fBreakpointService; -// private ITraceControl fTraceService; + // private ITraceControl fTraceService; private IBreakpointsTargetDMContext fBreakpointsDmc; -// private ITraceTargetDMContext fTraceTargetDmc; + // private ITraceTargetDMContext fTraceTargetDmc; + + // private int fTotalTracingBufferSize = 0; + + private static final String SOURCE_FILE = "TracepointTestApp.cc"; + private static final String METHOD_NAME = "testTracepoints"; + private static final int LINE_NUMBER_1 = 97; + private static final int LINE_NUMBER_2 = 75; + private static final int LINE_NUMBER_3 = 76; + private static final int LINE_NUMBER_4 = 85; + private static final int LINE_LOOP_2 = 109; + private static final String NO_CONDITION = ""; + private static final String NO_COMMANDS = ""; + // private static final int LAST_LINE_NUMBER = 94; + // + // private static final int TOTAL_FRAMES_TO_BE_COLLECTED = 1 + 1 + 10 + 1 + 10000; -// private int fTotalTracingBufferSize = 0; - private final static int[] PASS_COUNTS = {12, 2, 32, 6, 128, 0, 0, 0, 0, 0, 0, 0}; + private final static String[] CONDITIONS = {"gIntVar == 543", "gBoolVar == false", "counter == 3", "counter > 4", "counter > 2 && lIntVar == 12345"}; -// private static CollectAction COLLECT_ACTION_1; -// private static CollectAction COLLECT_ACTION_2; -// private static CollectAction COLLECT_ACTION_3; -// private static EvalAction EVAL_ACTION_1; -// private static EvalAction EVAL_ACTION_2; -// private static EvalAction EVAL_ACTION_3; -// private static WhileSteppingAction STEPPING_ACTION_1; -// private static WhileSteppingAction STEPPING_ACTION_2; -// private static WhileSteppingAction STEPPING_ACTION_3; + private static CollectAction[] COLLECT_ACTIONS = new CollectAction[10]; + private static EvaluateAction[] EVAL_ACTIONS = new EvaluateAction[10]; + // private static WhileSteppingAction[] STEPPING_ACTION_1 = new WhileSteppingAction[3]; + static { + TracepointActionManager tracepointActionMgr = TracepointActionManager.getInstance(); -// static { -// BreakpointActionManager breakpointActionMgr = CDebugCorePlugin.getDefault().getBreakpointActionManager(); -// -// COLLECT_ACTION_1 = new CollectAction(); -// COLLECT_ACTION_1.setCollectString("$locals, counter"); -// COLLECT_ACTION_1.setName("CollectAction1"); -// breakpointActionMgr.addAction(COLLECT_ACTION_1); -// -// COLLECT_ACTION_2 = new CollectAction(); -// COLLECT_ACTION_2.setCollectString("$reg"); -// COLLECT_ACTION_2.setName("CollectAction2"); -// breakpointActionMgr.addAction(COLLECT_ACTION_2); -// -// COLLECT_ACTION_3 = new CollectAction(); -// COLLECT_ACTION_3.setCollectString("$myTraceVariable"); -// COLLECT_ACTION_3.setName("CollectAction3"); -// breakpointActionMgr.addAction(COLLECT_ACTION_3); -// -// -// EVAL_ACTION_1 = new EvalAction(); -// EVAL_ACTION_1.setEvalString("$count=$count+1"); -// EVAL_ACTION_1.setName("EvalAction1"); -// breakpointActionMgr.addAction(EVAL_ACTION_1); -// -// EVAL_ACTION_2 = new EvalAction(); -// EVAL_ACTION_2.setEvalString("$count2=$count2+2"); -// EVAL_ACTION_2.setName("EvalAction2"); -// breakpointActionMgr.addAction(EVAL_ACTION_2); -// -// EVAL_ACTION_3 = new EvalAction(); -// EVAL_ACTION_3.setEvalString("$count3=$count3+3"); -// EVAL_ACTION_3.setName("EvalAction3"); -// breakpointActionMgr.addAction(EVAL_ACTION_3); -// -// //TODO do while stepping actions -// -// } + int index = 0; + COLLECT_ACTIONS[index] = new CollectAction(); + COLLECT_ACTIONS[index].setCollectString("$locals"); + COLLECT_ACTIONS[index].setName("Collect locals"); + tracepointActionMgr.addAction(COLLECT_ACTIONS[index]); + index++; - @Before - public void initialTest() throws Exception { - fSession = getGDBLaunch().getSession(); - Runnable runnable = new Runnable() { - public void run() { - fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId()); + COLLECT_ACTIONS[index] = new CollectAction(); + COLLECT_ACTIONS[index].setCollectString("gIntVar"); + COLLECT_ACTIONS[index].setName("Collect gIntVar"); + tracepointActionMgr.addAction(COLLECT_ACTIONS[index]); + index++; - - fBreakpointService = fServicesTracker.getService(IBreakpoints.class); -// fTraceService = fServicesTracker.getService(ITraceControl.class); - fSession.addServiceEventListener(GDBRemoteTracepointsTest_7_0.this, null); - - // Create a large array to make sure we don't run out - fTracepoints = new IBreakpointDMContext[100]; - - // Run an initial test to check that everything is ok with GDB - checkTraceInitialStatus(); - } - }; - fSession.getExecutor().submit(runnable).get(); - - IContainerDMContext containerDmc = SyncUtil.getContainerContext(); - fBreakpointsDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); - assert(fBreakpointsDmc != null); -// fTraceTargetDmc = DMContexts.getAncestorOfType(containerDmc, ITraceTargetDMContext.class); + COLLECT_ACTIONS[index] = new CollectAction(); + COLLECT_ACTIONS[index].setCollectString("$locals, counter, $reg"); + COLLECT_ACTIONS[index].setName("Collect locals, counter and reg"); + tracepointActionMgr.addAction(COLLECT_ACTIONS[index]); + index++; + + COLLECT_ACTIONS[index] = new CollectAction(); + COLLECT_ACTIONS[index].setCollectString("$reg"); + COLLECT_ACTIONS[index].setName("Collect reg"); + tracepointActionMgr.addAction(COLLECT_ACTIONS[index]); + index++; + + COLLECT_ACTIONS[index] = new CollectAction(); + COLLECT_ACTIONS[index].setCollectString("counter, $locals"); + COLLECT_ACTIONS[index].setName("Collect counter, locals"); + tracepointActionMgr.addAction(COLLECT_ACTIONS[index]); + index++; + + COLLECT_ACTIONS[index] = new CollectAction(); + COLLECT_ACTIONS[index].setCollectString("$myTraceVariable"); + COLLECT_ACTIONS[index].setName("Collect myTraceVariable"); + tracepointActionMgr.addAction(COLLECT_ACTIONS[index]); + index++; + + index=0; + EVAL_ACTIONS[index] = new EvaluateAction(); + EVAL_ACTIONS[index].setEvalString("$count=$count+1"); + EVAL_ACTIONS[index].setName("Eval increment count"); + tracepointActionMgr.addAction(EVAL_ACTIONS[index]); + index++; + + EVAL_ACTIONS[index] = new EvaluateAction(); + EVAL_ACTIONS[index].setEvalString("$count2=$count2+2"); + EVAL_ACTIONS[index].setName("Eval increment count2 by 2"); + tracepointActionMgr.addAction(EVAL_ACTIONS[index]); + index++; + + EVAL_ACTIONS[index] = new EvaluateAction(); + EVAL_ACTIONS[index].setEvalString("$count3=$count3+3"); + EVAL_ACTIONS[index].setName("Eval increment count3 by 3"); + tracepointActionMgr.addAction(EVAL_ACTIONS[index]); + index++; + + //TODO do while stepping actions + index=0; } - + + @Before + public void initialTest() throws Exception { + fSession = getGDBLaunch().getSession(); + Runnable runnable = new Runnable() { + public void run() { + fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId()); + + + fBreakpointService = fServicesTracker.getService(IBreakpoints.class); + // fTraceService = fServicesTracker.getService(ITraceControl.class); + fSession.addServiceEventListener(GDBRemoteTracepointsTest_7_0.this, null); + + // Create a large array to make sure we don't run out + fTracepoints = new IBreakpointDMContext[100]; + + // Run an initial test to check that everything is ok with GDB + checkTraceInitialStatus(); + } + }; + fSession.getExecutor().submit(runnable).get(); + + IContainerDMContext containerDmc = SyncUtil.getContainerContext(); + fBreakpointsDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); + assert(fBreakpointsDmc != null); + // fTraceTargetDmc = DMContexts.getAncestorOfType(containerDmc, ITraceTargetDMContext.class); + + } + @After public void shutdown() throws Exception { - Runnable runnable = new Runnable() { - public void run() { - fSession.removeServiceEventListener(GDBRemoteTracepointsTest_7_0.this); - } - }; - fSession.getExecutor().submit(runnable).get(); + Runnable runnable = new Runnable() { + public void run() { + fSession.removeServiceEventListener(GDBRemoteTracepointsTest_7_0.this); + } + }; + fSession.getExecutor().submit(runnable).get(); fBreakpointService = null; fServicesTracker.dispose(); } @@ -164,44 +204,44 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { // ********************************************************************* // Below are utility methods. // ********************************************************************* - private static Boolean lock = true; - enum Events {BP_ADDED, BP_UPDATED, BP_REMOVED, BP_HIT} - final int BP_ADDED = Events.BP_ADDED.ordinal(); - final int BP_UPDATED = Events.BP_UPDATED.ordinal(); - final int BP_REMOVED = Events.BP_REMOVED.ordinal(); - final int BP_HIT = Events.BP_HIT.ordinal(); - private int[] fBreakpointEvents = new int[Events.values().length]; - private boolean fBreakpointEvent; - private int fBreakpointEventCount; + private static Boolean lock = true; + enum Events {BP_ADDED, BP_UPDATED, BP_REMOVED, BP_HIT} + final int BP_ADDED = Events.BP_ADDED.ordinal(); + final int BP_UPDATED = Events.BP_UPDATED.ordinal(); + final int BP_REMOVED = Events.BP_REMOVED.ordinal(); + final int BP_HIT = Events.BP_HIT.ordinal(); + private int[] fBreakpointEvents = new int[Events.values().length]; + private boolean fBreakpointEvent; + private int fBreakpointEventCount; - @DsfServiceEventHandler + @DsfServiceEventHandler public void eventDispatched(IBreakpointsAddedEvent e) { - synchronized (lock) { - fBreakpointEvents[BP_ADDED]++; - fBreakpointEventCount++; - fBreakpointEvent = true; - lock.notifyAll(); - } + synchronized (lock) { + fBreakpointEvents[BP_ADDED]++; + fBreakpointEventCount++; + fBreakpointEvent = true; + lock.notifyAll(); + } } - @DsfServiceEventHandler + @DsfServiceEventHandler public void eventDispatched(IBreakpointsUpdatedEvent e) { - synchronized (lock) { - fBreakpointEvents[BP_UPDATED]++; - fBreakpointEventCount++; - fBreakpointEvent = true; - lock.notifyAll(); - } + synchronized (lock) { + fBreakpointEvents[BP_UPDATED]++; + fBreakpointEventCount++; + fBreakpointEvent = true; + lock.notifyAll(); + } } - @DsfServiceEventHandler + @DsfServiceEventHandler public void eventDispatched(IBreakpointsRemovedEvent e) { - synchronized (lock) { - fBreakpointEvents[BP_REMOVED]++; - fBreakpointEventCount++; - fBreakpointEvent = true; - lock.notifyAll(); - } + synchronized (lock) { + fBreakpointEvents[BP_REMOVED]++; + fBreakpointEventCount++; + fBreakpointEvent = true; + lock.notifyAll(); + } } // Clears the counters @@ -218,9 +258,9 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { // Get the breakpoint hit count private int getBreakpointEventCount(int event) { int count = 0; - synchronized (lock) { - count = fBreakpointEvents[event]; - } + synchronized (lock) { + count = fBreakpointEvents[event]; + } return count; } @@ -235,338 +275,325 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { } } fBreakpointEvent = false; - } + } } // ********************************************************************* // Breakpoint service methods (to use with tracepoints). // ********************************************************************* - private IBreakpointDMContext insertBreakpoint(final IBreakpointsTargetDMContext context, - final Map attributes) throws InterruptedException - { - final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); + private IBreakpointDMContext insertBreakpoint(final IBreakpointsTargetDMContext context, + final Map attributes) throws InterruptedException + { + final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); - fBreakpointService.getExecutor().submit(new Runnable() { - public void run() { - fBreakpointService.insertBreakpoint(context, attributes, - new DataRequestMonitor(fBreakpointService.getExecutor(), null) { - @Override - protected void handleCompleted() { - wait.setReturnInfo(getData()); - wait.waitFinished(getStatus()); - } - }); - } - }); + fBreakpointService.getExecutor().submit(new Runnable() { + public void run() { + fBreakpointService.insertBreakpoint(context, attributes, + new DataRequestMonitor(fBreakpointService.getExecutor(), null) { + @Override + protected void handleCompleted() { + wait.setReturnInfo(getData()); + wait.waitFinished(getStatus()); + } + }); + } + }); - // Wait for the result and return the breakpoint id - wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + // Wait for the result and return the breakpoint id + wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); assertTrue(wait.getMessage(), wait.isOK()); - return (IBreakpointDMContext)wait.getReturnInfo(); - } + return (IBreakpointDMContext)wait.getReturnInfo(); + } - private void removeBreakpoint(final IBreakpointDMContext breakpoint) throws InterruptedException - { - final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); + private void removeBreakpoint(final IBreakpointDMContext breakpoint) throws InterruptedException + { + final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); - fBreakpointService.getExecutor().submit(new Runnable() { - public void run() { - fBreakpointService.removeBreakpoint(breakpoint, - new RequestMonitor(fBreakpointService.getExecutor(), null) { - @Override - protected void handleCompleted() { - wait.waitFinished(getStatus()); - } - }); - } - }); + fBreakpointService.getExecutor().submit(new Runnable() { + public void run() { + fBreakpointService.removeBreakpoint(breakpoint, + new RequestMonitor(fBreakpointService.getExecutor(), null) { + @Override + protected void handleCompleted() { + wait.waitFinished(getStatus()); + } + }); + } + }); - wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); assertTrue(wait.getMessage(), wait.isOK()); - } + } - private void updateBreakpoint(final IBreakpointDMContext breakpoint, - final Map delta) throws InterruptedException - { - final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); + private void updateBreakpoint(final IBreakpointDMContext breakpoint, + final Map delta) throws InterruptedException + { + final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); - fBreakpointService.getExecutor().submit(new Runnable() { - public void run() { - fBreakpointService.updateBreakpoint(breakpoint, delta, - new RequestMonitor(fBreakpointService.getExecutor(), null) { - @Override - protected void handleCompleted() { - wait.waitFinished(getStatus()); - } - }); - } - }); + fBreakpointService.getExecutor().submit(new Runnable() { + public void run() { + fBreakpointService.updateBreakpoint(breakpoint, delta, + new RequestMonitor(fBreakpointService.getExecutor(), null) { + @Override + protected void handleCompleted() { + wait.waitFinished(getStatus()); + } + }); + } + }); - wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); assertTrue(wait.getMessage(), wait.isOK()); - } - - private IBreakpointDMData getBreakpoint(final IBreakpointDMContext breakpoint) throws InterruptedException - { - final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); + } - fBreakpointService.getExecutor().submit(new Runnable() { - public void run() { - fBreakpointService.getBreakpointDMData(breakpoint, - new DataRequestMonitor(fBreakpointService.getExecutor(), null) { - @Override - protected void handleCompleted() { - wait.setReturnInfo(getData()); - wait.waitFinished(getStatus()); - } - }); - } - }); + private IBreakpointDMData getBreakpoint(final IBreakpointDMContext breakpoint) throws InterruptedException + { + final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); - wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); - assertTrue(wait.getMessage(), wait.isOK()); + fBreakpointService.getExecutor().submit(new Runnable() { + public void run() { + fBreakpointService.getBreakpointDMData(breakpoint, + new DataRequestMonitor(fBreakpointService.getExecutor(), null) { + @Override + protected void handleCompleted() { + wait.setReturnInfo(getData()); + wait.waitFinished(getStatus()); + } + }); + } + }); - return (IBreakpointDMData)wait.getReturnInfo(); - } - - private IBreakpointDMContext[] getBreakpoints(final IBreakpointsTargetDMContext context) throws InterruptedException - { - final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); + wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + assertTrue(wait.getMessage(), wait.isOK()); - fBreakpointService.getExecutor().submit(new Runnable() { - public void run() { - fBreakpointService.getBreakpoints(context, new DataRequestMonitor(fBreakpointService.getExecutor(), null) { - @Override - protected void handleCompleted() { - wait.setReturnInfo(getData()); - wait.waitFinished(getStatus()); - } - }); - } - }); + return (IBreakpointDMData)wait.getReturnInfo(); + } - wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); - assertTrue(wait.getMessage(), wait.isOK()); + private IBreakpointDMContext[] getBreakpoints(final IBreakpointsTargetDMContext context) throws InterruptedException + { + final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); - return (IBreakpointDMContext[])wait.getReturnInfo(); - } + fBreakpointService.getExecutor().submit(new Runnable() { + public void run() { + fBreakpointService.getBreakpoints(context, new DataRequestMonitor(fBreakpointService.getExecutor(), null) { + @Override + protected void handleCompleted() { + wait.setReturnInfo(getData()); + wait.waitFinished(getStatus()); + } + }); + } + }); + + wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + assertTrue(wait.getMessage(), wait.isOK()); + + return (IBreakpointDMContext[])wait.getReturnInfo(); + } // ********************************************************************* // TraceControl service methods. // ********************************************************************* -// private void startTracing() throws InterruptedException -// { -// startTracing(null); -// } -// -// private void startTracing(String errorMessage) throws InterruptedException -// { -// final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); -// -// fTraceService.getExecutor().submit(new Runnable() { -// public void run() { -// fTraceService.canStartTracing(fTraceTargetDmc, -// new DataRequestMonitor(fTraceService.getExecutor(), null) { -// @Override -// protected void handleCompleted() { -// wait.setReturnInfo(getData()); -// wait.waitFinished(getStatus()); -// } -// }); -// } -// }); -// -// wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); -// assertTrue(wait.getMessage(), wait.isOK()); -// assertTrue("Not allowed to start tracing!", (Boolean)wait.getReturnInfo()); -// -// wait.waitReset(); -// -// fTraceService.getExecutor().submit(new Runnable() { -// public void run() { -// fTraceService.startTracing(fTraceTargetDmc, -// new RequestMonitor(fTraceService.getExecutor(), null) { -// @Override -// protected void handleCompleted() { -// wait.waitFinished(getStatus()); -// } -// }); -// } -// }); -// -// wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); -// if (errorMessage == null) { -// assertTrue(wait.getMessage(), wait.isOK()); -// } else { -// assertTrue(wait.getMessage(), !wait.isOK()); -// assertTrue("Message " + wait.getMessage() + " does not contain \"" + errorMessage +"\"", -// wait.getMessage().indexOf(errorMessage) != -1); -// } -// } -// -// private void stopTracing() throws InterruptedException -// { -// final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); -// -// fTraceService.getExecutor().submit(new Runnable() { -// public void run() { -// fTraceService.canStopTracing(fTraceTargetDmc, -// new DataRequestMonitor(fTraceService.getExecutor(), null) { -// @Override -// protected void handleCompleted() { -// wait.setReturnInfo(getData()); -// wait.waitFinished(getStatus()); -// } -// }); -// } -// }); -// -// wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); -// assertTrue(wait.getMessage(), wait.isOK()); -// assertTrue("Not allowed to stop tracing!", (Boolean)wait.getReturnInfo()); -// -// wait.waitReset(); -// -// fTraceService.getExecutor().submit(new Runnable() { -// public void run() { -// fTraceService.stopTracing(fTraceTargetDmc, -// new RequestMonitor(fTraceService.getExecutor(), null) { -// @Override -// protected void handleCompleted() { -// wait.waitFinished(getStatus()); -// } -// }); -// } -// }); -// -// wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); -// assertTrue(wait.getMessage(), wait.isOK()); -// } -// -// private boolean isTracing() throws InterruptedException -// { -// final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); -// -// fTraceService.getExecutor().submit(new Runnable() { -// public void run() { -// fTraceService.isTracing(fTraceTargetDmc, -// new DataRequestMonitor(fTraceService.getExecutor(), null) { -// @Override -// protected void handleCompleted() { -// wait.setReturnInfo(getData()); -// wait.waitFinished(getStatus()); -// } -// }); -// } -// }); -// -// wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); -// assertTrue(wait.getMessage(), wait.isOK()); -// -// return (Boolean)wait.getReturnInfo(); -// } -// -// private ITraceStatusDMData getTraceStatus() throws InterruptedException -// { -// final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); -// -// fTraceService.getExecutor().submit(new Runnable() { -// public void run() { -// fTraceService.getTraceStatus(fTraceTargetDmc, -// new DataRequestMonitor(fTraceService.getExecutor(), null) { -// @Override -// protected void handleCompleted() { -// wait.setReturnInfo(getData()); -// wait.waitFinished(getStatus()); -// } -// }); -// } -// }); -// -// wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); -// assertTrue(wait.getMessage(), wait.isOK()); -// -// return (ITraceStatusDMData)wait.getReturnInfo(); -// } + // private void startTracing() throws InterruptedException + // { + // startTracing(null); + // } + // + // private void startTracing(String errorMessage) throws InterruptedException + // { + // final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); + // + // fTraceService.getExecutor().submit(new Runnable() { + // public void run() { + // fTraceService.canStartTracing(fTraceTargetDmc, + // new DataRequestMonitor(fTraceService.getExecutor(), null) { + // @Override + // protected void handleCompleted() { + // wait.setReturnInfo(getData()); + // wait.waitFinished(getStatus()); + // } + // }); + // } + // }); + // + // wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + // assertTrue(wait.getMessage(), wait.isOK()); + // assertTrue("Not allowed to start tracing!", (Boolean)wait.getReturnInfo()); + // + // wait.waitReset(); + // + // fTraceService.getExecutor().submit(new Runnable() { + // public void run() { + // fTraceService.startTracing(fTraceTargetDmc, + // new RequestMonitor(fTraceService.getExecutor(), null) { + // @Override + // protected void handleCompleted() { + // wait.waitFinished(getStatus()); + // } + // }); + // } + // }); + // + // wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + // if (errorMessage == null) { + // assertTrue(wait.getMessage(), wait.isOK()); + // } else { + // assertTrue(wait.getMessage(), !wait.isOK()); + // assertTrue("Message " + wait.getMessage() + " does not contain \"" + errorMessage +"\"", + // wait.getMessage().indexOf(errorMessage) != -1); + // } + // } + // + // private void stopTracing() throws InterruptedException + // { + // final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); + // + // fTraceService.getExecutor().submit(new Runnable() { + // public void run() { + // fTraceService.canStopTracing(fTraceTargetDmc, + // new DataRequestMonitor(fTraceService.getExecutor(), null) { + // @Override + // protected void handleCompleted() { + // wait.setReturnInfo(getData()); + // wait.waitFinished(getStatus()); + // } + // }); + // } + // }); + // + // wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + // assertTrue(wait.getMessage(), wait.isOK()); + // assertTrue("Not allowed to stop tracing!", (Boolean)wait.getReturnInfo()); + // + // wait.waitReset(); + // + // fTraceService.getExecutor().submit(new Runnable() { + // public void run() { + // fTraceService.stopTracing(fTraceTargetDmc, + // new RequestMonitor(fTraceService.getExecutor(), null) { + // @Override + // protected void handleCompleted() { + // wait.waitFinished(getStatus()); + // } + // }); + // } + // }); + // + // wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + // assertTrue(wait.getMessage(), wait.isOK()); + // } + // + // private boolean isTracing() throws InterruptedException + // { + // final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); + // + // fTraceService.getExecutor().submit(new Runnable() { + // public void run() { + // fTraceService.isTracing(fTraceTargetDmc, + // new DataRequestMonitor(fTraceService.getExecutor(), null) { + // @Override + // protected void handleCompleted() { + // wait.setReturnInfo(getData()); + // wait.waitFinished(getStatus()); + // } + // }); + // } + // }); + // + // wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + // assertTrue(wait.getMessage(), wait.isOK()); + // + // return (Boolean)wait.getReturnInfo(); + // } + // + // private ITraceStatusDMData getTraceStatus() throws InterruptedException + // { + // final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); + // + // fTraceService.getExecutor().submit(new Runnable() { + // public void run() { + // fTraceService.getTraceStatus(fTraceTargetDmc, + // new DataRequestMonitor(fTraceService.getExecutor(), null) { + // @Override + // protected void handleCompleted() { + // wait.setReturnInfo(getData()); + // wait.waitFinished(getStatus()); + // } + // }); + // } + // }); + // + // wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER); + // assertTrue(wait.getMessage(), wait.isOK()); + // + // return (ITraceStatusDMData)wait.getReturnInfo(); + // } // ********************************************************************* // Below are the tests for the control of tracepoints. // ********************************************************************* - private static final String SOURCE_FILE = "TracepointTestApp.cc"; - private static final String METHOD_NAME = "testTracepoints"; - private static final int LINE_NUMBER_1 = 84; - private static final int LINE_NUMBER_2 = 55; - private static final int LINE_NUMBER_3 = 56; - private static final int LINE_LOOP_1 = 81; - private static final int LINE_LOOP_2 = 88; - private static final String NO_CONDITION = ""; -// private static final int LAST_LINE_NUMBER = 94; -// -// private static final int TOTAL_FRAMES_TO_BE_COLLECTED = 1 + 1 + 10 + 1 + 10000; + private IBreakpointDMContext[] fTracepoints = null; + // private void checkTraceStatus(boolean supported, boolean active, int frames, + // STOP_REASON_ENUM reason, Integer stoppingTracepoint) throws Throwable { + // ITraceStatusDMData status = getTraceStatus(); + // assertTrue("Error tracing supported should be " + supported + " but was " + status.isTracingSupported(), + // status.isTracingSupported() == supported); + // assertTrue("Error tracing active should be " + active + " but was " + status.isTracingActive(), + // status.isTracingActive() == active); + // boolean isTracing = isTracing(); + // assertTrue("Error, tracing active is " + status.isTracingActive() + " but the tracepoint service thinks it is " + isTracing, + // status.isTracingActive() == isTracing); + // + // assertTrue("Wrong number of collected frames. Expected " + frames + " but got " + + // status.getNumberOfCollectedFrame(), + // status.getNumberOfCollectedFrame() == frames); + // assertTrue("Total buffer size should be positive but is " + + // status.getTotalBufferSize(), + // status.getTotalBufferSize() > 0); + // + // if (fTotalTracingBufferSize == 0) { + // // Initialize buffer + // fTotalTracingBufferSize = status.getTotalBufferSize(); + // } else { + // assertTrue("Total buffer size changed! Should be " + fTotalTracingBufferSize + + // " but got " + status.getTotalBufferSize(), + // status.getTotalBufferSize() == fTotalTracingBufferSize); + // } + // + // assertTrue("Expected stopping reason " + reason + " but got " + status.getStopReason(), + // status.getStopReason() == reason); + // assertTrue("Expected stopping bp " + stoppingTracepoint + " but got " + status.getStoppingTracepoint(), + // status.getStoppingTracepoint() == stoppingTracepoint); + // } + // + // private void checkTraceStatus(boolean supported, boolean active, int frames) throws Throwable { + // checkTraceStatus(supported, active, frames, null, null); + // } - private IBreakpointDMContext[] fTracepoints = null; + // GDB 7.0 does not support fast tracepoints, but GDB 7.2 will + protected boolean fastTracepointsSupported() { return false; } -// private void checkTraceStatus(boolean supported, boolean active, int frames, -// STOP_REASON_ENUM reason, Integer stoppingTracepoint) throws Throwable { -// ITraceStatusDMData status = getTraceStatus(); -// assertTrue("Error tracing supported should be " + supported + " but was " + status.isTracingSupported(), -// status.isTracingSupported() == supported); -// assertTrue("Error tracing active should be " + active + " but was " + status.isTracingActive(), -// status.isTracingActive() == active); -// boolean isTracing = isTracing(); -// assertTrue("Error, tracing active is " + status.isTracingActive() + " but the tracepoint service thinks it is " + isTracing, -// status.isTracingActive() == isTracing); -// -// assertTrue("Wrong number of collected frames. Expected " + frames + " but got " + -// status.getNumberOfCollectedFrame(), -// status.getNumberOfCollectedFrame() == frames); -// assertTrue("Total buffer size should be positive but is " + -// status.getTotalBufferSize(), -// status.getTotalBufferSize() > 0); -// -// if (fTotalTracingBufferSize == 0) { -// // Initialize buffer -// fTotalTracingBufferSize = status.getTotalBufferSize(); -// } else { -// assertTrue("Total buffer size changed! Should be " + fTotalTracingBufferSize + -// " but got " + status.getTotalBufferSize(), -// status.getTotalBufferSize() == fTotalTracingBufferSize); -// } -// -// assertTrue("Expected stopping reason " + reason + " but got " + status.getStopReason(), -// status.getStopReason() == reason); -// assertTrue("Expected stopping bp " + stoppingTracepoint + " but got " + status.getStoppingTracepoint(), -// status.getStoppingTracepoint() == stoppingTracepoint); -// } -// -// private void checkTraceStatus(boolean supported, boolean active, int frames) throws Throwable { -// checkTraceStatus(supported, active, frames, null, null); -// } - - // GDB 7.0 does not support fast tracepoints, but GDB 7.1 will - protected boolean fastTracepointsSupported() { return false; } - private class TracepointData { String sourceFile; int lineNumber; String condition; int passcount; boolean enabled; - String actions; + String commands; boolean isFastTp; - - public TracepointData(String file, int line, String cond, int pass, boolean isEnabled, String acts, boolean fast) { + + public TracepointData(String file, int line, String cond, int pass, boolean isEnabled, String cmds, boolean fast) { sourceFile = file; lineNumber = line; condition = cond; passcount = pass; enabled = isEnabled; - actions = acts; + commands = cmds; if (fastTracepointsSupported()) { isFastTp = fast; } else { @@ -574,10 +601,10 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { } } } - + private void checkTracepoints(TracepointData[] dataArray) throws Throwable { int numTracepoints = dataArray.length; - + // Fetch the tp list from the backend IBreakpointDMContext[] tracepoints = getBreakpoints(fBreakpointsDmc); assertTrue("expected " + numTracepoints + " breakpoint(s), received " @@ -585,7 +612,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { for (int i=0; i attributes = null; int index = 0; - + // First tracepoint (will be a slow tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); @@ -647,8 +674,8 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); - - // Second tracepoint (will be a fast tracepoint) + + // Second tracepoint (will be a slow tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -662,11 +689,11 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); - // Third tracepoint (will be a slow tracepoint) + // Third tracepoint (will be a fast tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); - attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_1); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_4); fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); waitForBreakpointEvent(); @@ -703,23 +730,23 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); - + ArrayList dataArray = new ArrayList(); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, "", false)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, "", true)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_1, NO_CONDITION, 0, true, "", false)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, "", true)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, "", false)); - + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, 0, true, NO_COMMANDS, true)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, NO_COMMANDS, true)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, NO_COMMANDS, false)); + checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); } - + /** * This test sets the different types of tracepoints and then deletes them */ @Test - public void testDeleteTracepoints() throws Throwable { - testCreateTracepoints(); + public void deleteTracepoints() throws Throwable { + createTracepoints(); // Delete all tracepoints for (IBreakpointDMContext tp : fTracepoints) { if (tp == null) break; @@ -736,9 +763,9 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { * This test sets the different types of tracepoints and then disables them */ @Test - public void testDisableTracepoints() throws Throwable { - testCreateTracepoints(); - + public void disableTracepoints() throws Throwable { + createTracepoints(); + Map delta = new HashMap(); delta.put(MIBreakpoints.IS_ENABLED, false); // Disable all tracepoints @@ -748,12 +775,12 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { } ArrayList dataArray = new ArrayList(); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, false, "", false)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, false, "", true)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_1, NO_CONDITION, 0, false, "", false)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, false, "", true)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, false, "", false)); - + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, false, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, false, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, 0, false, NO_COMMANDS, true)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, false, NO_COMMANDS, true)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, false, NO_COMMANDS, false)); + checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); } @@ -761,9 +788,9 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { * This test sets, disables the different types of tracepoints and then enables them */ @Test - public void testEnableTracepoints() throws Throwable { - testDisableTracepoints(); - + public void enableTracepoints() throws Throwable { + disableTracepoints(); + Map delta = new HashMap(); delta.put(MIBreakpoints.IS_ENABLED, true); // Enable all tracepoints @@ -773,11 +800,11 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { } ArrayList dataArray = new ArrayList(); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, "", false)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, "", true)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_1, NO_CONDITION, 0, true, "", false)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, "", true)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, "", false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, 0, true, NO_COMMANDS, true)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, NO_COMMANDS, true)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, NO_COMMANDS, false)); checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); } @@ -786,9 +813,9 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { * This test sets the different types of tracepoints and then sets their passcount */ @Test - public void testTracepointPasscount() throws Throwable { - testCreateTracepoints(); - + public void tracepointPasscount() throws Throwable { + createTracepoints(); + Map delta = new HashMap(); // Set passcount for all tracepoints for (int i=0; i dataArray = new ArrayList(); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, PASS_COUNTS[0], true, "", false)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, PASS_COUNTS[1], true, "", true)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_1, NO_CONDITION, PASS_COUNTS[2], true, "", false)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, PASS_COUNTS[3], true, "", true)); - dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, PASS_COUNTS[4], true, "", false)); - + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, PASS_COUNTS[0], true, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, PASS_COUNTS[1], true, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, PASS_COUNTS[2], true, NO_COMMANDS, true)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, PASS_COUNTS[3], true, NO_COMMANDS, true)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, PASS_COUNTS[4], true, NO_COMMANDS, false)); + checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); } /** - * This test sets a tracepoint and then gives it a condition + * This test sets the different types of tracepoints and then sets some conditions */ - //@Test - public void testTracepointCondition() throws Throwable { - // Use trace state variables and stuff - } - + @Test + public void tracepointCondition() throws Throwable { + createTracepoints(); + + Map delta = new HashMap(); + // Set conditions for all tracepoints + for (int i=0; i dataArray = new ArrayList(); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, CONDITIONS[0], 0, true, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, CONDITIONS[1], 0, true, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, CONDITIONS[2], 0, true, NO_COMMANDS, true)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, CONDITIONS[3], 0, true, NO_COMMANDS, true)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, CONDITIONS[4], 0, true, NO_COMMANDS, false)); + + checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); + + } + + /** + * This test sets the different types of tracepoints and then sets some actions + */ + @Test + public void tracepointActions() throws Throwable { + createTracepoints(); + + Map delta = new HashMap(); + // Set conditions for all tracepoints + for (int i=0; i dataArray = new ArrayList(); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, COLLECT_ACTIONS[0].toString(), false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, COLLECT_ACTIONS[1].toString(), false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, 0, true, COLLECT_ACTIONS[2].toString(), true)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, COLLECT_ACTIONS[3].toString(), true)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, COLLECT_ACTIONS[4].toString(), false)); + + checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); + + } + + /** + * This test creates a tracepoint that starts disabled + */ + @Test + public void createTracepointDisabled() throws Throwable { + Map attributes = null; + int index = 0; + + // First tracepoint will be a slow tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2); + attributes.put(MIBreakpoints.IS_ENABLED, false); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + // Second tracepoint will be a fast tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1); + attributes.put(MIBreakpoints.IS_ENABLED, false); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + ArrayList dataArray = new ArrayList(); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, false, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, false, NO_COMMANDS, true)); + + checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); + } + + /** + * This test creates a tracepoint that starts with a passcount + */ + @Test + public void createTracepointWithPasscount() throws Throwable { + Map attributes = null; + int index = 0; + + // First tracepoint will be a slow tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2); + attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[0]); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + // Second tracepoint will be a fast tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1); + attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[1]); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + ArrayList dataArray = new ArrayList(); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, PASS_COUNTS[0], true, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, PASS_COUNTS[1], true, NO_COMMANDS, true)); + + checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); + } + + /** + * This test creates a tracepoint that starts with a condition + */ + @Test + public void createTracepointWithCondition() throws Throwable { + Map attributes = null; + int index = 0; + + // First tracepoint will be a slow tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2); + attributes.put(MIBreakpoints.CONDITION, CONDITIONS[0]); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + // Second tracepoint will be a fast tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1); + attributes.put(MIBreakpoints.CONDITION, CONDITIONS[1]); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + ArrayList dataArray = new ArrayList(); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, CONDITIONS[0], 0, true, NO_COMMANDS, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, CONDITIONS[1], 0, true, NO_COMMANDS, true)); + + checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); + } + + /** + * This test creates tracepoints that start a command + */ + @Test + public void createTracepointWithCommand() throws Throwable { + Map attributes = null; + int index = 0; + + // First tracepoint will be a slow tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2); + attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[0].getName()); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + // Second tracepoint will be a fast tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1); + attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[1].getName()); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + ArrayList dataArray = new ArrayList(); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, COLLECT_ACTIONS[0].toString(), false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, COLLECT_ACTIONS[1].toString(), true)); + + checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); + } + + /** + * This test creates tracepoints that start with more than one command + */ + @Test + public void createTracepointWithMultipleCommands() throws Throwable { + Map attributes = null; + int index = 0; + + // First tracepoint will be a slow tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2); + String commandsNames1 = COLLECT_ACTIONS[0].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER + + COLLECT_ACTIONS[1].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER + + COLLECT_ACTIONS[2].getName(); + String commandsResult1 = COLLECT_ACTIONS[0].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER + + COLLECT_ACTIONS[1].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER + + COLLECT_ACTIONS[2].toString(); + attributes.put(MIBreakpoints.COMMANDS, commandsNames1); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + // Second tracepoint will be a fast tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1); + String commandsNames2 = COLLECT_ACTIONS[2].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER + + COLLECT_ACTIONS[2].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER + + COLLECT_ACTIONS[1].getName(); + String commandsResult2 = COLLECT_ACTIONS[2].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER + + COLLECT_ACTIONS[2].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER + + COLLECT_ACTIONS[1].toString(); + attributes.put(MIBreakpoints.COMMANDS, commandsNames2); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + ArrayList dataArray = new ArrayList(); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, commandsResult1, false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, commandsResult2, true)); + + checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); + } + + /** + * This test creates an enabled tracepoint that starts with commands, condition and passcount + */ + @Test + public void createTracepointEnabledWithCommandsConditionPasscount() throws Throwable { + Map attributes = null; + int index = 0; + + // First tracepoint will be a slow tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2); + attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[0].getName()); + attributes.put(MIBreakpoints.CONDITION, CONDITIONS[0]); + attributes.put(MIBreakpoints.IS_ENABLED, true); + attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[0]); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + // Second tracepoint will be a fast tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1); + attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[1].getName()); + attributes.put(MIBreakpoints.CONDITION, CONDITIONS[1]); + attributes.put(MIBreakpoints.IS_ENABLED, true); + attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[1]); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + ArrayList dataArray = new ArrayList(); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, CONDITIONS[0], PASS_COUNTS[0], true, COLLECT_ACTIONS[0].toString(), false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, CONDITIONS[1], PASS_COUNTS[1], true, COLLECT_ACTIONS[1].toString(), true)); + + checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); + } + + /** + * This test creates a disabled tracepoint that starts with commands, condition and passcount + */ + @Test + public void createTracepointDisabledWithCommandsConditionPasscount() throws Throwable { + Map attributes = null; + int index = 0; + + // First tracepoint will be a slow tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2); + attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[0].getName()); + attributes.put(MIBreakpoints.CONDITION, CONDITIONS[0]); + attributes.put(MIBreakpoints.IS_ENABLED, false); + attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[0]); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + // Second tracepoint will be a fast tracepoint + attributes = new HashMap(); + attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); + attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); + attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1); + attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[1].getName()); + attributes.put(MIBreakpoints.CONDITION, CONDITIONS[1]); + attributes.put(MIBreakpoints.IS_ENABLED, false); + attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[1]); + fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes); + + waitForBreakpointEvent(); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received " + + fBreakpointEventCount, fBreakpointEventCount == 1); + assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); + clearEventCounters(); + + ArrayList dataArray = new ArrayList(); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, CONDITIONS[0], PASS_COUNTS[0], false, COLLECT_ACTIONS[0].toString(), false)); + dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, CONDITIONS[1], PASS_COUNTS[1], false, COLLECT_ACTIONS[1].toString(), true)); + + checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()])); + } + + // /** + // * This test sets the different types of tracepoints and then sets some eval actions + // */ + // @Test + // public void testEvalActions() throws Throwable { + // final String ACTIONS1 = EVAL_ACTION_1.getName()+","+EVAL_ACTION_2.getName()+","+EVAL_ACTION_3.getName(); + // final String ACTIONS2 = EVAL_ACTION_1.getName()+","+EVAL_ACTION_3.getName(); + // final String ACTIONS3 = EVAL_ACTION_3.getName(); + // + // testCreateTracepoints(); + // testActions(new String[] {ACTIONS1, ACTIONS2, ACTIONS3, ""}); + // } + // + // /** + // * This test sets the different types of tracepoints and then sets some while-stepping actions + // */ + // //@Test + // public void testSteppingActions() throws Throwable { + //// final String ACTIONS1 = STEPPING_ACTION_1.getName()+","+STEPPING_ACTION_2.getName()+","+STEPPING_ACTION_3.getName(); + //// final String ACTIONS2 = STEPPING_ACTION_1.getName()+","+STEPPING_ACTION_3.getName(); + //// final String ACTIONS3 = STEPPING_ACTION_3.getName(); + //// + //// testCreateTracepoints(); + //// testActions(new String[] {ACTIONS1, ACTIONS2, ACTIONS3, ""}); + // } + // + // /** + // * This test sets the different types of tracepoints and then sets a mix of different + // * tracepoint actions + // */ + // //@Test + // public void testMixedActions() throws Throwable { + //// final String ACTIONS1 = COLLECT_ACTION_1.getName() + "," + + //// EVAL_ACTION_2.getName() + "," + + //// STEPPING_ACTION_3.getName(); + //// final String ACTIONS2 = STEPPING_ACTION_1.getName() + "," + + //// COLLECT_ACTION_2.getName() + "," + + //// EVAL_ACTION_1.getName() + "," + + //// COLLECT_ACTION_3.getName() + "," + + //// EVAL_ACTION_2.getName() + "," + + //// EVAL_ACTION_3.getName(); + //// final String ACTIONS3 = EVAL_ACTION_3.getName() + "," + + //// COLLECT_ACTION_1.getName() + "," + + //// EVAL_ACTION_2.getName() + "," + + //// STEPPING_ACTION_3.getName(); + //// + //// testCreateTracepoints(); + //// testActions(new String[] {ACTIONS1, ACTIONS2, ACTIONS3, ""}); + // } + // + // /** + // * This test sets the different types of tracepoints and then sets some default collect actions + // */ + // //@Test + // public void testDefaultCollectAction() throws Throwable { + // testCreateTracepoints(); + // } + // + // // ********************************************************************* + // // Below are the tests for the control of tracing + // // ********************************************************************* + // + // /** + // * This test sets different tracepoints in the program: + // * - using a filename and line number + // * - using a method name + // * - using a method address + // * + // * and confirms they are installed when tracing starts + // */ + // @Test + // public void testCreateAndRunTracepoints() throws Throwable { + // testCreateTracepoints(); + // startTracing(); + // SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER)); + // checkTraceStatus(true, true, TOTAL_FRAMES_TO_BE_COLLECTED); + // stopTracing(); + // checkTraceStatus(true, false, TOTAL_FRAMES_TO_BE_COLLECTED); + // } + // + // /** + // * This test sets the different types of tracepoints and then deletes them + // * and confirms they are not installed when tracing starts + // */ + // @Test + // public void testDeleteAndRunTracepoints() throws Throwable { + // testDeleteTracepoints(); + // startTracing("No tracepoints available to download"); + // SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER)); + // checkTraceStatus(true, false, 0); + // } + // + // /** + // * This test sets the different types of tracepoints and then disables them + // * and confirms they are not hit when tracing starts + // */ + // @Test + // public void testDisableAndRunTracepoints() throws Throwable { + // testDisableTracepoints(); + // startTracing("None of the downloadable tracepoints enabled"); + // SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER)); + // checkTraceStatus(true, false, 0); + // } + // + // /** + // * This test sets, disables the different types of tracepoints and then enables them + // * and confirms they are hit when tracing starts + // */ + // @Test + // public void testEnableAndRunTracepoints() throws Throwable { + // testEnableTracepoints(); + // startTracing(); + // SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER)); + // checkTraceStatus(true, true, TOTAL_FRAMES_TO_BE_COLLECTED); + // stopTracing(); + // checkTraceStatus(true, false, TOTAL_FRAMES_TO_BE_COLLECTED); + // } + // + // /** + // * This test sets the different types of tracepoints and then sets their passcount + // * and confirms the passcount is respected + // */ + // @Test + // public void testTracepointPasscountAndRun1() throws Throwable { + // testTracepointPasscount(); + // startTracing(); + // SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER)); + // + // checkTraceStatus(true, false, + // 1 + 1 + 10 + 1 + PASS_COUNTS[4], + // STOP_REASON_ENUM.PASSCOUNT, 6); + // } + // + // /** + // * This test sets the passcount of the a tracepoint that is hit before some + // * other tracepoints are hit, to confirm tracing really stops. + // */ + // @Test + // public void testTracepointPasscountAndRun2() throws Throwable { + // testTracepointPasscount(); + // + // // Set the passcount of the forth tp to make it stop the tracing + // Map delta = new HashMap(); + // delta.put(MIBreakpoints.IGNORE_COUNT, 1); + // updateBreakpoint(fTracepoints[3], delta); + // + // startTracing(); + // SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER)); + // + // checkTraceStatus(true, false, + // 1 + 1 + 10 + 1, + // STOP_REASON_ENUM.PASSCOUNT, 5); + // } + // + // /** + // * This test sets a tracepoint and then gives it a condition + // * and confirms the condition is respected + // */ + // //@Test + // public void testTracepointConditionAndRun() throws Throwable { + // // Use trace state variables and stuff + // } + // + // /** + // * This test sets the different types of tracepoints and then sets some collect actions + // * and confirms the proper information is collected + // */ + // //@Test + // public void testCollectActionsAndRun() throws Throwable { + // testCreateTracepoints(); + // } + // + // /** + // * This test sets the different types of tracepoints and then sets some eval actions + // * and confirms the trace variables are properly updated + // */ + // //@Test + // public void testEvalActionsAndRun() throws Throwable { + // testCreateTracepoints(); + // } + // + // /** + // * This test sets the different types of tracepoints and then sets some while-stepping actions + // * and confirms the proper information is collected + // */ + // //@Test + // public void testSteppingActionsAndRun() throws Throwable { + // testCreateTracepoints(); + // } + // + // /** + // * This test sets the different types of tracepoints and then sets a mix of different + // * tracepoint actions and confirms the proper information is collected + // */ + // //@Test + // public void testMixedActionsAndRun() throws Throwable { + // testCreateTracepoints(); + // } + // + // /** + // * This test sets the different types of tracepoints and then sets some default collect actions + // * and confirms the proper information is collected + // */ + // //@Test + // public void testDefaultCollectActionAndRun() throws Throwable { + // testCreateTracepoints(); + // } + // -// private void testActions(String[] actions) throws Throwable { -// Map delta = new HashMap(); -// ArrayList dataArray = new ArrayList(); -// -// for (int i=0; i delta = new HashMap(); -// delta.put(MIBreakpoints.IGNORE_COUNT, 1); -// updateBreakpoint(fTracepoints[3], delta); -// -// startTracing(); -// SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER)); -// -// checkTraceStatus(true, false, -// 1 + 1 + 10 + 1, -// STOP_REASON_ENUM.PASSCOUNT, 5); -// } -// -// /** -// * This test sets a tracepoint and then gives it a condition -// * and confirms the condition is respected -// */ -// //@Test -// public void testTracepointConditionAndRun() throws Throwable { -// // Use trace state variables and stuff -// } -// -// /** -// * This test sets the different types of tracepoints and then sets some collect actions -// * and confirms the proper information is collected -// */ -// //@Test -// public void testCollectActionsAndRun() throws Throwable { -// testCreateTracepoints(); -// } -// -// /** -// * This test sets the different types of tracepoints and then sets some eval actions -// * and confirms the trace variables are properly updated -// */ -// //@Test -// public void testEvalActionsAndRun() throws Throwable { -// testCreateTracepoints(); -// } -// -// /** -// * This test sets the different types of tracepoints and then sets some while-stepping actions -// * and confirms the proper information is collected -// */ -// //@Test -// public void testSteppingActionsAndRun() throws Throwable { -// testCreateTracepoints(); -// } -// -// /** -// * This test sets the different types of tracepoints and then sets a mix of different -// * tracepoint actions and confirms the proper information is collected -// */ -// //@Test -// public void testMixedActionsAndRun() throws Throwable { -// testCreateTracepoints(); -// } -// -// /** -// * This test sets the different types of tracepoints and then sets some default collect actions -// * and confirms the proper information is collected -// */ -// //@Test -// public void testDefaultCollectActionAndRun() throws Throwable { -// testCreateTracepoints(); -// } -// - } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBRemoteTracepointsTest_7_2.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBRemoteTracepointsTest_7_2.java index 4149ed75675..e50615fe68c 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBRemoteTracepointsTest_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBRemoteTracepointsTest_7_2.java @@ -23,4 +23,7 @@ public class GDBRemoteTracepointsTest_7_2 extends GDBRemoteTracepointsTest_7_1 { public static void beforeClassMethod_7_2() { setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2); } + + @Override + protected boolean fastTracepointsSupported() { return true; } }