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 280631 | Differences between
and this patch

Collapse All | Expand All

(-)contexts_CDT_DEBUGGER_DSFGDB.xml (+3 lines)
Lines 15-20 Link Here
15
   <description>Control the behavior of the C/C++ debugger when debugging with GDB, specifically when using a GDB (DSF) launcher.</description>
15
   <description>Control the behavior of the C/C++ debugger when debugging with GDB, specifically when using a GDB (DSF) launcher.</description>
16
   <topic href="reference/cdt_u_dsfgdb.htm" label="GDB Preferences"/>
16
   <topic href="reference/cdt_u_dsfgdb.htm" label="GDB Preferences"/>
17
</context>
17
</context>
18
<context id="update_threadlist_button_context" title="About this checkbox">
19
   <description>This checkbox controls whether the CDT debugger will ask gdb for the target program&apos;s thread list on each suspend event (breakpoint-hit, step, etc). Normally, this isn&apos;t necessary, as GDB sends notifications in realtime when a thread is created or destroyed. However, some lightweight GDB remote stubs won&apos;t send these notifications. As such, the CDT debugger doesn&apos;t find out about new or destroyed threads unless it polls gdb. Turn on this option if you are debugging such a target (typically an embedded one).</description>
20
</context>
18
21
19
22
20
</contexts>
23
</contexts>
(-)src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java (-1 / +13 lines)
Lines 83-88 Link Here
83
	public static final String ATTR_DEBUGGER_REVERSE = GdbPlugin.PLUGIN_ID + ".REVERSE"; //$NON-NLS-1$
83
	public static final String ATTR_DEBUGGER_REVERSE = GdbPlugin.PLUGIN_ID + ".REVERSE"; //$NON-NLS-1$
84
84
85
	/**
85
	/**
86
	 * Launch configuration attribute key. Boolean value. See
87
	 * IGDBBackend.getUpdateThreadListOnSuspend()
	 * @since 3.0
88
	 */
89
	public static final String ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND = GdbPlugin.PLUGIN_ID + ".UPDATE_THREADLIST_ON_SUSPEND"; //$NON-NLS-1$
90
91
	/**
86
	 * Launch configuration attribute value. The key is ATTR_DEBUG_NAME.
92
	 * Launch configuration attribute value. The key is ATTR_DEBUG_NAME.
87
	 */
93
	 */
88
	public static final String DEBUGGER_DEBUG_NAME_DEFAULT = "gdb"; //$NON-NLS-1$
94
	public static final String DEBUGGER_DEBUG_NAME_DEFAULT = "gdb"; //$NON-NLS-1$
Lines 114-117 Link Here
114
	 * @since 2.0
120
	 * @since 2.0
115
	 */
121
	 */
116
	public static final boolean DEBUGGER_REVERSE_DEFAULT = false;
122
	public static final boolean DEBUGGER_REVERSE_DEFAULT = false;
117
}
123
	
124
	/**
125
	 * Launch configuration attribute value. The key is ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND
126
	 * @since 3.0
127
	 */
128
	public static final boolean DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT = false;
129
}
(-)src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java (+8 lines)
Lines 335-340 Link Here
335
		return !fLaunchConfiguration.getAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, true);
335
		return !fLaunchConfiguration.getAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, true);
336
	}
336
	}
337
	
337
	
338
	/** @since 3.0 */
339
	public boolean getUpdateThreadListOnSuspend() throws CoreException {
340
		return fLaunchConfiguration
341
				.getAttribute(
342
						IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND,
343
						IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT);
344
	}
345
	
338
	/*
346
	/*
339
	 * Launch GDB process. 
347
	 * Launch GDB process. 
340
	 * Allow subclass to override.
348
	 * Allow subclass to override.
(-)src/org/eclipse/cdt/dsf/gdb/service/IGDBBackend.java (+14 lines)
Lines 133-136 Link Here
133
	 * @return true if the ongoing session is attaching to a remote target.
133
	 * @return true if the ongoing session is attaching to a remote target.
134
	 */	
134
	 */	
135
	public boolean getIsAttachSession();
135
	public boolean getIsAttachSession();
136
137
	/**
138
	 * Indicates whether the CDT debugger should ask gdb for the target
139
	 * program's thread list on each suspend event (breakpoint-hit, step, etc).
140
	 * Normally, this isn't necessary, as GDB sends notifications in realtime
141
	 * when a thread is created or destroyed. However, some lightweight GDB
142
	 * remote stubs won't send these notifications. As such, the CDT debugger
143
	 * doesn't find out about new or destroyed threads unless it polls gdb. The
144
	 * user will enable this behavior if he is debugging such a target
145
	 * (typically an embedded one)
146
	 * 
147
	 * @since 3.0
148
	 */
