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 / +512 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 69-124 Link Here
69
72
70
//	private int fTotalTracingBufferSize = 0;
73
//	private int fTotalTracingBufferSize = 0;
71
	
74
	
75
	
76
    private static final String SOURCE_FILE     = "TracepointTestApp.cc";
77
    private static final String METHOD_NAME     = "testTracepoints";
78
    private static final int    LINE_NUMBER_1   = 97;
79
    private static final int    LINE_NUMBER_2   = 75;
80
    private static final int    LINE_NUMBER_3   = 76;
81
    private static final int    LINE_NUMBER_4   = 85;
82
    private static final int    LINE_LOOP_2     = 109;
83
    private static final String NO_CONDITION    = "";
84
    private static final String NO_COMMANDS     = "";
85
//    private static final int    LAST_LINE_NUMBER   = 94;
86
//    
87
//	private static final int TOTAL_FRAMES_TO_BE_COLLECTED = 1 + 1 + 10 + 1 + 10000;
88
72
	private final static int[] PASS_COUNTS = {12, 2, 32, 6, 128, 0, 0, 0, 0, 0, 0, 0};
89
	private final static int[] PASS_COUNTS = {12, 2, 32, 6, 128, 0, 0, 0, 0, 0, 0, 0};
90
	private final static String[] CONDITIONS = {"gIntVar == 543", "gBoolVar == false", "counter == 3", "counter > 4", "counter > 2 && lIntVar == 12345"};
73
91
74
//	private static CollectAction COLLECT_ACTION_1;
92
	private static CollectAction[] COLLECT_ACTIONS = new CollectAction[10];
75
//	private static CollectAction COLLECT_ACTION_2;
93
	private static EvaluateAction[] EVAL_ACTIONS = new EvaluateAction[10];
76
//	private static CollectAction COLLECT_ACTION_3;
94
//	private static WhileSteppingAction[] STEPPING_ACTION_1 = new WhileSteppingAction[3];
77
//	private static EvalAction EVAL_ACTION_1;
95
78
//	private static EvalAction EVAL_ACTION_2;
96
79
//	private static EvalAction EVAL_ACTION_3;
97
	 static {
80
//	private static WhileSteppingAction STEPPING_ACTION_1;
98
		TracepointActionManager tracepointActionMgr = TracepointActionManager.getInstance();
81
//	private static WhileSteppingAction STEPPING_ACTION_2;
99
82
//	private static WhileSteppingAction STEPPING_ACTION_3;
100
		int index = 0;
101
		COLLECT_ACTIONS[index] = new CollectAction();
102
		COLLECT_ACTIONS[index].setCollectString("$locals");
103
		COLLECT_ACTIONS[index].setName("Collect locals");
104
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
105
		index++;
106
		
107
		COLLECT_ACTIONS[index] = new CollectAction();
108
		COLLECT_ACTIONS[index].setCollectString("gIntVar");
109
		COLLECT_ACTIONS[index].setName("Collect gIntVar");
110
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
111
		index++;
112
		
113
		COLLECT_ACTIONS[index] = new CollectAction();
114
		COLLECT_ACTIONS[index].setCollectString("$locals, counter, $reg");
115
		COLLECT_ACTIONS[index].setName("Collect locals, counter and reg");
116
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
117
		index++;
118
119
		COLLECT_ACTIONS[index] = new CollectAction();
120
		COLLECT_ACTIONS[index].setCollectString("$reg");
121
		COLLECT_ACTIONS[index].setName("Collect reg");
122
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
123
		index++;
124
		
125
		COLLECT_ACTIONS[index] = new CollectAction();
126
		COLLECT_ACTIONS[index].setCollectString("counter, $locals");
127
		COLLECT_ACTIONS[index].setName("Collect counter, locals");
128
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
129
		index++;
130
		
131
		COLLECT_ACTIONS[index] = new CollectAction();
132
		COLLECT_ACTIONS[index].setCollectString("$myTraceVariable");
133
		COLLECT_ACTIONS[index].setName("Collect myTraceVariable");
134
		tracepointActionMgr.addAction(COLLECT_ACTIONS[index]);
135
		index++;
136
		
137
		index=0;
138
		EVAL_ACTIONS[index] = new EvaluateAction();
139
		EVAL_ACTIONS[index].setEvalString("$count=$count+1");
140
		EVAL_ACTIONS[index].setName("Eval increment count");
141
		tracepointActionMgr.addAction(EVAL_ACTIONS[index]);
142
		index++;
83
143
144
		EVAL_ACTIONS[index] = new EvaluateAction();
145
		EVAL_ACTIONS[index].setEvalString("$count2=$count2+2");
146
		EVAL_ACTIONS[index].setName("Eval increment count2 by 2");
147
		tracepointActionMgr.addAction(EVAL_ACTIONS[index]);
148
		index++;
84
149
85
//	 static {
150
		EVAL_ACTIONS[index] = new EvaluateAction();
86
//		BreakpointActionManager breakpointActionMgr = CDebugCorePlugin.getDefault().getBreakpointActionManager();
151
		EVAL_ACTIONS[index].setEvalString("$count3=$count3+3");
87
//
152
		EVAL_ACTIONS[index].setName("Eval increment count3 by 3");
88
//		COLLECT_ACTION_1 = new CollectAction();
153
		tracepointActionMgr.addAction(EVAL_ACTIONS[index]);
89
//		COLLECT_ACTION_1.setCollectString("$locals, counter");
154
		index++;
90
//		COLLECT_ACTION_1.setName("CollectAction1");
155
		
91
//		breakpointActionMgr.addAction(COLLECT_ACTION_1);
156
		//TODO do while stepping actions
92
//		
157
		index=0;
93
//		COLLECT_ACTION_2 = new CollectAction();
158
		
94
//		COLLECT_ACTION_2.setCollectString("$reg");
159
	}
