Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 346320 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java (+74 lines)
Lines 30-38 Link Here
30
import org.eclipse.swt.events.ModifyListener;
30
import org.eclipse.swt.events.ModifyListener;
31
import org.eclipse.swt.events.SelectionAdapter;
31
import org.eclipse.swt.events.SelectionAdapter;
32
import org.eclipse.swt.events.SelectionEvent;
32
import org.eclipse.swt.events.SelectionEvent;
33
import org.eclipse.swt.events.SelectionListener;
33
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.widgets.Button;
36
import org.eclipse.swt.widgets.Button;
37
import org.eclipse.swt.widgets.Combo;
36
import org.eclipse.swt.widgets.Composite;
38
import org.eclipse.swt.widgets.Composite;
37
import org.eclipse.swt.widgets.FileDialog;
39
import org.eclipse.swt.widgets.FileDialog;
38
import org.eclipse.swt.widgets.Label;
40
import org.eclipse.swt.widgets.Label;
Lines 53-58 Link Here
53
	protected Button fReverseCheckBox;
55
	protected Button fReverseCheckBox;
54
	protected Button fUpdateThreadlistOnSuspend;
56
	protected Button fUpdateThreadlistOnSuspend;
55
	protected Button fDebugOnFork;
57
	protected Button fDebugOnFork;
58
	
59
	/**
60
	 * A combo box to let the user choose if fast tracepoints should be used or not.
61
	 */
62
	protected Combo fTracepointModeCombo;
63
	protected static final String TP_FAST_ONLY = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_fast"); //$NON-NLS-1$
64
	protected static final String TP_SLOW_ONLY = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_slow"); //$NON-NLS-1$
65
	protected static final String TP_AUTOMATIC = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_auto"); //$NON-NLS-1$
56
66
57
	private IMILaunchConfigurationComponent fSolibBlock;
67
	private IMILaunchConfigurationComponent fSolibBlock;
58
	private boolean fIsInitializing = false;
68
	private boolean fIsInitializing = false;
Lines 82-87 Link Here
82
				IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT);
92
				IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT);
83
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_DEBUG_ON_FORK,
93
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_DEBUG_ON_FORK,
84
				IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_ON_FORK_DEFAULT);
94
				IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_ON_FORK_DEFAULT);
95
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE,
96
				IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT);
85
97
86
		if (fSolibBlock != null)
98
		if (fSolibBlock != null)
87
			fSolibBlock.setDefaults(configuration);
99
			fSolibBlock.setDefaults(configuration);
Lines 142-150 Link Here
142
		fUpdateThreadlistOnSuspend.setSelection(updateThreadsOnSuspend);
154
		fUpdateThreadlistOnSuspend.setSelection(updateThreadsOnSuspend);
143
		fDebugOnFork.setSelection(debugOnFork);
155
		fDebugOnFork.setSelection(debugOnFork);
144
156
157
		updateTracepointModeFromConfig(configuration);
158
		
145
		setInitializing(false);
159
		setInitializing(false);
146
	}
160
	}
161
	
162
	protected void updateTracepointModeFromConfig(ILaunchConfiguration config) {
163
		if (fTracepointModeCombo != null) {
164
			String tracepointMode = getStringAttr(config, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE,
165
					IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT);
147
166
167
			if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_SLOW_ONLY)) {
168
				fTracepointModeCombo.setText(TP_SLOW_ONLY);
169
			} else if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_ONLY)) {
170
				fTracepointModeCombo.setText(TP_FAST_ONLY);
171
			} else if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW)) {
172
				fTracepointModeCombo.setText(TP_AUTOMATIC);
173
			} else {
174
				assert false : "Unknown Tracepoint Mode: " + tracepointMode; //$NON-NLS-1$
175
				fTracepointModeCombo.setText(TP_SLOW_ONLY);
176
			}
177
		}
178
	}
179
180
	protected String getSelectedTracepointMode() {
181
		int selectedIndex = fTracepointModeCombo.getSelectionIndex();
182
		if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_SLOW_ONLY)) {
183
			return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_SLOW_ONLY;
184
		} else if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_FAST_ONLY)) {
185
			return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_ONLY;
186
		} else if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_AUTOMATIC)) {
187
			return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW;
188
		} else {
189
			assert false : "Unknown Tracepoint mode: " + fTracepointModeCombo.getItem(selectedIndex); //$NON-NLS-1$
190
			return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT;
191
		}
192
	}
193
	
148
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
194
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
149
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME,
195
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME,
150
				fGDBCommandText.getText().trim());
196
				fGDBCommandText.getText().trim());
Lines 158-163 Link Here
158
                fUpdateThreadlistOnSuspend.getSelection());
204
                fUpdateThreadlistOnSuspend.getSelection());
159
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_DEBUG_ON_FORK,
205
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_DEBUG_ON_FORK,
160
				fDebugOnFork.getSelection());
206
				fDebugOnFork.getSelection());
207
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE,
208
				getSelectedTracepointMode());
209
161
		if (fSolibBlock != null)
210
		if (fSolibBlock != null)
162
			fSolibBlock.performApply(configuration);
211
			fSolibBlock.performApply(configuration);
163
	}
212
	}
Lines 307-312 Link Here
307
		PlatformUI.getWorkbench().getHelpSystem().setHelp(fUpdateThreadlistOnSuspend, GdbUIPlugin.PLUGIN_ID + ".update_threadlist_button_context"); //$NON-NLS-1$
356
		PlatformUI.getWorkbench().getHelpSystem().setHelp(fUpdateThreadlistOnSuspend, GdbUIPlugin.PLUGIN_ID + ".update_threadlist_button_context"); //$NON-NLS-1$
308
357
309
		fDebugOnFork = addCheckbox(subComp, LaunchUIMessages.getString("GDBDebuggerPage.Automatically_debug_forked_processes")); //$NON-NLS-1$
358
		fDebugOnFork = addCheckbox(subComp, LaunchUIMessages.getString("GDBDebuggerPage.Automatically_debug_forked_processes")); //$NON-NLS-1$
359
		
360
		createTracepointModeCombo(subComp);
361
	}
362
	
363
	protected void createTracepointModeCombo(Composite parent) {
364
		// Add a combo to choose the type of tracepoint mode to use
365
		Label label = ControlFactory.createLabel(parent, LaunchUIMessages.getString("CMainTab.Post_mortem_file_type")); //$NON-NLS-1$
366
		label.setLayoutData(new GridData());
367
368
		fTracepointModeCombo = new Combo(parent, SWT.READ_ONLY | SWT.DROP_DOWN);
369
		fTracepointModeCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
370
		fTracepointModeCombo.add(TP_SLOW_ONLY);
371
		fTracepointModeCombo.add(TP_FAST_ONLY);
372
		fTracepointModeCombo.add(TP_AUTOMATIC);
373
		
374
		fTracepointModeCombo.addSelectionListener(new SelectionListener() {
375
			public void widgetSelected(SelectionEvent e) {
376
				updateLaunchConfigurationDialog();
377
			}
378
379
			public void widgetDefaultSelected(SelectionEvent e) {
380
			}
381
		});
382
		fTracepointModeCombo.select(0);
383
310
	}
384
	}
