1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 15:05:36 +02:00

Bug 509812 - Unable to interrupt arm remote target, Neon and GDB 7.12

Setting target-async ON in GDBJtagDSFFinalLaunchSequence_7_7 class 
only when interfacing with the FullGDBConsole.

async mode is required when using the full GDB console in order
to process the suspend MI command "-exec-interrupt" while the target is
running.

Change-Id: I08c382550c6dd8a8567a66169495a9e490c35397
This commit is contained in:
Alvaro Sanchez-Leon 2017-01-09 11:42:22 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent 14b07f490c
commit 625dfd8304
4 changed files with 120 additions and 40 deletions

View file

@ -19,6 +19,7 @@ import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress;
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
@ -36,6 +37,7 @@ public class FinalLaunchSequence_7_12 extends FinalLaunchSequence_7_7 {
private IGDBControl fCommandControl;
private CommandFactory fCommandFactory;
private Map<String, Object> fAttributes;
private IGDBBackend fGdbBackEnd;
public FinalLaunchSequence_7_12(DsfSession session, Map<String, Object> attributes,
RequestMonitorWithProgress rm) {
@ -76,6 +78,8 @@ public class FinalLaunchSequence_7_12 extends FinalLaunchSequence_7_7 {
DsfServicesTracker tracker = new DsfServicesTracker(GdbPlugin.getBundleContext(),
getSession().getId());
fCommandControl = tracker.getService(IGDBControl.class);
fGdbBackEnd = tracker.getService(IGDBBackend.class);
tracker.dispose();
if (fCommandControl == null) {
@ -90,20 +94,37 @@ public class FinalLaunchSequence_7_12 extends FinalLaunchSequence_7_7 {
}
private boolean isNonStop() {
boolean isNonStop = CDebugUtils.getAttribute(fAttributes,
IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP,
LaunchUtils.getIsNonStopModeDefault());
return isNonStop;
}
@Execute
public void stepSetTargetAsync(RequestMonitor requestMonitor) {
// Use target async when interfacing with GDB 7.12 or higher
// this will allow us to use the new enhanced GDB Full CLI console
if (fCommandControl == null || fGdbBackEnd == null) {
requestMonitor.done();
return;
}
// Use target async for non-stop mode or when the
// Full GDB CLI console is being used.
// Otherwise Explicitly set target-async to off
boolean asyncOn = false;
if (isNonStop() || fGdbBackEnd.isFullGdbConsoleSupported()) {
asyncOn = true;
}
fCommandControl.queueCommand(
fCommandFactory.createMIGDBSetTargetAsync(fCommandControl.getContext(), true),
new DataRequestMonitor<MIInfo>(getExecutor(), requestMonitor) {
@Override
protected void handleError() {
// We should only be calling this for GDB >= 7.12,
// but just in case, accept errors for older GDBs
requestMonitor.done();
}
});
fCommandFactory.createMIGDBSetTargetAsync(fCommandControl.getContext(), asyncOn),
new DataRequestMonitor<MIInfo>(getExecutor(), requestMonitor) {
@Override
protected void handleError() {
// Accept errors for older GDBs
requestMonitor.done();
}
});
}
/**
@ -127,15 +148,13 @@ public class FinalLaunchSequence_7_12 extends FinalLaunchSequence_7_7 {
@Override
@Execute
public void stepSetNonStop(final RequestMonitor requestMonitor) {
boolean isNonStop = CDebugUtils.getAttribute(fAttributes,
IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP,
LaunchUtils.getIsNonStopModeDefault());
if (isNonStop) {
if (isNonStop()) {
// GDBs that don't support non-stop don't allow you to set it to false.
// We really should set it to false when GDB supports it though.
// Something to fix later.
// Note that disabling pagination is taken care of elsewhere
// Note: The base class is setting pagination to off, this is only necessary when
// using the Full GDB console (The basic console is started in MI mode and does not paginate)
// When the Full GDB console is used, pagination is set to off when GDB is started.
fCommandControl.queueCommand(
fCommandFactory.createMIGDBSetNonStop(fCommandControl.getContext(), true),
new DataRequestMonitor<MIInfo>(getExecutor(), requestMonitor));

View file

@ -43,6 +43,7 @@ import org.eclipse.core.runtime.jobs.Job;
public class GDBRunControl_7_12 extends GDBRunControl_7_10 {
private IMICommandControl fCommandControl;
private CommandFactory fCommandFactory;
private IGDBBackend fGDBBackEnd;
private Map<String, EnableReverseAtLocOperation> fBpIdToReverseOpMap = new HashMap<>();
public GDBRunControl_7_12(DsfSession session) {
@ -61,6 +62,8 @@ public class GDBRunControl_7_12 extends GDBRunControl_7_10 {
private void doInitialize(final RequestMonitor rm) {
fCommandControl = getServicesTracker().getService(IMICommandControl.class);
fGDBBackEnd = getServicesTracker().getService(IGDBBackend.class);
fCommandFactory = fCommandControl.getCommandFactory();
register(new String[]{ GDBRunControl_7_12.class.getName() },
@ -87,32 +90,48 @@ public class GDBRunControl_7_12 extends GDBRunControl_7_10 {
}
private void doSuspend(IExecutionDMContext context, final RequestMonitor rm) {
// Start the job before sending the interrupt command
// to make sure we don't miss the *stopped event
final MonitorSuspendJob monitorJob = new MonitorSuspendJob(0, rm);
fCommandControl.queueCommand(fCommandFactory.createMIExecInterrupt(context),
new ImmediateDataRequestMonitor<MIInfo>() {
@Override
protected void handleSuccess() {
// Nothing to do in the case of success, the monitoring job
// will take care of completing the RM once it gets the
// *stopped event.
}
// We use the MI interrupt command when working in async mode.
// Since this run control service is specifically for all-stop mode,
// 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
// to make sure we don't miss the *stopped event
final MonitorSuspendJob monitorJob = new MonitorSuspendJob(0, rm);
fCommandControl.queueCommand(fCommandFactory.createMIExecInterrupt(context),
new ImmediateDataRequestMonitor<MIInfo>() {
@Override
protected void handleSuccess() {
// Nothing to do in the case of success, the monitoring job
// will take care of completing the RM once it gets the
// *stopped event.
}
@Override
protected void handleFailure() {
// In case of failure, we must cancel the monitoring job
// and indicate the failure in the rm.
monitorJob.cleanAndCancel();
rm.done(getStatus());
}
});
@Override
protected void handleFailure() {
// In case of failure, we must cancel the monitoring job
// and indicate the failure in the rm.
monitorJob.cleanAndCancel();
rm.done(getStatus());
}
});
} else {
// Asynchronous mode is off
super.suspend(context, rm);
}
}
@Override
public boolean isTargetAcceptingCommands() {
// Async mode is on when running with GDB 7.12 or higher
return true;
// We shall directly return true if the async mode is ON,
// Since this run control service is specifically for all-stop mode,
// The only possibility to be running asynchronously is if the Full GDB console
// is being used.
if (fGDBBackEnd.isFullGdbConsoleSupported()) {
return true;
}
return super.isTargetAcceptingCommands();
}
/**

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* Copyright (c) 2014, 2017 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -15,10 +15,13 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress;
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetDPrintfStyle;
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
@ -75,4 +78,37 @@ public class GDBJtagDSFFinalLaunchSequence_7_7 extends GDBJtagDSFFinalLaunchSequ
});
}
}
@Execute
public void stepSourceGDBInitFile(RequestMonitor rm) {
super.stepSourceGDBInitFile(new RequestMonitor(getExecutor(), rm) {
@Override
protected void handleSuccess() {
// Processing this request after sourcing the gdbinit file to make sure the user
// cannot change this behavior
DsfServicesTracker tracker = new DsfServicesTracker(Activator.getBundleContext(),
getSession().getId());
IMICommandControl commandControl = tracker.getService(IMICommandControl.class);
IGDBBackend gdbBackEnd = tracker.getService(IGDBBackend.class);
tracker.dispose();
if (commandControl != null && gdbBackEnd != null) {
// Use target async when interfacing with the full GDB console (i.e. minimum GDB version 7.12)
// otherwise explicitly set it to off.
commandControl.queueCommand(
commandControl.getCommandFactory().createMIGDBSetTargetAsync(commandControl.getContext(), gdbBackEnd.isFullGdbConsoleSupported()),
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
protected void handleError() {
// Accept errors for older GDBs
rm.done();
}
});
} else {
// Should not happen
rm.done();
}
}
});
}
}

View file

@ -79,7 +79,13 @@ public class DefaultGDBJtagDeviceImpl implements IGDBJtagDevice {
*/
@Override
public void doContinue(Collection<String> commands) {
String cmd = "continue"; //$NON-NLS-1$
// The CLI version "continue" causes GDB to block and would not be
// able to respond other MI commands, this is a problem
// when running in async mode as it depends on the processing
// of MI commands e.g. to suspend the program.
// Therefore we need to use the MI command version "-exec-continue"
// which does not block GDB.
String cmd = "-exec-continue"; //$NON-NLS-1$
addCmd(commands, cmd);
}