95
//		COLLECT_ACTION_2.setName("CollectAction2");
96
//		breakpointActionMgr.addAction(COLLECT_ACTION_2);
97
//		
98
//		COLLECT_ACTION_3 = new CollectAction();
99
//		COLLECT_ACTION_3.setCollectString("$myTraceVariable");
100
//		COLLECT_ACTION_3.setName("CollectAction3");
101
//		breakpointActionMgr.addAction(COLLECT_ACTION_3);
102
//		
103
//		
104
//		EVAL_ACTION_1 = new EvalAction();
105
//		EVAL_ACTION_1.setEvalString("$count=$count+1");
106
//		EVAL_ACTION_1.setName("EvalAction1");
107
//		breakpointActionMgr.addAction(EVAL_ACTION_1);
108
//		
109
//		EVAL_ACTION_2 = new EvalAction();
110
//		EVAL_ACTION_2.setEvalString("$count2=$count2+2");
111
//		EVAL_ACTION_2.setName("EvalAction2");
112
//		breakpointActionMgr.addAction(EVAL_ACTION_2);
113
//		
114
//		EVAL_ACTION_3 = new EvalAction();
115
//		EVAL_ACTION_3.setEvalString("$count3=$count3+3");
116
//		EVAL_ACTION_3.setName("EvalAction3");
117
//		breakpointActionMgr.addAction(EVAL_ACTION_3);
118
//		
119
//		//TODO do while stepping actions
120
//		
121
//	}
122
160
123
	 @Before
161
	 @Before