311
385
312
	public void createSolibTab(TabFolder tabFolder) {
386
	public void createSolibTab(TabFolder tabFolder) {
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties (+3 lines)
Lines 25-30 Link Here
25
GDBDebuggerPage.reverse_Debugging=Enable Reverse Debugging at startup (Note: Requires Reverse GDB)
25
GDBDebuggerPage.reverse_Debugging=Enable Reverse Debugging at startup (Note: Requires Reverse GDB)
26
GDBDebuggerPage.update_thread_list_on_suspend=Force thread list update on suspend
26
GDBDebuggerPage.update_thread_list_on_suspend=Force thread list update on suspend
27
GDBDebuggerPage.Automatically_debug_forked_processes=Automatically debug forked processes (Note: Requires Multi Process GDB)
27
GDBDebuggerPage.Automatically_debug_forked_processes=Automatically debug forked processes (Note: Requires Multi Process GDB)
28
GDBDebuggerPage.tracepoint_mode_fast=Fast
29
GDBDebuggerPage.tracepoint_mode_slow=Slow
30
GDBDebuggerPage.tracepoint_mode_auto=Automatic
28
StandardGDBDebuggerPage.0=Debugger executable must be specified.
31
StandardGDBDebuggerPage.0=Debugger executable must be specified.
29
StandardGDBDebuggerPage.1=GDB Debugger Options
32
StandardGDBDebuggerPage.1=GDB Debugger Options
30
StandardGDBDebuggerPage.2=Main
33
StandardGDBDebuggerPage.2=Main
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsList.java (-2 / +4 lines)
Lines 132-138 Link Here
132
		TableItem[] currentItems = table.getItems();
132
		TableItem[] currentItems = table.getItems();
133
		for (int i = 0; i < currentItems.length; i++) {
133
		for (int i = 0; i < currentItems.length; i++) {
134
			if (i > 0) {
134
			if (i > 0) {
135
				result.append(',');
135
				// Keep a delimiter between the different action strings
136
				// so we can separate them again.
137
				result.append(TracepointActionManager.TRACEPOINT_ACTION_DELIMITER);
136
			}
138
			}
137
			result.append(((ITracepointAction) currentItems[i].getData()).getName());
139
			result.append(((ITracepointAction) currentItems[i].getData()).getName());
138
		}
140
		}
Lines 179-185 Link Here
179
	public void setNames(String actionNames) {
181
	public void setNames(String actionNames) {
180
182
181
		table.removeAll();
183
		table.removeAll();
182
		String[] names = actionNames.split(","); //$NON-NLS-1$
184
		String[] names = actionNames.split(TracepointActionManager.TRACEPOINT_ACTION_DELIMITER);
183
185
184
		for (String actionName : names) {
186
		for (String actionName : names) {
185
			ITracepointAction action = TracepointActionManager.getInstance().findAction(actionName);
187
			ITracepointAction action = TracepointActionManager.getInstance().findAction(actionName);
(-)src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java (+28 lines)
Lines 105-110 Link Here
105
	 */
105
	 */
106
	public static final String ATTR_DEBUGGER_DEBUG_ON_FORK = GdbPlugin.PLUGIN_ID + ".DEBUG_ON_FORK"; //$NON-NLS-1$
106
	public static final String ATTR_DEBUGGER_DEBUG_ON_FORK = GdbPlugin.PLUGIN_ID + ".DEBUG_ON_FORK"; //$NON-NLS-1$
107
107
108
	/**
109
	 * Launch configuration attribute key. The value is a String specifying the type of Tracepoint mode
110
	 * that should be used for this launch.
111
	 */
112
	public static final String ATTR_DEBUGGER_TRACEPOINT_MODE = GdbPlugin.PLUGIN_ID + ".TRACEPOINT_MODE"; //$NON-NLS-1$
108
	
113
	
109
	/**
114
	/**
110
	 * Launch configuration attribute value. The key is ATTR_DEBUG_NAME.
115
	 * Launch configuration attribute value. The key is ATTR_DEBUG_NAME.
Lines 174-179 Link Here
174
	 * @since 4.0
179
	 * @since 4.0
175
	 */
180
	 */
176
	public static final boolean DEBUGGER_DEBUG_ON_FORK_DEFAULT = false;
181
	public static final boolean DEBUGGER_DEBUG_ON_FORK_DEFAULT = false;
182
183
	/**  
184
	 * Possible attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE.
185
	 * Indicates that only slow tracepoints should be used.
186
	 */                                                 
187
	public static final String DEBUGGER_TRACEPOINT_SLOW_ONLY = "TP_SLOW_ONLY"; //$NON-NLS-1$
188
189
	/**  
190
	 * Possible attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE.
191
	 * Indicates that only fast tracepoints should be used.
192
	 */                                                 
193
	public static final String DEBUGGER_TRACEPOINT_FAST_ONLY = "TP_FAST_ONLY"; //$NON-NLS-1$
194
195
	/**  
196
	 * Possible attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE.
197
	 * Indicates that slow tracepoints should be used whenever a fast tracepoint
198
	 * cannot be inserted.
199
	 */                                                 
200
	public static final String DEBUGGER_TRACEPOINT_FAST_THEN_SLOW = "TP_FAST_THEN_SLOW"; //$NON-NLS-1$
177
201
202
	/**  
203
	 * Default attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE.
204
	 */
205
	public static final String DEBUGGER_TRACEPOINT_MODE_DEFAULT = DEBUGGER_TRACEPOINT_SLOW_ONLY;
178
206
179
}
207
}
(-)src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/TracepointActionManager.java (+4 lines)
Lines 39-44 Link Here
39
	private static final String TRACEPOINT_ACTION_DATA = "TracepointActionManager.actionData"; //$NON-NLS-1$
39
	private static final String TRACEPOINT_ACTION_DATA = "TracepointActionManager.actionData"; //$NON-NLS-1$
40
    private static final TracepointActionManager fTracepointActionManager = new TracepointActionManager();
40
    private static final TracepointActionManager fTracepointActionManager = new TracepointActionManager();
41
    
41
    
42
    // We need a delimiter that the user won't type directly.
43
    // Bug 346215
44
    public static final String TRACEPOINT_ACTION_DELIMITER = "%_#"; //$NON-NLS-1$
45
    
42
	private ArrayList<ITracepointAction> tracepointActions = null;
46
	private ArrayList<ITracepointAction> tracepointActions = null;
43
47
44
	private TracepointActionManager() {
48
	private TracepointActionManager() {
(-)src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_0.java (-1 / +1 lines)
Lines 325-331 Link Here
325
	}
325
	}
326
	
326
	
327
	private ITracepointAction[] generateGdbCommands(String actionStr) {
327
	private ITracepointAction[] generateGdbCommands(String actionStr) {
328
		String[] actionNames = actionStr.split(","); //$NON-NLS-1$
328
		String[] actionNames = actionStr.split(TracepointActionManager.TRACEPOINT_ACTION_DELIMITER);
329
		ITracepointAction[] actions = new ITracepointAction[actionNames.length];
329
		ITracepointAction[] actions = new ITracepointAction[actionNames.length];
330
330
331
		TracepointActionManager actionManager = TracepointActionManager.getInstance();
331
		TracepointActionManager actionManager = TracepointActionManager.getInstance();
(-)src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java (+210 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Ericsson and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Ericsson - Initial API and implementation 
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.gdb.service;
12
13
import java.util.HashMap;
14
import java.util.Hashtable;
15
import java.util.Map;
16
17
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
18
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
19
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
20
import org.eclipse.cdt.dsf.datamodel.IDMContext;
21
import org.eclipse.cdt.dsf.debug.service.IBreakpoints;
22
import org.eclipse.cdt.dsf.debug.service.IBreakpointsExtension;
23
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
24
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
25
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
26
import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData;
27
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
28
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
29
import org.eclipse.cdt.dsf.service.DsfSession;
30
import org.eclipse.core.runtime.CoreException;
31
import org.eclipse.core.runtime.IStatus;
32
import org.eclipse.core.runtime.Status;
33
import org.eclipse.debug.core.ILaunch;
34
35
/**
36
 * Breakpoint service for GDB 7.2.
37
 * It support MI for tracepoints as well as fast vs slow tracepoints.
38
 *
39
 * @since 4.0
40
 */
41
public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0
42
{
43
	private IMICommandControl fConnection;
44
45
	private enum TracepointMode { FAST_THEN_SLOW, FAST_ONLY, SLOW_ONLY };
46
	
47
	private TracepointMode fTracepointMode = TracepointMode.SLOW_ONLY;
48
	
49
	public GDBBreakpoints_7_2(DsfSession session) {
50
		super(session);
51
	}
52
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.cdt.dsf.service.AbstractDsfService#initialize(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
55
	 */
56
	@Override
57
	public void initialize(final RequestMonitor rm) {
58
		super.initialize(new RequestMonitor(ImmediateExecutor.getInstance(), rm) {
59
			@Override
60
			protected void handleSuccess() {
61
				doInitialize(rm);
62
			}
63
		});
64
	}
65
66
	private void doInitialize(final RequestMonitor rm) {
67
    	// Get the services references
68
		fConnection = getServicesTracker().getService(IMICommandControl.class);
69
70
		setTracepointMode();
71
		
72
		// Register this service
73
		register(new String[] { IBreakpoints.class.getName(),
74
		                        IBreakpointsExtension.class.getName(),
75
								MIBreakpoints.class.getName(),
76
								GDBBreakpoints_7_0.class.getName(),
77
								GDBBreakpoints_7_2.class.getName() },
78
				new Hashtable<String, String>());
79
80
		rm.done();
81
	}
82
83
	@Override
84
	public void shutdown(RequestMonitor requestMonitor) {
85
        unregister();
86
		super.shutdown(requestMonitor);
87
	}
88
89
	private void setTracepointMode() {
90
		ILaunch launch = (ILaunch)getSession().getModelAdapter(ILaunch.class);
91
		String tpMode = IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT;
92
		try {
93
			tpMode = launch.getLaunchConfiguration().getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE,
94
					IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT);
95
		} catch (CoreException e) {
96
		}
97
		
98
		if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_ONLY)) {
99
			fTracepointMode = TracepointMode.FAST_ONLY;
100
		} else if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_SLOW_ONLY)) {
101
			fTracepointMode = TracepointMode.SLOW_ONLY;
102
		} else if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW)) {
103
			fTracepointMode = TracepointMode.FAST_THEN_SLOW;
104
		} else {
105
			assert false : "Invalid tracepoint mode: " + tpMode; //$NON-NLS-1$
106
			fTracepointMode = TracepointMode.SLOW_ONLY;			
107
		}
108
	}
109
	
110
	protected void sendTracepointCommand(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, boolean isFastTracepoint, final DataRequestMonitor<IBreakpointDMContext> drm) {
111
		// Select the context breakpoints map
112
		final Map<Integer, MIBreakpointDMData> contextBreakpoints = getBreakpointMap(context);
113
		if (contextBreakpoints == null) {
114
       		drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
115
       		drm.done();
116
			return;
117
		}
118
119
		// Extract the relevant parameters (providing default values to avoid potential NPEs)
120
		final String location = formatLocation(attributes);
121
		if (location.equals(NULL_STRING)) {
122
       		drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
123
       		drm.done();
124
			return;
125
		}
126
127
		final Boolean enabled        = (Boolean) getProperty(attributes, MIBreakpoints.IS_ENABLED,        true);
128
		final String  condition      = (String)  getProperty(attributes, MIBreakpoints.CONDITION,         NULL_STRING);
129
130
		fConnection.queueCommand(
131
				fConnection.getCommandFactory().createMIBreakInsert(context, false, isFastTracepoint, condition, 0, location, 0, !enabled, true),
132
				new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), drm) {
133
					@Override
134
					protected void handleSuccess() {
135
						// With MI, an invalid location won't generate an error
136
						if (getData().getMIBreakpoints().length == 0) {
137
							drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, BREAKPOINT_INSERTION_FAILURE, null));
138
							drm.done();
139
							return;
140
						}
141
142
						// Create a breakpoint object and store it in the map
143
						final MIBreakpointDMData newBreakpoint = new MIBreakpointDMData(getData().getMIBreakpoints()[0]);
144
						int reference = newBreakpoint.getNumber();
145
						if (reference == -1) {
146
							drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, BREAKPOINT_INSERTION_FAILURE, null));
