1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 507950 - Answer query on MI channel to avoid GDB waiting forever

With GDB 7.12, it is possible to receive queries on the dedicated MI
channel.  This channel is not accessible or shown to the user so if we
don't answer, GDB will wait forever.

This patch blindly answers 'y' to any query on the MI channel unless it
has already been answered automatically (which happens when we don't use
the full console).

Change-Id: I0e208fc3495ce6ba57b3e477661f47e50680fd88
This commit is contained in:
Marc Khouzam 2017-01-23 09:25:41 -05:00
parent 3c20d6f0ea
commit add2a14628
2 changed files with 67 additions and 0 deletions

View file

@ -12,7 +12,10 @@ import java.util.Map;
import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress;
import org.eclipse.cdt.dsf.concurrent.Sequence;
import org.eclipse.cdt.dsf.gdb.launching.FinalLaunchSequence_7_12;
import org.eclipse.cdt.dsf.mi.service.command.AbstractMIControl;
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
import org.eclipse.cdt.dsf.mi.service.command.IEventProcessor;
import org.eclipse.cdt.dsf.mi.service.command.MIRunControlEventProcessor_7_12;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.debug.core.ILaunchConfiguration;
@ -29,4 +32,10 @@ public class GDBControl_7_12 extends GDBControl_7_7 {
protected Sequence getCompleteInitializationSequence(Map<String, Object> attributes, RequestMonitorWithProgress rm) {
return new FinalLaunchSequence_7_12(getSession(), attributes, rm);
}
@Override
protected IEventProcessor createMIRunControlEventProcessor(AbstractMIControl connection, ICommandControlDMContext controlDmc) {
return new MIRunControlEventProcessor_7_12(connection, controlDmc);
}
}

View file

@ -0,0 +1,58 @@
/*******************************************************************************
* Copyright (c) 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
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.cdt.dsf.mi.service.command;
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
import org.eclipse.cdt.dsf.mi.service.command.commands.RawCommand;
import org.eclipse.cdt.dsf.mi.service.command.output.MIConsoleStreamOutput;
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.MIOOBRecord;
import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput;
/**
* Listens to events on the MI channel and takes proper action.
* Specialization for GDB 7.12.
*
* @since 5.3
*/
public class MIRunControlEventProcessor_7_12 extends MIRunControlEventProcessor_7_0
{
private final AbstractMIControl fCommandControl;
private final ICommandControlDMContext fControlDmc;
public MIRunControlEventProcessor_7_12(AbstractMIControl connection, ICommandControlDMContext controlDmc) {
super(connection, controlDmc);
fCommandControl = connection;
fControlDmc = controlDmc;
}
@Override
public void eventReceived(Object output) {
for (MIOOBRecord oobr : ((MIOutput)output).getMIOOBRecords()) {
if (oobr instanceof MIConsoleStreamOutput) {
MIConsoleStreamOutput stream = (MIConsoleStreamOutput) oobr;
if (stream.getCString().indexOf("(y or n)") != -1 && //$NON-NLS-1$
stream.getCString().indexOf("[answered ") == -1) {//$NON-NLS-1$
// We have a query on MI that was not automatically answered by GDB!.
// That is not something GDB should do.
// The user cannot answer since it is on MI, so we need to answer
// ourselves. If we don't GDB will hang forever, waiting for that
// answer. We always answer 'yes' although
// we can't be sure it is the right answer, but it is better
// than simply hanging there forever.
fCommandControl.queueCommand(new RawCommand(fControlDmc, "y"), //$NON-NLS-1$
new ImmediateDataRequestMonitor<MIInfo>());
}
}
}
super.eventReceived(output);
}
}