124
	 public void initialTest() throws Exception {
162
	 public void initialTest() throws Exception {
Lines 496-512 Link Here
496
	// Below are the tests for the control of tracepoints.
534
	// Below are the tests for the control of tracepoints.
497
	// *********************************************************************
535
	// *********************************************************************
498
536
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
537
511
538
512
    private IBreakpointDMContext[] fTracepoints = null;
539
    private IBreakpointDMContext[] fTracepoints = null;
Lines 548-554 Link Here
548
//		checkTraceStatus(supported, active, frames, null, null);
575
//		checkTraceStatus(supported, active, frames, null, null);
549
//	}
576
//	}
550
577
551
    // GDB 7.0 does not support fast tracepoints, but GDB 7.1 will
578
    // GDB 7.0 does not support fast tracepoints, but GDB 7.2 will
552
    protected boolean fastTracepointsSupported() { return false; }
579
    protected boolean fastTracepointsSupported() { return false; }
553
    
580
    
554
	private class TracepointData {
581
	private class TracepointData {
Lines 557-572 Link Here
557
		String condition;
584
		String condition;
558
		int passcount;
585
		int passcount;
559
		boolean enabled;
586
		boolean enabled;
560
		String actions;
587
		String commands;
561
		boolean isFastTp;
588
		boolean isFastTp;
562
		
589
		
563
		public TracepointData(String file, int line, String cond, int pass, boolean isEnabled, String acts, boolean fast) {
590
		public TracepointData(String file, int line, String cond, int pass, boolean isEnabled, String cmds, boolean fast) {
564
			sourceFile = file;
591
			sourceFile = file;
565
			lineNumber = line;
592
			lineNumber = line;
566
			condition = cond;
593
			condition = cond;
567
			passcount = pass;
594
			passcount = pass;
568
			enabled = isEnabled;
595
			enabled = isEnabled;
569
			actions = acts;
596
			commands = cmds;
570
			if (fastTracepointsSupported()) {
597
			if (fastTracepointsSupported()) {
571
				isFastTp = fast;
598
				isFastTp = fast;
572
			} else {
599
			} else {
Lines 600-609 Link Here
600
					tp.getCondition().equals(data.condition));
627
					tp.getCondition().equals(data.condition));
601
			assertTrue("tracepoint "+i+" mismatch (wrong pass count) got " + tp.getPassCount(),
628
			assertTrue("tracepoint "+i+" mismatch (wrong pass count) got " + tp.getPassCount(),
602
					tp.getPassCount() == data.passcount);
629
					tp.getPassCount() == data.passcount);
603
			assertTrue("tracepoint "+i+" mismatch (wrong state) got " + tp.isEnabled(),
630
			assertTrue("tracepoint "+i+" mismatch (wrong enablement) got " + tp.isEnabled(),
604
					tp.isEnabled() == data.enabled);
631
					tp.isEnabled() == data.enabled);
605
			assertTrue("tracepoint mismatch (wrong actions) got " + tp.getCommands(),
632
			assertTrue("tracepoint "+i+" mismatch (wrong actions) got " + tp.getCommands(),
606
					tp.getCommands().equals(data.actions));
633
					tp.getCommands().equals(data.commands));
607
634
608
			assertTrue("tracepoint "+i+" mismatch",
635
			assertTrue("tracepoint "+i+" mismatch",
609
					tp.equals((MIBreakpointDMData)getBreakpoint(tracepoints[i])));
636
					tp.equals((MIBreakpointDMData)getBreakpoint(tracepoints[i])));
Lines 630-636 Link Here
630
	 * It also set a fast tracepoint by 
657
	 * It also set a fast tracepoint by 
631
	 */
658
	 */
632
	@Test
659
	@Test
633
	public void testCreateTracepoints() throws Throwable {
660
	public void createTracepoints() throws Throwable {
634
661
635
		Map<String, Object> attributes = null;
662
		Map<String, Object> attributes = null;
636
		int index = 0;
663
		int index = 0;
Lines 648-654 Link Here
648
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
675
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
649
		clearEventCounters();
676
		clearEventCounters();
650
		
677
		
651
		// Second tracepoint (will be a fast tracepoint)
678
		// Second tracepoint (will be a slow tracepoint)
652
		attributes = new HashMap<String, Object>();
679
		attributes = new HashMap<String, Object>();
653
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
680
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
654
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
681
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
Lines 662-672 Link Here
662
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
689
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
663
		clearEventCounters();
690
		clearEventCounters();
664
691
665
		// Third tracepoint (will be a slow tracepoint)
692
		// Third tracepoint (will be a fast tracepoint)
666
		attributes = new HashMap<String, Object>();
693
		attributes = new HashMap<String, Object>();
667
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
694
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
668
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
695
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
669
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_1);
696
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_4);
670
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
697
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
671
698
672
		waitForBreakpointEvent();
699
		waitForBreakpointEvent();
Lines 705-715 Link Here
705
		clearEventCounters();		
732
		clearEventCounters();		
706
		
733
		
707
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
734
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
708
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, "", false));
735
		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));
736
		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));
737
		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));
738
		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));
739
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, NO_COMMANDS, false));
713
		
740
		
714
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
741
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
715
	}
742
	}