147
							drm.done();
148
							return;
149
						}
150
						contextBreakpoints.put(reference, newBreakpoint);
151
152
						// Format the return value
153
						MIBreakpointDMContext dmc = new MIBreakpointDMContext(GDBBreakpoints_7_2.this, new IDMContext[] { context }, reference);
154
						drm.setData(dmc);
155
156
						// Flag the event
157
						getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties());
158
						
159
						// Tracepoints are created with no passcount (passcount are not 
160
						// the same thing as ignore-count, which is not supported by
161
						// tracepoints).  We have to set the passcount manually now.
162
						// Same for commands.
163
						Map<String,Object> delta = new HashMap<String,Object>();
164
						delta.put(MIBreakpoints.PASS_COUNT, getProperty(attributes, MIBreakpoints.PASS_COUNT, 0));
165
						delta.put(MIBreakpoints.COMMANDS, getProperty(attributes, MIBreakpoints.COMMANDS, "")); //$NON-NLS-1$
166
						modifyBreakpoint(dmc, delta, drm, false);
167
					}
168
169
					@Override
170
					protected void handleError() {
171
						drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, BREAKPOINT_INSERTION_FAILURE, null));
172
						drm.done();
173
					}
174
				});
175
	}
176
	
177
	/**
178
	 * Add a tracepoint using MI.  We have three settings:
179
	 *   1- set only a fast tracepoint but if it fails, set a slow tracepoint
180
	 *   2- only set a fast tracepoint even if it fails
181
	 *   3- only set a slow tracepoint even if a fast tracepoint could have been used
182
	 */
183
	@Override
184
	protected void addTracepoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm) {
185
		// Unless we should only set slow tracepoints, we try to set a fast tracepoint.
186
		boolean isFastTracepoint = fTracepointMode != TracepointMode.SLOW_ONLY;
187
188
		sendTracepointCommand(context, attributes, isFastTracepoint, new DataRequestMonitor<IBreakpointDMContext>(ImmediateExecutor.getInstance(), drm) {
189
			@Override
190
			protected void handleSuccess() {
191
				// Tracepoint was set successfully.
192
				drm.setData(getData());
193
				drm.done();
194
			}
195
			@Override
196
			protected void handleError() {
197
				// Tracepoint failed to be set.
198
				if (fTracepointMode == TracepointMode.FAST_THEN_SLOW) {
199
					// In this case, we failed to set a fast tracepoint, but we should try to set a slow one.
200
					sendTracepointCommand(context, attributes, false, drm);
201
				} else {
202
					// We either failed to set a fast tracepoint and we should not try to set a slow one,
203
					// or we failed to set a slow one.  Either way, we are done.
204
					drm.setStatus(getStatus());
205
					drm.done();
206
				}
207
			}
208
		});
209
	}
210
}
(-)src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java (-2 / +7 lines)
Lines 98-103 Link Here
98
98
99
	@Override
99
	@Override
100
	protected IBreakpoints createBreakpointService(DsfSession session) {
100
	protected IBreakpoints createBreakpointService(DsfSession session) {
101
		// This service is available for GDB 7.2 but there is a pre-release of GDB that
102
		// supports the same features and has version of 6.8.50.20090414
103
		if (GDB_7_2_VERSION.compareTo(fVersion) <= 0 || "6.8.50.20090414".equals(fVersion)) { //$NON-NLS-1$
104
			return new GDBBreakpoints_7_2(session);
105
		}
101
		if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) {
106
		if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) {
102
			return new GDBBreakpoints_7_0(session);
107
			return new GDBBreakpoints_7_0(session);
103
		}
108
		}
Lines 184-191 Link Here
184
	