149
	public boolean getUpdateThreadListOnSuspend() throws CoreException;
136
}
150
}
(-)src/org/eclipse/cdt/dsf/mi/service/MIProcesses.java (+15 lines)
Lines 33-38 Link Here
33
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
33
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
34
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
34
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
35
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
35
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
36
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
36
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
37
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
37
import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoThreadsInfo;
38
import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoThreadsInfo;
38
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
39
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
Lines 40-45 Link Here
40
import org.eclipse.cdt.dsf.service.AbstractDsfService;
41
import org.eclipse.cdt.dsf.service.AbstractDsfService;
41
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
42
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
42
import org.eclipse.cdt.dsf.service.DsfSession;
43
import org.eclipse.cdt.dsf.service.DsfSession;
44
import org.eclipse.core.runtime.CoreException;
43
import org.eclipse.core.runtime.IStatus;
45
import org.eclipse.core.runtime.IStatus;
44
import org.eclipse.core.runtime.Status;
46
import org.eclipse.core.runtime.Status;
45
import org.osgi.framework.BundleContext;
47
import org.osgi.framework.BundleContext;
Lines 305-310 Link Here
305
    private ICommandControlService fCommandControl;
307
    private ICommandControlService fCommandControl;
306
	private CommandCache fContainerCommandCache;
308
	private CommandCache fContainerCommandCache;
307
	private CommandFactory fCommandFactory;
309
	private CommandFactory fCommandFactory;
310
	private IGDBBackend fGdbBackend;
308
311
309
	private static final String FAKE_THREAD_ID = "0"; //$NON-NLS-1$
312
	private static final String FAKE_THREAD_ID = "0"; //$NON-NLS-1$
310
	// The unique id should be an empty string so that the views know not to display the fake id
313
	// The unique id should be an empty string so that the views know not to display the fake id
Lines 350-355 Link Here
350
		
353
		
351
		fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
354
		fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
352
		
355
		
356
		fGdbBackend = getServicesTracker().getService(IGDBBackend.class);
357
		
353
		// This cache stores the result of a command when received; also, this cache
358
		// This cache stores the result of a command when received; also, this cache
354
		// is manipulated when receiving events.  Currently, events are received after
359
		// is manipulated when receiving events.  Currently, events are received after
355
		// three scheduling of the executor, while command results after only one.  This
360
		// three scheduling of the executor, while command results after only one.  This
Lines 641-646 Link Here
641
       	if (e instanceof IContainerSuspendedDMEvent) {
646
       	if (e instanceof IContainerSuspendedDMEvent) {
642
    		// This will happen in all-stop mode
647
    		// This will happen in all-stop mode
643
       		fContainerCommandCache.setContextAvailable(e.getDMContext(), true);
648
       		fContainerCommandCache.setContextAvailable(e.getDMContext(), true);
649
       		
650
			// If user is debugging a gdb target that doesn't send thread
651
			// creation events, make sure we don't use cached thread
652
			// information. Reset the cache after every suspend. See bugzilla
653
			// 280631
654
       		try {
655
				if (fGdbBackend.getUpdateThreadListOnSuspend()) {
656
					fContainerCommandCache.reset(e.getDMContext());
657
				}
658
			} catch (CoreException exc) {}
644
       	} else {
659
       	} else {
645
       		// This will happen in non-stop mode
660
       		// This will happen in non-stop mode
646
       	}
661
       	}
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java (-51 / +56 lines)
Lines 17-22 Link Here
17
17
18
import org.eclipse.cdt.debug.ui.AbstractCDebuggerPage;
18
import org.eclipse.cdt.debug.ui.AbstractCDebuggerPage;
19
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
19
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
20
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
20
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
21
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.ILaunchConfiguration;
Lines 36-41 Link Here
36
import org.eclipse.swt.widgets.TabFolder;
37
import org.eclipse.swt.widgets.TabFolder;
37
import org.eclipse.swt.widgets.TabItem;
38
import org.eclipse.swt.widgets.TabItem;
38
import org.eclipse.swt.widgets.Text;
39
import org.eclipse.swt.widgets.Text;
40
import org.eclipse.ui.PlatformUI;
39
41
40
/**
42
/**
41
 * The dynamic tab for gdb-based debugger implementations.
43
 * The dynamic tab for gdb-based debugger implementations.
Lines 47-52 Link Here
47
	protected Text fGDBInitText;
49
	protected Text fGDBInitText;
48
	protected Button fNonStopCheckBox;
50
	protected Button fNonStopCheckBox;
49
	protected Button fReverseCheckBox;
51
	protected Button fReverseCheckBox;
52
	protected Button fUpdateThreadlistOnSuspend;
50
53
51
	private IMILaunchConfigurationComponent fSolibBlock;
54
	private IMILaunchConfigurationComponent fSolibBlock;
52
	private boolean fIsInitializing = false;
55
	private boolean fIsInitializing = false;
Lines 71-76 Link Here
71
				                   IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
74
				                   IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
72
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE,
75
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE,
73
                				   IGDBLaunchConfigurationConstants.DEBUGGER_REVERSE_DEFAULT);
76
                				   IGDBLaunchConfigurationConstants.DEBUGGER_REVERSE_DEFAULT);
77
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND,
78
								   IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT);
74
79
75
		if (fSolibBlock != null)
80
		if (fSolibBlock != null)
76
			fSolibBlock.setDefaults(configuration);
81
			fSolibBlock.setDefaults(configuration);
Lines 90-135 Link Here
90
		return valid;
95
		return valid;
91
	}
96
	}
92
97
93
	public void initializeFrom(ILaunchConfiguration configuration) {
98
	/** utility method to cut down on clutter */