Lines 718-725 Link Here
718
	 * This test sets the different types of tracepoints and then deletes them
745
	 * This test sets the different types of tracepoints and then deletes them
719
	 */
746
	 */
720
	@Test
747
	@Test
721
	public void testDeleteTracepoints() throws Throwable {
748
	public void deleteTracepoints() throws Throwable {
722
		testCreateTracepoints();
749
		createTracepoints();
723
		// Delete all tracepoints
750
		// Delete all tracepoints
724
		for (IBreakpointDMContext tp : fTracepoints) {
751
		for (IBreakpointDMContext tp : fTracepoints) {
725
			if (tp == null) break;
752
			if (tp == null) break;
Lines 736-743 Link Here
736
	 * This test sets the different types of tracepoints and then disables them
763
	 * This test sets the different types of tracepoints and then disables them
737
	 */
764
	 */
738
	@Test
765
	@Test
739
	public void testDisableTracepoints() throws Throwable {
766
	public void disableTracepoints() throws Throwable {
740
		testCreateTracepoints();
767
		createTracepoints();
741
		
768
		
742
		Map<String, Object> delta = new HashMap<String, Object>();
769
		Map<String, Object> delta = new HashMap<String, Object>();
743
		delta.put(MIBreakpoints.IS_ENABLED, false);
770
		delta.put(MIBreakpoints.IS_ENABLED, false);
Lines 748-758 Link Here
748
		}
775
		}
749
776
750
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
777
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
751
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, false, "", false));
778
		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));
779
		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));
780
		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));
781
		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));
782
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, false, NO_COMMANDS, false));
756
		
783
		
757
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
784
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
758
	}
785
	}
Lines 761-768 Link Here
761
	 * This test sets, disables the different types of tracepoints and then enables them
788
	 * This test sets, disables the different types of tracepoints and then enables them
762
	 */
789
	 */
763
	@Test
790
	@Test
764
	public void testEnableTracepoints() throws Throwable {
791
	public void enableTracepoints() throws Throwable {
765
		testDisableTracepoints();
792
		disableTracepoints();
766
		
793
		
767
		Map<String, Object> delta = new HashMap<String, Object>();
794
		Map<String, Object> delta = new HashMap<String, Object>();
768
		delta.put(MIBreakpoints.IS_ENABLED, true);
795
		delta.put(MIBreakpoints.IS_ENABLED, true);
Lines 773-783 Link Here
773
		}
800
		}
774
801
775
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
802
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
776
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, "", false));
803
		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));
804
		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));
805
		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));
806
		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));
807
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, NO_COMMANDS, false));
781
808
782
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
809
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
783
	}
810
	}
Lines 786-793 Link Here
786
	 * This test sets the different types of tracepoints and then sets their passcount
813
	 * This test sets the different types of tracepoints and then sets their passcount
787
	 */
814
	 */
788
	@Test
815
	@Test
789
	public void testTracepointPasscount() throws Throwable {
816
	public void tracepointPasscount() throws Throwable {
790
		testCreateTracepoints();
817
		createTracepoints();
791
		
818
		
792
		Map<String, Object> delta = new HashMap<String, Object>();
819
		Map<String, Object> delta = new HashMap<String, Object>();
793
		// Set passcount for all tracepoints
820
		// Set passcount for all tracepoints
Lines 795-848 Link Here
795
			if (fTracepoints[i] == null) break;
822
			if (fTracepoints[i] == null) break;
796
			if (PASS_COUNTS[i] == 0) continue;
823
			if (PASS_COUNTS[i] == 0) continue;
797
			delta.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[i]);
824
			delta.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[i]);
825
			updateBreakpoint(fTracepoints[i], delta);
826
		}
827
828
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
829
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, PASS_COUNTS[0], true, NO_COMMANDS, false));
830
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, PASS_COUNTS[1], true, NO_COMMANDS, false));
831
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, PASS_COUNTS[2], true, NO_COMMANDS, true));
832
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, PASS_COUNTS[3], true, NO_COMMANDS, true));
833
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, PASS_COUNTS[4], true, NO_COMMANDS, false));
834
		
835
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
836
	}
837
838
	/**
839
	 * This test sets the different types of tracepoints and then sets some conditions
840
	 */
841
	@Test