189
	
185
	/** @since 3.0 */
190
	/** @since 3.0 */
186
	protected IGDBTraceControl createTraceControlService(DsfSession session, ILaunchConfiguration config) {
191
	protected IGDBTraceControl createTraceControlService(DsfSession session, ILaunchConfiguration config) {
187
		// This service is available for GDB 7.2. But until that GDB is itself available
192
		// This service is available for GDB 7.2 but there is a pre-release of GDB that
188
		// there is a pre-release that has a version of 6.8.50.20090414
193
		// supports the same features and has version of 6.8.50.20090414
189
		if (GDB_7_2_VERSION.compareTo(fVersion) <= 0 || "6.8.50.20090414".equals(fVersion)) { //$NON-NLS-1$
194
		if (GDB_7_2_VERSION.compareTo(fVersion) <= 0 || "6.8.50.20090414".equals(fVersion)) { //$NON-NLS-1$
190
			return new GDBTraceControl_7_2(session, config);
195
			return new GDBTraceControl_7_2(session, config);
191
		}
196
		}
(-)src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java (+22 lines)
Lines 17-22 Link Here
17
17
18
import java.util.StringTokenizer;
18
import java.util.StringTokenizer;
19
19
20
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.TracepointActionManager;
21
20
/**
22
/**
21
 * Contain info about the GDB/MI breakpoint.
23
 * Contain info about the GDB/MI breakpoint.
22
 * 
24
 * 
Lines 498-504 Link Here
498
            } else if (var.equals("pending")) { //$NON-NLS-1$
500
            } else if (var.equals("pending")) { //$NON-NLS-1$
499
            	// Only supported starting with GDB 6.8
501
            	// Only supported starting with GDB 6.8
500
                pending = true;
502
                pending = true;
503
            } else if (var.equals("script")) { //$NON-NLS-1$
504
            	if (value instanceof MITuple) {
505
            		parseCommands((MITuple)value);
506
            	}
507
            }
508
        }
509
    }
510
    
511
    void parseCommands(MITuple tuple) {
512
        MIValue[] values = tuple.getMIValues();
513
        StringBuffer cmds = new StringBuffer();
514
        for (int i = 0; i < values.length; i++) {
515
        	MIValue value = values[i];
516
            if (value != null && value instanceof MIConst) {
517
            	if (i > 0) {
518
            		// Insert a delimiter
519
            		cmds.append(TracepointActionManager.TRACEPOINT_ACTION_DELIMITER);
520
            	}
521
                cmds.append(((MIConst)value).getCString());
501
            }
522
            }
502
        }
523
        }
524
        setCommands(cmds.toString());
503
    }
525
    }
504
}
526
}
(-)data/launch/src/TracepointTestApp.cc (-7 / +64 lines)
Lines 1-4 Link Here
1
#ifdef __MINGW32__
2
 #include <process.h>	// MinGW has no POSIX support; use MSVC runtime
3
#else
4
 #include <pthread.h>
5
#endif
1
#include <stdio.h>
6
#include <stdio.h>
7
#include <stdlib.h>
8
#include "Sleep.h"
9
#define NUM_THREADS	5
2
10
3
int gIntVar = 543;
11
int gIntVar = 543;
4
double gDoubleVar = 543.543;
12
double gDoubleVar = 543.543;
Lines 52-59 Link Here
52
	Z z;	
60
	Z z;	
53
};
61
};
54
62
55
void testTracepoints() {	
63
#ifdef __MINGW32__
56
    printf("Running TracepointTest App\n");
64
typedef unsigned int TID;
65
#else
66
typedef pthread_t TID;
67
#endif
68
69
70
#ifdef __MINGW32__
71
unsigned int __stdcall testTracepoints(void *threadid)
72
#else
73
void *testTracepoints(void *threadid)
74
#endif
75
{
76
    int tid = (int)threadid;
77
    printf("Hello World! It's me, thread #%d!\n", tid);
57
78
58
    int lIntVar = 12345;
79
    int lIntVar = 12345;
59
    double lDoubleVar = 12345.12345;
80
    double lDoubleVar = 12345.12345;
Lines 81-96 Link Here
81
        counter++;
102
        counter++;
82
    }
103
    }
83
104
84
	counter = 185;
105
    printf("counter is now #%d!\n", counter);
85
106
86
	// Large loop
107
	// Large loop
87
    for (counter=0; counter<10000;) {
108
    for (; counter<10000;) {
88
        counter++;
109
        counter++;
89
    }
110
    }
111
    
112
    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
113
    
114
#ifdef __MINGW32__
115
   return 0;
116
#else
117
   pthread_exit(NULL);
118
#endif
90
}
119
}
91
120
92
int main() {
121
int main() 
93
	testTracepoints();    
122
{
123
	TID threads[NUM_THREADS];
124
	int t;
125
	for(t=0; t < NUM_THREADS; t++)
126
	{
127
		printf("In main: creating thread %d\n", t);
128
#ifdef __MINGW32__
129
		{
130
			uintptr_t rc = _beginthreadex(NULL, 0, testTracepoints, (void*)t, 0, &threads[t]);
131
	    	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   
132
		    if (rc == 0)
133
		    {
134
				printf("ERROR; _beginthreadex() failed. errno = %d\n", errno);
135
				exit(-1);
136
		    }
137
		}  
138
#else
139
		{
140
	        int rc = pthread_create(&threads[t], NULL, testTracepoints, (void *)t);
141
	    	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	        
142
		    if (rc)
143
		    {
144
				printf("ERROR; return code from pthread_create() is %d\n", rc);
145
				exit(-1);
146
		    }
147
		}
148
#endif
149
	}
150
	
151
	SLEEP(2); // keep this thread around for a bit
94
    return 0;
152
    return 0;
95
}
153
}
96
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java (-126 / +516 lines)
Lines 30-35 Link Here
30
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsUpdatedEvent;
30
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsUpdatedEvent;
31
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
31
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
32
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
32
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
33
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.CollectAction;
34
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.EvaluateAction;
35
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.TracepointActionManager;
33
import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData;
36
import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData;
34
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
37
import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
35
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
38
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
Lines 58-63 Link Here
58
		// GDB tracepoints are only supported on a remote target (e.g., using gdbserver)
61
		// GDB tracepoints are only supported on a remote target (e.g., using gdbserver)
59
		setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
62
		setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
60
                           IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE);
63
                           IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE);
64
		
65
		// To test both fast and slow tracepoint we just the FAST_THEN_SLOW setting
66
		setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE,
67
				IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW);
61
	}
68
	}
62
	
69
	
63
	private DsfSession fSession;
70
	private DsfSession fSession;
Lines 69-124 Link Here
69
76
70
//	private int fTotalTracingBufferSize = 0;
77
//	private int fTotalTracingBufferSize = 0;
71
	
78
	
79
	
80
    private static final String SOURCE_FILE     = "TracepointTestApp.cc";
81
    private static final String METHOD_NAME     = "testTracepoints";
82
    private static final int    LINE_NUMBER_1   = 97;
83
    private static final int    LINE_NUMBER_2   = 75;
84
    private static final int    LINE_NUMBER_3   = 76;
85
    private static final int    LINE_NUMBER_4   = 85;
86
    private static final int    LINE_LOOP_2     = 109;
87
    private static final String NO_CONDITION    = "";
88
    private static final String NO_COMMANDS     = "";
89
//    private static final int    LAST_LINE_NUMBER   = 94;
90
//    
91
//	private static final int TOTAL_FRAMES_TO_BE_COLLECTED = 1 + 1 + 10 + 1 + 10000;
92
72
	private final static int[] PASS_COUNTS = {12, 2, 32, 6, 128, 0, 0, 0, 0, 0, 0, 0};
93
	private final static int[] PASS_COUNTS = {12, 2, 32, 6, 128, 0, 0, 0, 0, 0, 0, 0};
94
	private final static String[] CONDITIONS = {"gIntVar == 543", "gBoolVar == false", "counter == 3", "counter > 4", "counter > 2 && lIntVar == 12345"};
73
95
74
//	private static CollectAction COLLECT_ACTION_1;
96
	private static CollectAction[] COLLECT_ACTIONS = new CollectAction[10];
75
//	private static CollectAction COLLECT_ACTION_2;
97
	private static EvaluateAction[] EVAL_ACTIONS = new EvaluateAction[10];
76
//	private static CollectAction COLLECT_ACTION_3;
98
//	private static WhileSteppingAction[] STEPPING_ACTION_1 = new WhileSteppingAction[3];
77
//	private static EvalAction EVAL_ACTION_1;
78
//	private static EvalAction EVAL_ACTION_2;
79
//	private static EvalAction EVAL_ACTION_3;
80
//	private static WhileSteppingAction STEPPING_ACTION_1;
81
//	private static WhileSteppingAction STEPPING_ACTION_2;
82
//	private static WhileSteppingAction STEPPING_ACTION_3;
83
99
84
100
85
//	 static {
101
	 static {
86
//		BreakpointActionManager breakpointActionMgr = CDebugCorePlugin.getDefault().getBreakpointActionManager();
102
		TracepointActionManager tracepointActionMgr = TracepointActionManager.getInstance();
87
//
103
88
//		COLLECT_ACTION_1 = new CollectAction();
104
		int index = 0;
89
//		COLLECT_ACTION_1.setCollectString("$locals, counter");
105
		COLLECT_ACTIONS[index] = new CollectAction();
90
//		COLLECT_ACTION_1.setName("CollectAction1");
106
		COLLECT_ACTIONS[index].setCollectString("$locals");
91
//		breakpointActionMgr.addAction(COLLECT_ACTION_1);
107
		COLLECT_ACTIONS[index].setName("Collect locals");
92
//		
108
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
93
//		COLLECT_ACTION_2 = new CollectAction();
109
		index++;
94
//		COLLECT_ACTION_2.setCollectString("$reg");
110
		
95
//		COLLECT_ACTION_2.setName("CollectAction2");
111
		COLLECT_ACTIONS[index] = new CollectAction();
96
//		breakpointActionMgr.addAction(COLLECT_ACTION_2);
112
		COLLECT_ACTIONS[index].setCollectString("gIntVar");
97
//		
113
		COLLECT_ACTIONS[index].setName("Collect gIntVar");
98
//		COLLECT_ACTION_3 = new CollectAction();
114
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
99
//		COLLECT_ACTION_3.setCollectString("$myTraceVariable");
115
		index++;
100
//		COLLECT_ACTION_3.setName("CollectAction3");
116
		
101
//		breakpointActionMgr.addAction(COLLECT_ACTION_3);
117
		COLLECT_ACTIONS[index] = new CollectAction();
102
//		
118
		COLLECT_ACTIONS[index].setCollectString("$locals, counter, $reg");
103
//		
119
		COLLECT_ACTIONS[index].setName("Collect locals, counter and reg");
104
//		EVAL_ACTION_1 = new EvalAction();
120
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
105
//		EVAL_ACTION_1.setEvalString("$count=$count+1");
121
		index++;
106
//		EVAL_ACTION_1.setName("EvalAction1");
122
107
//		breakpointActionMgr.addAction(EVAL_ACTION_1);
123
		COLLECT_ACTIONS[index] = new CollectAction();
108
//		
124
		COLLECT_ACTIONS[index].setCollectString("$reg");
109
//		EVAL_ACTION_2 = new EvalAction();
125
		COLLECT_ACTIONS[index].setName("Collect reg");
110
//		EVAL_ACTION_2.setEvalString("$count2=$count2+2");
126
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
111
//		EVAL_ACTION_2.setName("EvalAction2");
127
		index++;
112
//		breakpointActionMgr.addAction(EVAL_ACTION_2);
128
		
113
//		
129
		COLLECT_ACTIONS[index] = new CollectAction();
114
//		EVAL_ACTION_3 = new EvalAction();
130
		COLLECT_ACTIONS[index].setCollectString("counter, $locals");
115
//		EVAL_ACTION_3.setEvalString("$count3=$count3+3");
131
		COLLECT_ACTIONS[index].setName("Collect counter, locals");
116
//		EVAL_ACTION_3.setName("EvalAction3");
132
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
117
//		breakpointActionMgr.addAction(EVAL_ACTION_3);
133
		index++;
118
//		
134
		
119
//		//TODO do while stepping actions
135
		COLLECT_ACTIONS[index] = new CollectAction();
120
//		
136
		COLLECT_ACTIONS[index].setCollectString("$myTraceVariable");
121
//	}
137
		COLLECT_ACTIONS[index].setName("Collect myTraceVariable");
138
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
139
		index++;
140
		
141
		index=0;
142
		EVAL_ACTIONS[index] = new EvaluateAction();
143
		EVAL_ACTIONS[index].setEvalString("$count=$count+1");
144
		EVAL_ACTIONS[index].setName("Eval increment count");
145
		tracepointActionMgr.addAction(EVAL_ACTIONS[index]);
146
		index++;
147
148
		EVAL_ACTIONS[index] = new EvaluateAction();
149
		EVAL_ACTIONS[index].setEvalString("$count2=$count2+2");
150
		EVAL_ACTIONS[index].setName("Eval increment count2 by 2");
151
		tracepointActionMgr.addAction(EVAL_ACTIONS[index]);
152
		index++;
153
154
		EVAL_ACTIONS[index] = new EvaluateAction();
155
		EVAL_ACTIONS[index].setEvalString("$count3=$count3+3");
156
		EVAL_ACTIONS[index].setName("Eval increment count3 by 3");
157
		tracepointActionMgr.addAction(EVAL_ACTIONS[index]);
158
		index++;
159
		
160
		//TODO do while stepping actions
161
		index=0;
162
		
163
	}
122
164
123
	 @Before
165
	 @Before
124
	 public void initialTest() throws Exception {
166
	 public void initialTest() throws Exception {
Lines 496-512 Link Here
496
	// Below are the tests for the control of tracepoints.
538
	// Below are the tests for the control of tracepoints.
497
	// *********************************************************************
539
	// *********************************************************************
498
540
499
    private static final String SOURCE_FILE     = "TracepointTestApp.cc";
500
    private static final String METHOD_NAME     = "testTracepoints";
501
    private static final int    LINE_NUMBER_1   = 84;
502
    private static final int    LINE_NUMBER_2   = 55;
503
    private static final int    LINE_NUMBER_3   = 56;
504
    private static final int    LINE_LOOP_1     = 81;
505
    private static final int    LINE_LOOP_2     = 88;
506
    private static final String NO_CONDITION    = "";
507
//    private static final int    LAST_LINE_NUMBER   = 94;
508
//    
509
//	private static final int TOTAL_FRAMES_TO_BE_COLLECTED = 1 + 1 + 10 + 1 + 10000;
510
541
511
542
512
    private IBreakpointDMContext[] fTracepoints = null;
543
    private IBreakpointDMContext[] fTracepoints = null;
Lines 548-554 Link Here
548
//		checkTraceStatus(supported, active, frames, null, null);
579
//		checkTraceStatus(supported, active, frames, null, null);
549
//	}
580
//	}
550
581
551
    // GDB 7.0 does not support fast tracepoints, but GDB 7.1 will
582
    // GDB 7.0 does not support fast tracepoints, but GDB 7.2 will
552
    protected boolean fastTracepointsSupported() { return false; }
583
    protected boolean fastTracepointsSupported() { return false; }
553
    
584
    
554
	private class TracepointData {
585
	private class TracepointData {
Lines 557-572 Link Here
557
		String condition;
588
		String condition;
558
		int passcount;
589
		int passcount;
559
		boolean enabled;
590
		boolean enabled;
560
		String actions;
591
		String commands;
561
		boolean isFastTp;
592
		boolean isFastTp;
562
		
593
		
563
		public TracepointData(String file, int line, String cond, int pass, boolean isEnabled, String acts, boolean fast) {
594
		public TracepointData(String file, int line, String cond, int pass, boolean isEnabled, String cmds, boolean fast) {
564
			sourceFile = file;
595
			sourceFile = file;
565
			lineNumber = line;
596
			lineNumber = line;
566
			condition = cond;
597
			condition = cond;
567
			passcount = pass;
598
			passcount = pass;
568
			enabled = isEnabled;
599
			enabled = isEnabled;
569
			actions = acts;
600
			commands = cmds;
570
			if (fastTracepointsSupported()) {
601
			if (fastTracepointsSupported()) {
571
				isFastTp = fast;
602
				isFastTp = fast;
572
			} else {
603
			} else {
Lines 600-609 Link Here
600
					tp.getCondition().equals(data.condition));
631
					tp.getCondition().equals(data.condition));
601
			assertTrue("tracepoint "+i+" mismatch (wrong pass count) got " + tp.getPassCount(),
632
			assertTrue("tracepoint "+i+" mismatch (wrong pass count) got " + tp.getPassCount(),
602
					tp.getPassCount() == data.passcount);
633
					tp.getPassCount() == data.passcount);
603
			assertTrue("tracepoint "+i+" mismatch (wrong state) got " + tp.isEnabled(),
634
			assertTrue("tracepoint "+i+" mismatch (wrong enablement) got " + tp.isEnabled(),
604
					tp.isEnabled() == data.enabled);
635
					tp.isEnabled() == data.enabled);
605
			assertTrue("tracepoint mismatch (wrong actions) got " + tp.getCommands(),
636
			assertTrue("tracepoint "+i+" mismatch (wrong actions) got " + tp.getCommands(),
606
					tp.getCommands().equals(data.actions));
637
					tp.getCommands().equals(data.commands));
607
638
608
			assertTrue("tracepoint "+i+" mismatch",
639
			assertTrue("tracepoint "+i+" mismatch",
609
					tp.equals((MIBreakpointDMData)getBreakpoint(tracepoints[i])));
640
					tp.equals((MIBreakpointDMData)getBreakpoint(tracepoints[i])));
Lines 630-636 Link Here
630
	 * It also set a fast tracepoint by 
661
	 * It also set a fast tracepoint by 
631
	 */
662
	 */
632
	@Test
663
	@Test
633
	public void testCreateTracepoints() throws Throwable {
664
	public void createTracepoints() throws Throwable {
634
665
635
		Map<String, Object> attributes = null;
666
		Map<String, Object> attributes = null;
636
		int index = 0;
667
		int index = 0;
Lines 648-654 Link Here
648
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
679
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
649
		clearEventCounters();
680
		clearEventCounters();
650
		
681
		
651
		// Second tracepoint (will be a fast tracepoint)
682
		// Second tracepoint (will be a slow tracepoint)
652
		attributes = new HashMap<String, Object>();
683
		attributes = new HashMap<String, Object>();
653
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
684
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
654
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
685
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
Lines 662-672 Link Here
662
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
693
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
663
		clearEventCounters();
694
		clearEventCounters();
664
695
665
		// Third tracepoint (will be a slow tracepoint)
696
		// Third tracepoint (will be a fast tracepoint)
666
		attributes = new HashMap<String, Object>();
697
		attributes = new HashMap<String, Object>();
667
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
698
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
668
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
699
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
669
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_1);
700
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_4);
670
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
701
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
671
702
672
		waitForBreakpointEvent();
703
		waitForBreakpointEvent();
Lines 705-715 Link Here
705
		clearEventCounters();		
736
		clearEventCounters();		
706
		
737
		
707
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
738
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
708
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, "", false));
739
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, NO_COMMANDS, false));
709
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, "", true));
740
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, NO_COMMANDS, false));
710
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_1, NO_CONDITION, 0, true, "", false));
741
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, 0, true, NO_COMMANDS, true));
711
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, "", true));
742
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, NO_COMMANDS, true));
712
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, "", false));
743
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, NO_COMMANDS, false));
713
		
