1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Bug 516371: Enable GDB target async support for Windows remote debugging

Traditionally CDT used sync debug support all the time. However there
are cases where using target async is better because of GDB missing
interrupt.

This patch expands the cases that use target async to be all
remote targets when using Windows host. That is in addition to
cases when the full GDB Console is supported (new-ui).

Signed-off-by: Muhammad Bilal <hafizbilal100@gmail.com>
Change-Id: I1309d20319a24e4f23543d4ed22735044fd5b811
This commit is contained in:
Muhammad Bilal 2020-12-17 19:57:04 +05:00 committed by Jonah Graham
parent c3c5c2f3ba
commit 5f8fa75f1f
8 changed files with 50 additions and 28 deletions

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.cdt.dsf.gdb" version="2">
<resource path="src/org/eclipse/cdt/dsf/gdb/service/IGDBBackend.java" type="org.eclipse.cdt.dsf.gdb.service.IGDBBackend">
<filter comment="CDT allows new default methods that are unlikely to conflict with existing methods, therefore major version bump is unneeded." id="404000815">
<message_arguments>
<message_argument value="org.eclipse.cdt.dsf.gdb.service.IGDBBackend"/>
<message_argument value="useTargetAsync()"/>
</message_arguments>
</filter>
</resource>
</component>

View file

@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName Bundle-Name: %pluginName
Bundle-Vendor: %providerName Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true
Bundle-Version: 6.1.0.qualifier Bundle-Version: 6.2.0.qualifier
Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin
Bundle-Localization: plugin Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime, Require-Bundle: org.eclipse.core.runtime,

View file

@ -107,11 +107,11 @@ public class FinalLaunchSequence_7_12 extends FinalLaunchSequence_7_7 {
return; return;
} }
// Use target async for non-stop mode or when the // Use target async for non-stop mode or when
// Full GDB CLI console is being used. // it is specifically enabled by backend in all-stop mode
// Otherwise Explicitly set target-async to off // Otherwise Explicitly set target-async to off
boolean asyncOn = false; boolean asyncOn = false;
if (isNonStop() || fGdbBackEnd.isFullGdbConsoleSupported()) { if (isNonStop() || fGdbBackEnd.useTargetAsync()) {
asyncOn = true; asyncOn = true;
} }

View file

