diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_12.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_12.java index 5c8712cf175..d777330e800 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_12.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_12.java @@ -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 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); + } + } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor_7_12.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor_7_12.java new file mode 100644 index 00000000000..dd268976cce --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor_7_12.java @@ -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()); + } + } + } + + super.eventReceived(output); + } +}