744
		
714
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
745
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
715
	}
746
	}
Lines 718-725 Link Here
718
	 * This test sets the different types of tracepoints and then deletes them
749
	 * This test sets the different types of tracepoints and then deletes them
719
	 */
750
	 */
720
	@Test
751
	@Test
721
	public void testDeleteTracepoints() throws Throwable {
752
	public void deleteTracepoints() throws Throwable {
722
		testCreateTracepoints();
753
		createTracepoints();
723
		// Delete all tracepoints
754
		// Delete all tracepoints
724
		for (IBreakpointDMContext tp : fTracepoints) {
755
		for (IBreakpointDMContext tp : fTracepoints) {
725
			if (tp == null) break;
756
			if (tp == null) break;
Lines 736-743 Link Here
736
	 * This test sets the different types of tracepoints and then disables them
767
	 * This test sets the different types of tracepoints and then disables them
737
	 */
768
	 */
738
	@Test
769
	@Test
739
	public void testDisableTracepoints() throws Throwable {
770
	public void disableTracepoints() throws Throwable {
740
		testCreateTracepoints();
771
		createTracepoints();
741
		
772
		
742
		Map<String, Object> delta = new HashMap<String, Object>();
773
		Map<String, Object> delta = new HashMap<String, Object>();
743
		delta.put(MIBreakpoints.IS_ENABLED, false);
774
		delta.put(MIBreakpoints.IS_ENABLED, false);
Lines 748-758 Link Here
748
		}
779
		}
749
780
750
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
781
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
751
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, false, "", false));
782
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, false, NO_COMMANDS, false));
752
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, false, "", true));
783
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, false, NO_COMMANDS, false));
753
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_1, NO_CONDITION, 0, false, "", false));
784
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, 0, false, NO_COMMANDS, true));
754
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, false, "", true));
785
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, false, NO_COMMANDS, true));
755
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, false, "", false));
786
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, false, NO_COMMANDS, false));
756
		