842
	public void tracepointCondition() throws Throwable {
843
		createTracepoints();
844
		
845
		Map<String, Object> delta = new HashMap<String, Object>();
846
		// Set conditions for all tracepoints
847
		for (int i=0; i<fTracepoints.length; i++) {
848
			if (fTracepoints[i] == null) break;
849
			if (CONDITIONS[i].equals(NO_CONDITION)) continue;
850
			delta.put(MIBreakpoints.CONDITION, CONDITIONS[i]);
851
			updateBreakpoint(fTracepoints[i], delta);
852
		}
853
854
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
855
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, CONDITIONS[0], 0, true, NO_COMMANDS, false));
856
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, CONDITIONS[1], 0, true, NO_COMMANDS, false));
857
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, CONDITIONS[2], 0, true, NO_COMMANDS, true));
858
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, CONDITIONS[3], 0, true, NO_COMMANDS, true));
859
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, CONDITIONS[4], 0, true, NO_COMMANDS, false));
860
		
861
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
862
863
	}
864
	
865
	/**
866
	 * This test sets the different types of tracepoints and then sets some actions
867
	 */
868
	@Test
869
	public void tracepointActions() throws Throwable {
870
		createTracepoints();
871
		
872
		Map<String, Object> delta = new HashMap<String, Object>();
873
		// Set conditions for all tracepoints
874
		for (int i=0; i<fTracepoints.length; i++) {
875
			if (fTracepoints[i] == null) break;
876
			if (COLLECT_ACTIONS[i].equals(NO_COMMANDS)) continue;
877
			delta.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[i].getName());
798
			updateBreakpoint(fTracepoints[i], delta);
878
			updateBreakpoint(fTracepoints[i], delta);
799
		}
879
		}
880
881
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
882
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, COLLECT_ACTIONS[0].toString(), false));
883
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, COLLECT_ACTIONS[1].toString(), false));
884
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_4, NO_CONDITION, 0, true, COLLECT_ACTIONS[2].toString(), true));
885
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, COLLECT_ACTIONS[3].toString(), true));
886
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, COLLECT_ACTIONS[4].toString(), false));
887
		
888
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
889
890
	}
891
	
892
	/**
893
	 * This test creates a tracepoint that starts disabled
894
	 */
895
	@Test
896
	public void createTracepointDisabled() throws Throwable {
897
		Map<String, Object> attributes = null;
898
		int index = 0;
899
		
900
		// First tracepoint will be a slow tracepoint
901
		attributes = new HashMap<String, Object>();
902
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
903
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
904
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
905
		attributes.put(MIBreakpoints.IS_ENABLED, false);
906
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
907
908
		waitForBreakpointEvent();
909
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
910
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
911
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
912
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
913
		clearEventCounters();
914
915
		// Second tracepoint will be a fast tracepoint
916
		attributes = new HashMap<String, Object>();
917
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
918
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
919
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
920
		attributes.put(MIBreakpoints.IS_ENABLED, false);
921
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
922
923
		waitForBreakpointEvent();
924
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
925
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
926
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
927
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
928
		clearEventCounters();		
929
930
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
931
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, false, NO_COMMANDS, false));
932
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, false, NO_COMMANDS, true));
933
		
934
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
935
	}
936
937
	/**
938
	 * This test creates a tracepoint that starts with a passcount
939
	 */
940
	@Test
941
	public void createTracepointWithPasscount() throws Throwable {
942
		Map<String, Object> attributes = null;
943
		int index = 0;
944
		
945
		// First tracepoint will be a slow tracepoint
946
		attributes = new HashMap<String, Object>();
947
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
948
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
949
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
950
		attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[0]);
951
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
952
953
		waitForBreakpointEvent();
954
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
955
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
956
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
957
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
958
		clearEventCounters();
959
960
		// Second tracepoint will be a fast tracepoint
961
		attributes = new HashMap<String, Object>();
962
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
963
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
964
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
965
		attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[1]);
966
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
967
968
		waitForBreakpointEvent();
969
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
970
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
971
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
972
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
973
		clearEventCounters();		
974
975
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
976
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, PASS_COUNTS[0], true, NO_COMMANDS, false));
977
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, PASS_COUNTS[1], true, NO_COMMANDS, true));
978
		