@ -63,6 +63,17 @@ public class GDBBackend_7_12 extends GDBBackend {
&& !fPtyFailure; && !fPtyFailure;
} }
/**
* @since 6.2
*/
@Override
public boolean useTargetAsync() {
// Enable target asynchronously if there is Full GDB console as Full GDB Console requires async target or
// If Windows remote debugging as remote debugging in GDB has lots of issues with handling Ctrl-C (See Bug 516371)
return isFullGdbConsoleSupported()
|| (Platform.getOS().equals(Platform.OS_WIN32) && getSessionType() == SessionType.REMOTE);
}
protected void createPty() { protected void createPty() {
if (!isFullGdbConsoleSupported()) { if (!isFullGdbConsoleSupported()) {
return; return;

View file

@ -47,12 +47,12 @@ public class GDBProcesses_7_12 extends GDBProcesses_7_11 {
@Override @Override
public void terminate(IThreadDMContext thread, RequestMonitor rm) { public void terminate(IThreadDMContext thread, RequestMonitor rm) {
IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class); IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
if (!backend.isFullGdbConsoleSupported()) { if (!backend.useTargetAsync()) {
super.terminate(thread, rm); super.terminate(thread, rm);
return; return;
} }
// If we are running the full GDB console, there is a bug with GDB 7.12 // If we are running the target-async support, there is a bug with GDB 7.12
// where after we terminate the process, the GDB prompt does not come // where after we terminate the process, the GDB prompt does not come
// back in the console. As a workaround, we first interrupt the process // back in the console. As a workaround, we first interrupt the process
// to get the prompt back, and only then kill the process. // to get the prompt back, and only then kill the process.
@ -93,12 +93,12 @@ public class GDBProcesses_7_12 extends GDBProcesses_7_11 {
} }
IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class); IGDBBackend backend = getServicesTracker().getService(IGDBBackend.class);
if (!backend.isFullGdbConsoleSupported()) { if (!backend.useTargetAsync()) {
super.detachDebuggerFromProcess(dmc, rm); super.detachDebuggerFromProcess(dmc, rm);
return; return;
} }
// If we are running the full GDB console, there is a bug with GDB 7.12 // If we are running the target-async support, there is a bug with GDB 7.12
// where after we detach the process, the GDB prompt does not come // where after we detach the process, the GDB prompt does not come
// back in the console. As a workaround, we first interrupt the process // back in the console. As a workaround, we first interrupt the process
// to get the prompt back, and only then detach the process. // to get the prompt back, and only then detach the process.

View file

@ -92,10 +92,7 @@ public class GDBRunControl_7_12 extends GDBRunControl_7_10 {
private void doSuspend(IExecutionDMContext context, final RequestMonitor rm) { private void doSuspend(IExecutionDMContext context, final RequestMonitor rm) {
// We use the MI interrupt command when working in async mode. // We use the MI interrupt command when working in async mode.
// Since this run control service is specifically for all-stop mode, if (fGDBBackEnd.useTargetAsync()) {
// the only possibility to be running asynchronously is if the Full GDB console
// is being used.
if (fGDBBackEnd.isFullGdbConsoleSupported()) {
// Start the job before sending the interrupt command // Start the job before sending the interrupt command
// to make sure we don't miss the *stopped event // to make sure we don't miss the *stopped event
final MonitorSuspendJob monitorJob = new MonitorSuspendJob(0, rm); final MonitorSuspendJob monitorJob = new MonitorSuspendJob(0, rm);
@ -124,11 +121,8 @@ public class GDBRunControl_7_12 extends GDBRunControl_7_10 {
@Override @Override
public boolean isTargetAcceptingCommands() { public boolean isTargetAcceptingCommands() {
// We shall directly return true if the async mode is ON, // We shall directly return true if the async mode is ON.
// Since this run control service is specifically for all-stop mode, if (fGDBBackEnd.useTargetAsync()) {
// The only possibility to be running asynchronously is if the Full GDB console
// is being used.
if (fGDBBackEnd.isFullGdbConsoleSupported()) {
return true; return true;
} }

View file

@ -170,6 +170,14 @@ public interface IGDBBackend extends IMIBackend {
return false; return false;
} }
/**
* @return True if CDT should use target async in all-stop mode.
* @since 6.2
*/
default boolean useTargetAsync() {
return false;
}
/** /**
* @return The real GDB process that was started for the debug session * @return The real GDB process that was started for the debug session
* @since 5.2 * @since 5.2

View file

@ -64,17 +64,15 @@ public class GDBJtagDSFFinalLaunchSequence_7_12 extends GDBJtagDSFFinalLaunchSeq
if (commandControl != null && gdbBackEnd != null) { if (commandControl != null && gdbBackEnd != null) {
// Use target async when interfacing with the full GDB console (i.e. minimum GDB version 7.12) // Use target async when interfacing with the full GDB console (i.e. minimum GDB version 7.12)
// otherwise explicitly set it to off. // otherwise explicitly set it to off.
commandControl commandControl.queueCommand(commandControl.getCommandFactory()
.queueCommand( .createMIGDBSetTargetAsync(commandControl.getContext(), gdbBackEnd.useTargetAsync()),
commandControl.getCommandFactory().createMIGDBSetTargetAsync(commandControl.getContext(), new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
gdbBackEnd.isFullGdbConsoleSupported()), @Override
new DataRequestMonitor<MIInfo>(getExecutor(), rm) { protected void handleError() {
@Override // Accept errors for older GDBs
protected void handleError() { rm.done();
// Accept errors for older GDBs }
rm.done(); });
}
});
} else { } else {
// Should not happen // Should not happen
rm.done(); rm.done();