787
		
757
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
788
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
758
	}
789
	}
Lines 761-768 Link Here
761
	 * This test sets, disables the different types of tracepoints and then enables them
792
	 * This test sets, disables the different types of tracepoints and then enables them
762
	 */
793
	 */
763
	@Test
794
	@Test
764
	public void testEnableTracepoints() throws Throwable {
795
	public void enableTracepoints() throws Throwable {
765
		testDisableTracepoints();
796
		disableTracepoints();
766
		
797
		
767
		Map<String, Object> delta = new HashMap<String, Object>();
798
		Map<String, Object> delta = new HashMap<String, Object>();
768
		delta.put(MIBreakpoints.IS_ENABLED, true);
799
		delta.put(MIBreakpoints.IS_ENABLED, true);
Lines 773-783 Link Here
773
		}
804
		}
774
805
775
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
806
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
776
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, "", false));
807
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, NO_COMMANDS, false));
777
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, "", true));
808
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, NO_COMMANDS, false));
778
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_1, NO_CONDITION, 0, true, "", false));
809
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, 0, true, NO_COMMANDS, true));
779
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, "", true));
810
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, NO_COMMANDS, true));
780
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, "", false));
811
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, NO_COMMANDS, false));
781
812
782
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
813
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
783
	}
814
	}
Lines 786-793 Link Here
786
	 * This test sets the different types of tracepoints and then sets their passcount
817
	 * This test sets the different types of tracepoints and then sets their passcount