94
		setInitializing(true);
99
	private String getStringAttr(ILaunchConfiguration config, String attributeName, String defaultValue) {
95
		String gdbCommand = IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT;
100
		try { 
96
		String gdbInit = IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT;
101
			return config.getAttribute(attributeName, defaultValue);
97
		boolean nonStopMode = IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT;
98
		boolean reverseEnabled = IGDBLaunchConfigurationConstants.DEBUGGER_REVERSE_DEFAULT;
99
100
		try {
101
			gdbCommand = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME,
102
					                                IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT);
103
		}
104
		catch(CoreException e) {
105
		}
106
		try {
107
			gdbInit = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, 
108
					                             IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
109
		}
102
		}
110
		catch(CoreException e) {
103
		catch (CoreException exc) {
104
			return defaultValue;
111
		}
105
		}
112
106
	}
113
		try {
107
	/** utility method to cut down on clutter */
114
			nonStopMode = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP,
108
	private boolean getBooleanAttr(ILaunchConfiguration config, String attributeName, boolean defaultValue) {
115
					                                 IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
109
		try { 
110
			return config.getAttribute(attributeName, defaultValue);
116
		}
111
		}
117
		catch(CoreException e) {
112
		catch (CoreException exc) {
113
			return defaultValue;
118
		}
114
		}
115
	}
116
	
117
	public void initializeFrom(ILaunchConfiguration configuration) {
118
		setInitializing(true);
119
		String gdbCommand = getStringAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME,
120
                				IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT);
121
		String gdbInit = getStringAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, 
122
                			IGDBLaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT); 
123
		boolean nonStopMode = getBooleanAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP,
124
                				IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
125
		boolean reverseEnabled = getBooleanAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE,
126
									IGDBLaunchConfigurationConstants.DEBUGGER_REVERSE_DEFAULT);
127
		boolean updateThreadsOnSuspend = getBooleanAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND,
128
				IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT);
119
		
129
		
120
		try {
121
			reverseEnabled = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE,
122
                    									IGDBLaunchConfigurationConstants.DEBUGGER_REVERSE_DEFAULT);
123
		}
124
		catch(CoreException e) {
125
		}
126
127
		if (fSolibBlock != null)
130
		if (fSolibBlock != null)
128
			fSolibBlock.initializeFrom(configuration);
131
			fSolibBlock.initializeFrom(configuration);
129
		fGDBCommandText.setText(gdbCommand);
132
		fGDBCommandText.setText(gdbCommand);
130
		fGDBInitText.setText(gdbInit);
133
		fGDBInitText.setText(gdbInit);
131
		fNonStopCheckBox.setSelection(nonStopMode);
134
		fNonStopCheckBox.setSelection(nonStopMode);
132
		fReverseCheckBox.setSelection(reverseEnabled);
135
		fReverseCheckBox.setSelection(reverseEnabled);
136
		fUpdateThreadlistOnSuspend.setSelection(updateThreadsOnSuspend);
133
		
137
		
134
		setInitializing(false); 
138
		setInitializing(false); 
135
	}
139
	}
Lines 143-148 Link Here
143
				                   fNonStopCheckBox.getSelection());
147
				                   fNonStopCheckBox.getSelection());
144
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE,
148
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE,
145
                                   fReverseCheckBox.getSelection());
149
                                   fReverseCheckBox.getSelection());
150
		configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND,
151
                fUpdateThreadlistOnSuspend.getSelection());
146
152
147
		if (fSolibBlock != null)
153
		if (fSolibBlock != null)
148
			fSolibBlock.performApply(configuration);
154
			fSolibBlock.performApply(configuration);
Lines 284-315 Link Here
284
		
290
		
285
		// TODO: Ideally, this field should be disabled if the back-end doesn't support non-stop debugging