979
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
980
	}
981
982
	/**
983
	 * This test creates a tracepoint that starts with a condition
984
	 */
985
	@Test
986
	public void createTracepointWithCondition() throws Throwable {
987
		Map<String, Object> attributes = null;
988
		int index = 0;
989
		
990
		// First tracepoint will be a slow tracepoint
991
		attributes = new HashMap<String, Object>();
992
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
993
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
994
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
995
		attributes.put(MIBreakpoints.CONDITION, CONDITIONS[0]);
996
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
997
998
		waitForBreakpointEvent();
999
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1000
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1001
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1002
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1003
		clearEventCounters();
1004
1005
		// Second tracepoint will be a fast tracepoint
1006
		attributes = new HashMap<String, Object>();
1007
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1008
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1009
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
1010
		attributes.put(MIBreakpoints.CONDITION, CONDITIONS[1]);
1011
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1012
1013
		waitForBreakpointEvent();
1014
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1015
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1016
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1017
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1018
		clearEventCounters();		
1019
1020
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
1021
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, CONDITIONS[0], 0, true, NO_COMMANDS, false));
1022
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, CONDITIONS[1], 0, true, NO_COMMANDS, true));
1023
		
1024
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
1025
	}
1026
	
1027
	/**
1028
	 * This test creates tracepoints that start a command
1029
	 */
1030
	@Test
1031
	public void createTracepointWithCommand() throws Throwable {
1032
		Map<String, Object> attributes = null;
1033
		int index = 0;
1034
		
1035
		// First tracepoint will be a slow tracepoint
1036
		attributes = new HashMap<String, Object>();
1037
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1038
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1039
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
1040
		attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[0].getName());
1041
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1042
1043
		waitForBreakpointEvent();
1044
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1045
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1046
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1047
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1048
		clearEventCounters();
1049
1050
		// Second tracepoint will be a fast tracepoint
1051
		attributes = new HashMap<String, Object>();
1052
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1053
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1054
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
1055
		attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[1].getName());
1056
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1057
1058
		waitForBreakpointEvent();
1059
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1060
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1061
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1062
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1063
		clearEventCounters();		
1064
1065
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
1066
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, COLLECT_ACTIONS[0].toString(), false));
1067
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, COLLECT_ACTIONS[1].toString(), true));
1068
		
1069
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
1070
	}
1071
	
1072
	/**
1073
	 * This test creates tracepoints that start with more than one command
1074
	 */
1075
	@Test
1076
	public void createTracepointWithMultipleCommands() throws Throwable {
1077
		Map<String, Object> attributes = null;
1078
		int index = 0;
1079
		
1080
		// First tracepoint will be a slow tracepoint
1081
		attributes = new HashMap<String, Object>();
1082
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1083
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1084
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
1085
		String commandsNames1 = COLLECT_ACTIONS[0].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1086
				COLLECT_ACTIONS[1].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1087
				COLLECT_ACTIONS[2].getName();
1088
		String commandsResult1 = COLLECT_ACTIONS[0].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1089
				COLLECT_ACTIONS[1].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1090
				COLLECT_ACTIONS[2].toString();
1091
		attributes.put(MIBreakpoints.COMMANDS, commandsNames1);
1092
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1093
1094
		waitForBreakpointEvent();
1095
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1096
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1097
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1098
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1099
		clearEventCounters();
1100
1101
		// Second tracepoint will be a fast tracepoint
1102
		attributes = new HashMap<String, Object>();
1103
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1104
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1105
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
1106
		String commandsNames2 = COLLECT_ACTIONS[2].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1107
				COLLECT_ACTIONS[2].getName() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1108
				COLLECT_ACTIONS[1].getName();
1109
		String commandsResult2 = COLLECT_ACTIONS[2].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1110
				COLLECT_ACTIONS[2].toString() + TracepointActionManager.TRACEPOINT_ACTION_DELIMITER +
1111
				COLLECT_ACTIONS[1].toString();
1112
		attributes.put(MIBreakpoints.COMMANDS, commandsNames2);
1113
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1114
1115
		waitForBreakpointEvent();
1116
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1117
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1118
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1119
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1120
		clearEventCounters();		
800
1121
801
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
1122
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
802
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, PASS_COUNTS[0], true, "", false));
1123
		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));