787
	 */
818
	 */
788
	@Test
819
	@Test
789
	public void testTracepointPasscount() throws Throwable {
820
	public void tracepointPasscount() throws Throwable {
790
		testCreateTracepoints();
821
		createTracepoints();
791
		
822
		
792
		Map<String, Object> delta = new HashMap<String, Object>();
823
		Map<String, Object> delta = new HashMap<String, Object>();
793
		// Set passcount for all tracepoints
824
		// Set passcount for all tracepoints
Lines 795-848 Link Here
795
			if (fTracepoints[i] == null) break;
826
			if (fTracepoints[i] == null) break;
796
			if (PASS_COUNTS[i] == 0) continue;
827
			if (PASS_COUNTS[i] == 0) continue;
797
			delta.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[i]);
828
			delta.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[i]);
829
			updateBreakpoint(fTracepoints[i], delta);
830
		}
831
832
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
833
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, PASS_COUNTS[0], true, NO_COMMANDS, false));
834
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, PASS_COUNTS[1], true, NO_COMMANDS, false));
835
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, PASS_COUNTS[2], true, NO_COMMANDS, true));
836
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, PASS_COUNTS[3], true, NO_COMMANDS, true));
837
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, PASS_COUNTS[4], true, NO_COMMANDS, false));
838
		
839
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
840
	}
841
842
	/**
843
	 * This test sets the different types of tracepoints and then sets some conditions
844
	 */
845
	@Test
846
	public void tracepointCondition() throws Throwable {
847
		createTracepoints();
848
		
849
		Map<String, Object> delta = new HashMap<String, Object>();
850
		// Set conditions for all tracepoints
851
		for (int i=0; i<fTracepoints.length; i++) {
852
			if (fTracepoints[i] == null) break;
853
			if (CONDITIONS[i].equals(NO_CONDITION)) continue;
854
			delta.put(MIBreakpoints.CONDITION, CONDITIONS[i]);
855
			updateBreakpoint(fTracepoints[i], delta);
856
		}
857
858
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
859
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, CONDITIONS[0], 0, true, NO_COMMANDS, false));
860
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, CONDITIONS[1], 0, true, NO_COMMANDS, false));
861
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, CONDITIONS[2], 0, true, NO_COMMANDS, true));
862
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, CONDITIONS[3], 0, true, NO_COMMANDS, true));
863
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, CONDITIONS[4], 0, true, NO_COMMANDS, false));
864
		
865
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
866
867
	}
868
	
869
	/**
870
	 * This test sets the different types of tracepoints and then sets some actions
871
	 */
872
	@Test
873
	public void tracepointActions() throws Throwable {
874
		createTracepoints();
875
		
876
		Map<String, Object> delta = new HashMap<String, Object>();
877
		// Set conditions for all tracepoints
878
		for (int i=0; i<fTracepoints.length; i++) {
879
			if (fTracepoints[i] == null) break;
880
			if (COLLECT_ACTIONS[i].equals(NO_COMMANDS)) continue;
881
			delta.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[i].getName());
798
			updateBreakpoint(fTracepoints[i], delta);
882
			updateBreakpoint(fTracepoints[i], delta);
799
		}
883
		}
884
885
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
886
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, COLLECT_ACTIONS[0].toString(), false));
887
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, COLLECT_ACTIONS[1].toString(), false));
888
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, 0, true, COLLECT_ACTIONS[2].toString(), true));
889
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, COLLECT_ACTIONS[3].toString(), true));
890
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, COLLECT_ACTIONS[4].toString(), false));
891
		
892
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
893
894
	}
895
	
896
	/**
897
	 * This test creates a tracepoint that starts disabled
898
	 */
899
	@Test
900
	public void createTracepointDisabled() throws Throwable {
901
		Map<String, Object> attributes = null;
902
		int index = 0;
903
		
904
		// First tracepoint will be a slow tracepoint
905
		attributes = new HashMap<String, Object>();
906
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
907
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
908
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
909
		attributes.put(MIBreakpoints.IS_ENABLED, false);
910
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
911
912
		waitForBreakpointEvent();
913
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
914
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
915
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
916
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
917
		clearEventCounters();
918
919
		// Second tracepoint will be a fast tracepoint
920
		attributes = new HashMap<String, Object>();
921
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
922
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
923
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
924
		attributes.put(MIBreakpoints.IS_ENABLED, false);
925
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
926
927
		waitForBreakpointEvent();
928
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
929
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
930
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
931
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
932
		clearEventCounters();		
933
934
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
935
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, false, NO_COMMANDS, false));
936
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, false, NO_COMMANDS, true));
937
		
938
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
939
	}
940
941
	/**
942
	 * This test creates a tracepoint that starts with a passcount
943
	 */
944
	@Test
945
	public void createTracepointWithPasscount() throws Throwable {
946
		Map<String, Object> attributes = null;
947
		int index = 0;
948
		
949
		// First tracepoint will be a slow tracepoint
950
		attributes = new HashMap<String, Object>();
951
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
952
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
953
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
954
		attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[0]);
955
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
956
957
		waitForBreakpointEvent();
958
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
959
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
960
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
961
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
962
		clearEventCounters();
963
964
		// Second tracepoint will be a fast tracepoint
965
		attributes = new HashMap<String, Object>();
966
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
967
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
968
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
969
		attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[1]);
970
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
971
972
		waitForBreakpointEvent();
973
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
974
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
975
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
976
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
977
		clearEventCounters();		
978
979
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
980
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, PASS_COUNTS[0], true, NO_COMMANDS, false));
981
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, PASS_COUNTS[1], true, NO_COMMANDS, true));
982
		
983
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
984
	}
985
986
	/**
987
	 * This test creates a tracepoint that starts with a condition
988
	 */
989
	@Test
990
	public void createTracepointWithCondition() throws Throwable {
991
		Map<String, Object> attributes = null;
992
		int index = 0;
993
		
994
		// First tracepoint will be a slow tracepoint
995
		attributes = new HashMap<String, Object>();
996
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
997
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
998
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
999
		attributes.put(MIBreakpoints.CONDITION, CONDITIONS[0]);
1000
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1001
1002
		waitForBreakpointEvent();
1003
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1004
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1005
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1006
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1007
		clearEventCounters();
1008
1009
		// Second tracepoint will be a fast tracepoint
1010
		attributes = new HashMap<String, Object>();
1011
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1012
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1013
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
1014
		attributes.put(MIBreakpoints.CONDITION, CONDITIONS[1]);
1015
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1016
1017
		waitForBreakpointEvent();
1018
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1019
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1020
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1021
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1022
		clearEventCounters();		
1023
1024
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
1025
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, CONDITIONS[0], 0, true, NO_COMMANDS, false));
1026
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, CONDITIONS[1], 0, true, NO_COMMANDS, true));
1027
		
1028
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
1029
	}
1030
	
1031
	/**
1032
	 * This test creates tracepoints that start a command
1033
	 */
1034
	@Test
1035
	public void createTracepointWithCommand() throws Throwable {
1036
		Map<String, Object> attributes = null;
1037
		int index = 0;
1038
		
1039
		// First tracepoint will be a slow tracepoint
1040
		attributes = new HashMap<String, Object>();
1041
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1042
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1043
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
1044
		attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[0].getName());
1045
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1046
1047
		waitForBreakpointEvent();
1048
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1049
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1050
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1051
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1052
		clearEventCounters();
1053
1054
		// Second tracepoint will be a fast tracepoint
1055
		attributes = new HashMap<String, Object>();
1056
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1057
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1058
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
1059
		attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[1].getName());
1060
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1061
1062
		waitForBreakpointEvent();
1063
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1064
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1065
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1066
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1067
		clearEventCounters();		