291
		// TODO: Ideally, this field should be disabled if the back-end doesn't support non-stop debugging
286
		// TODO: Find a way to determine if non-stop is supported (i.e. find the GDB version) then grey out the check box if necessary 
292
		// TODO: Find a way to determine if non-stop is supported (i.e. find the GDB version) then grey out the check box if necessary 
287
		fNonStopCheckBox = ControlFactory.createCheckBox(subComp, LaunchUIMessages.getString("GDBDebuggerPage.nonstop_mode")); //$NON-NLS-1$
293
		fNonStopCheckBox = addCheckbox(subComp, LaunchUIMessages.getString("GDBDebuggerPage.nonstop_mode")); //$NON-NLS-1$
288
		fNonStopCheckBox.addSelectionListener( new SelectionAdapter() {
289
				@Override
290
				public void widgetSelected(SelectionEvent e) {
291
					updateLaunchConfigurationDialog();
292
				}
293
			});
294
294
295
		// TODO: Ideally, this field should be disabled if the back-end doesn't support reverse debugging
295
		// TODO: Ideally, this field should be disabled if the back-end doesn't support reverse debugging
296
		// TODO: Find a way to determine if reverse is supported (i.e. find the GDB version) then grey out the check box if necessary 
296
		// TODO: Find a way to determine if reverse is supported (i.e. find the GDB version) then grey out the check box if necessary 
297
		fReverseCheckBox = ControlFactory.createCheckBox(subComp, LaunchUIMessages.getString("GDBDebuggerPage.reverse_Debugging")); //$NON-NLS-1$
297
		fReverseCheckBox = addCheckbox(subComp, LaunchUIMessages.getString("GDBDebuggerPage.reverse_Debugging")); //$NON-NLS-1$
298
		fReverseCheckBox.addSelectionListener( new SelectionAdapter() {
299
				@Override
300
				public void widgetSelected(SelectionEvent e) {
301
					updateLaunchConfigurationDialog();
302
				}
303
			});
304
298
305
		
299
		fUpdateThreadlistOnSuspend = addCheckbox(subComp, LaunchUIMessages.getString("GDBDebuggerPage.update_thread_list_on_suspend")); //$NON-NLS-1$
306
		// fit options one per line
300
		// This checkbox needs an explanation. Attach context help to it.
307
		gd = new GridData();
301
		PlatformUI.getWorkbench().getHelpSystem().setHelp(fUpdateThreadlistOnSuspend, GdbUIPlugin.PLUGIN_ID + ".update_threadlist_button_context"); //$NON-NLS-1$
308
		gd.horizontalSpan = 3;
309
		fNonStopCheckBox.setLayoutData(gd);
310
		gd = new GridData();
311
		gd.horizontalSpan = 3;
312
		fReverseCheckBox.setLayoutData(gd);
313
	}
302
	}
314
303
315
	public void createSolibTab(TabFolder tabFolder) {
304
	public void createSolibTab(TabFolder tabFolder) {
Lines 323-328 Link Here
323
			((Observable)fSolibBlock).addObserver(this);
312
			((Observable)fSolibBlock).addObserver(this);
324
	}
313
	}
325
314
315
	/** Used to add a checkbox to the tab. Each checkbox has its own line. */
316
	private Button addCheckbox(Composite parent, String label) {
317
		Button button = ControlFactory.createCheckBox(parent, label);
318
		button .addSelectionListener(new SelectionAdapter() {
319
			@Override
320
			public void widgetSelected(SelectionEvent e) {
321
				updateLaunchConfigurationDialog();
322
			}
323
		});
324
		GridData gd = new GridData();
325
		gd.horizontalSpan = 3;
326
		button.setLayoutData(gd);
327
		
328
		return button;
329
	}
330
326
	/*
331
	/*
327
	 * (non-Javadoc)
332
	 * (non-Javadoc)
328
	 * 
333
	 * 
(-)src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties (+1 lines)
Lines 23-28 Link Here
23
GDBDebuggerPage.shared_libraries=Shared Libraries
23
GDBDebuggerPage.shared_libraries=Shared Libraries
24
GDBDebuggerPage.nonstop_mode=Non-stop mode (Note: Requires non-stop GDB)
24
GDBDebuggerPage.nonstop_mode=Non-stop mode (Note: Requires non-stop GDB)
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
StandardGDBDebuggerPage.0=Debugger executable must be specified.
27
StandardGDBDebuggerPage.0=Debugger executable must be specified.
27
StandardGDBDebuggerPage.1=GDB Debugger Options
28
StandardGDBDebuggerPage.1=GDB Debugger Options
28
StandardGDBDebuggerPage.2=Main
29
StandardGDBDebuggerPage.2=Main

Return to bug 280631