1124
		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
		
1125
		
808
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
1126
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
809
	}
1127
	}
1128
	
1129
	/**
1130
	 * This test creates an enabled tracepoint that starts with commands, condition and passcount
1131
	 */
1132
	@Test
1133
	public void createTracepointEnabledWithCommandsConditionPasscount() throws Throwable {
1134
		Map<String, Object> attributes = null;
1135
		int index = 0;
1136
		
1137
		// First tracepoint will be a slow tracepoint
1138
		attributes = new HashMap<String, Object>();
1139
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1140
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1141
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
1142
		attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[0].getName());
1143
		attributes.put(MIBreakpoints.CONDITION, CONDITIONS[0]);
1144
		attributes.put(MIBreakpoints.IS_ENABLED, true);
1145
		attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[0]);
1146
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1147
1148
		waitForBreakpointEvent();
1149
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1150
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1151
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1152
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1153
		clearEventCounters();
1154
1155
		// Second tracepoint will be a fast tracepoint
1156
		attributes = new HashMap<String, Object>();
1157
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1158
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1159
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
1160
		attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[1].getName());
1161
		attributes.put(MIBreakpoints.CONDITION, CONDITIONS[1]);
1162
		attributes.put(MIBreakpoints.IS_ENABLED, true);
1163
		attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[1]);
1164
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1165
1166
		waitForBreakpointEvent();
1167
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1168
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1169
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1170
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1171
		clearEventCounters();		
810
1172
1173
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
1174
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, CONDITIONS[0], PASS_COUNTS[0], true, COLLECT_ACTIONS[0].toString(), false));
1175
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, CONDITIONS[1], PASS_COUNTS[1], true, COLLECT_ACTIONS[1].toString(), true));
1176
		
1177
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
1178
	}
1179
	
811
	/**
1180
	/**
812
	 * This test sets a tracepoint and then gives it a condition
1181
	 * This test creates a disabled tracepoint that starts with commands, condition and passcount
813
	 */
1182
	 */
814
	//@Test
1183
	@Test
815
	public void testTracepointCondition() throws Throwable {
1184
	public void createTracepointDisabledWithCommandsConditionPasscount() throws Throwable {
816
		// Use trace state variables and stuff
1185
		Map<String, Object> attributes = null;
1186
		int index = 0;
1187
		
1188
		// First tracepoint will be a slow tracepoint
1189
		attributes = new HashMap<String, Object>();
1190
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1191
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1192
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
1193
		attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[0].getName());
1194
		attributes.put(MIBreakpoints.CONDITION, CONDITIONS[0]);
1195
		attributes.put(MIBreakpoints.IS_ENABLED, false);
1196
		attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[0]);
1197
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1198
1199
		waitForBreakpointEvent();
1200
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1201
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1202
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1203
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1204
		clearEventCounters();
1205
1206
		// Second tracepoint will be a fast tracepoint
1207
		attributes = new HashMap<String, Object>();
1208
		attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
1209
		attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
1210
		attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
1211
		attributes.put(MIBreakpoints.COMMANDS, COLLECT_ACTIONS[1].getName());
1212
		attributes.put(MIBreakpoints.CONDITION, CONDITIONS[1]);
1213
		attributes.put(MIBreakpoints.IS_ENABLED, false);
1214
		attributes.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[1]);
1215
		fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
1216
1217
		waitForBreakpointEvent();
1218
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
1219
				+ fBreakpointEventCount, fBreakpointEventCount == 1);
1220
		assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
1221
				+ getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
1222
		clearEventCounters();		
1223
1224
		ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
1225
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, CONDITIONS[0], PASS_COUNTS[0], false, COLLECT_ACTIONS[0].toString(), false));
1226
		dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, CONDITIONS[1], PASS_COUNTS[1], false, COLLECT_ACTIONS[1].toString(), true));
1227
		
1228
		checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
817
	}
1229
	}
818
	
1230
	
819
1231
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
//	/**
1232
//	/**
847
//	 * This test sets the different types of tracepoints and then sets some eval actions
1233
//	 * This test sets the different types of tracepoints and then sets some eval actions
848
//	 */
1234
//	 */
(-)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