1068
1069
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
1070
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, COLLECT_ACTIONS[0].toString(), false));
1071
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, COLLECT_ACTIONS[1].toString(), true));
1072
		
1073
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
1074
	}
1075
	
1076
	/**
1077
	 * This test creates tracepoints that start with more than one command
1078
	 */
1079
	@Test
1080
	public void createTracepointWithMultipleCommands() throws Throwable {
1081
		Map<String, Object> attributes = null;
1082
		int index = 0;
1083
		
1084
		// First tracepoint will be a slow tracepoint
1085
		attributes = new HashMap<String, Object>();
1086
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1087
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1088
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
1089
		String commandsNames1 = COLLECT_ACTIONS[0].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1090
				COLLECT_ACTIONS[1].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1091
				COLLECT_ACTIONS[2].getName();
1092
		String commandsResult1 = COLLECT_ACTIONS[0].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1093
				COLLECT_ACTIONS[1].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1094
				COLLECT_ACTIONS[2].toString();
1095
		attributes.put(MIBreakpoints.COMMANDS, commandsNames1);
1096
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1097
1098
		waitForBreakpointEvent();
1099
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1100
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1101
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1102
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1103
		clearEventCounters();
1104
1105
		// Second tracepoint will be a fast tracepoint
1106
		attributes = new HashMap<String, Object>();
1107
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1108
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1109
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
1110
		String commandsNames2 = COLLECT_ACTIONS[2].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1111
				COLLECT_ACTIONS[2].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1112
				COLLECT_ACTIONS[1].getName();
1113
		String commandsResult2 = COLLECT_ACTIONS[2].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1114
				COLLECT_ACTIONS[2].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1115
				COLLECT_ACTIONS[1].toString();
1116
		attributes.put(MIBreakpoints.COMMANDS, commandsNames2);
1117
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1118
1119
		waitForBreakpointEvent();
1120
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1121
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1122
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1123
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1124
		clearEventCounters();		
800
1125
801
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
1126
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
802
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, PASS_COUNTS[0], true, "", false));
1127
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, commandsResult1, false));
803
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, PASS_COUNTS[1], true, "", true));
1128
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, commandsResult2, true));
804
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_1, NO_CONDITION, PASS_COUNTS[2], true, "", false));
805
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, PASS_COUNTS[3], true, "", true));
806
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, PASS_COUNTS[4], true, "", false));
807
		
1129
		
808
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
1130
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
809
	}
1131
	}
1132
	
1133
	/**
1134
	 * This test creates an enabled tracepoint that starts with commands, condition and passcount
1135
	 */
1136
	@Test
1137
	public void createTracepointEnabledWithCommandsConditionPasscount() throws Throwable {
1138
		Map<String, Object> attributes = null;
1139
		int index = 0;
1140
		
1141
		// First tracepoint will be a slow tracepoint
1142
		attributes = new HashMap<String, Object>();
1143
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1144
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1145
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
1146
		attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[0].getName());
1147
		attributes.put(MIBreakpoints.CONDITION, CONDITIONS[0]);
1148
		attributes.put(MIBreakpoints.IS_ENABLED, true);
1149
		attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[0]);
1150
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1151
1152
		waitForBreakpointEvent();
1153
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1154
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1155
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1156
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1157
		clearEventCounters();
1158
1159
		// Second tracepoint will be a fast tracepoint
1160
		attributes = new HashMap<String, Object>();
1161
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1162
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1163
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
1164
		attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[1].getName());
1165
		attributes.put(MIBreakpoints.CONDITION, CONDITIONS[1]);
1166
		attributes.put(MIBreakpoints.IS_ENABLED, true);
1167
		attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[1]);
1168
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1169
1170
		waitForBreakpointEvent();
1171
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1172
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1173
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1174
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1175
		clearEventCounters();		
810
1176
1177
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
1178
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, CONDITIONS[0], PASS_COUNTS[0], true, COLLECT_ACTIONS[0].toString(), false));
1179
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, CONDITIONS[1], PASS_COUNTS[1], true, COLLECT_ACTIONS[1].toString(), true));
1180
		
1181
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
1182
	}
1183
	
811
	/**
1184
	/**
812
	 * This test sets a tracepoint and then gives it a condition
1185
	 * This test creates a disabled tracepoint that starts with commands, condition and passcount
813
	 */
1186
	 */
814
	//@Test
1187
	@Test
815
	public void testTracepointCondition() throws Throwable {
1188
	public void createTracepointDisabledWithCommandsConditionPasscount() throws Throwable {
816
		// Use trace state variables and stuff
1189
		Map<String, Object> attributes = null;
1190
		int index = 0;
1191
		
1192
		// First tracepoint will be a slow tracepoint
1193
		attributes = new HashMap<String, Object>();
1194
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1195
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1196
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
1197
		attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[0].getName());
1198
		attributes.put(MIBreakpoints.CONDITION, CONDITIONS[0]);
1199
		attributes.put(MIBreakpoints.IS_ENABLED, false);
1200
		attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[0]);
1201
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1202
1203
		waitForBreakpointEvent();
1204
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1205
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1206
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1207
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1208
		clearEventCounters();
1209
1210
		// Second tracepoint will be a fast tracepoint
1211
		attributes = new HashMap<String, Object>();
1212
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1213
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1214
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
1215
		attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[1].getName());
1216
		attributes.put(MIBreakpoints.CONDITION, CONDITIONS[1]);
1217
		attributes.put(MIBreakpoints.IS_ENABLED, false);
1218
		attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[1]);
1219
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1220
1221
		waitForBreakpointEvent();
1222
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1223
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1224
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1225
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1226
		clearEventCounters();		
1227
1228
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
1229
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, CONDITIONS[0], PASS_COUNTS[0], false, COLLECT_ACTIONS[0].toString(), false));
1230
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, CONDITIONS[1], PASS_COUNTS[1], false, COLLECT_ACTIONS[1].toString(), true));
1231
		
1232
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
817
	}
1233
	}
818
	
1234
	
819
1235
820
//	private void testActions(String[] actions) throws Throwable {
821
//		Map<String, Object> delta = new HashMap<String, Object>();
822
//		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
823
//		
824
//		for (int i=0; i<actions.length; i++) {
825
//			delta.put(MIBreakpoints.COMMANDS, actions[i]);
826
//			updateBreakpoint(fTracepoints[i], delta);
827
//			dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, actions[i], false));
828
//		}
829
//		
830
//		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
831
//	}
832
//	
833
//	/**
834
//	 * This test sets the different types of tracepoints and then sets some collect actions
835
//	 */	
836
//	@Test
837
//	public void testCollectActions() throws Throwable {
838
//		final String ACTIONS1 = COLLECT_ACTION_1.getName()+","+COLLECT_ACTION_2.getName()+","+COLLECT_ACTION_3.getName();
839
//		final String ACTIONS2 = COLLECT_ACTION_1.getName()+","+COLLECT_ACTION_3.getName();
840
//		final String ACTIONS3 = COLLECT_ACTION_3.getName();
841
//
842
//		testCreateTracepoints();
843
//		testActions(new String[] {ACTIONS1, ACTIONS2, ACTIONS3, ""});
844
//	}
845
//	
846
//	/**
1236
//	/**
847
//	 * This test sets the different types of tracepoints and then sets some eval actions
1237
//	 * This test sets the different types of tracepoints and then sets some eval actions
848
//	 */
1238
//	 */
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/GDBRemoteTracepointsTest_7_2.java (+4 lines)
Lines 23-26 Link Here
23
	public static void beforeClassMethod_7_2() {
23
	public static void beforeClassMethod_7_2() {
24
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2);		
24
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2);		
25
	}
25
	}
26
	
27
	@Override
28
    protected boolean fastTracepointsSupported() { return true; }
29
26
}
30
}

Return to bug 346320