mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Bug 522367: prevent hang of -target-attach on Ubuntu 16.04 / GDB 7.11
-target-attach on Ubuntu 16.04 / GDB 7.11 does not flush its error response, leaving CDT hanging in final launch sequence. Sending a newline to GDB after the target-attach causes GDB to flush the buffer so CDT sees the error. Change-Id: I8816ac6c88eeaffc6d243ebdae9eb347cfdc5cf0
This commit is contained in:
parent
5f1962e068
commit
5fd3ddb84d
7 changed files with 114 additions and 12 deletions
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: %pluginName
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true
|
||||
Bundle-Version: 5.3.0.qualifier
|
||||
Bundle-Version: 5.4.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Kichwa Coders 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
|
||||
*
|
||||
* Contributors:
|
||||
* Kichwa Coders - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.service;
|
||||
|
||||
import org.eclipse.cdt.dsf.mi.service.IMIRunControl;
|
||||
import org.eclipse.cdt.dsf.mi.service.IMIRunControl.MIRunMode;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
|
||||
/**
|
||||
* @since 5.4
|
||||
*/
|
||||
public class GDBProcesses_7_11 extends GDBProcesses_7_10 {
|
||||
|
||||
public GDBProcesses_7_11(DsfSession session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean targetAttachRequiresTrailingNewline() {
|
||||
IMIRunControl runControl = getServicesTracker().getService(IMIRunControl.class);
|
||||
if (runControl != null && runControl.getRunMode() == MIRunMode.NON_STOP) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Ericsson and others.
|
||||
* Copyright (c) 2016, 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
|
||||
|
@ -29,7 +29,7 @@ import org.eclipse.core.runtime.Status;
|
|||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
public class GDBProcesses_7_12 extends GDBProcesses_7_10 {
|
||||
public class GDBProcesses_7_12 extends GDBProcesses_7_11 {
|
||||
|
||||
public GDBProcesses_7_12(DsfSession session) {
|
||||
super(session);
|
||||
|
@ -120,4 +120,9 @@ public class GDBProcesses_7_12 extends GDBProcesses_7_10 {
|
|||
super.detachDebuggerFromProcess(dmc, rm);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean targetAttachRequiresTrailingNewline() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010, 2016 TUBITAK BILGEM-ITI and others.
|
||||
* Copyright (c) 2010, 2017 TUBITAK BILGEM-ITI 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
|
||||
|
@ -40,6 +40,7 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
|||
import org.eclipse.cdt.dsf.debug.service.IRunControl.ICreatedDMEvent;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExitedDMEvent;
|
||||
import org.eclipse.cdt.dsf.debug.service.command.ICommand;
|
||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
|
||||
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
|
||||
|
@ -445,10 +446,14 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 implements IMultiTerminat
|
|||
shouldInterrupt = false;
|
||||
}
|
||||
|
||||
fCommandControl.queueCommand(
|
||||
fCommandFactory.createMITargetAttach(fContainerDmc, ((IMIProcessDMContext)procCtx).getProcId(), shouldInterrupt),
|
||||
new ImmediateDataRequestMonitor<MIInfo>(rm));
|
||||
}
|
||||
boolean extraNewline = targetAttachRequiresTrailingNewline();
|
||||
ICommand<MIInfo> miTargetAttach = fCommandFactory.createMITargetAttach(fContainerDmc,
|
||||
((IMIProcessDMContext) procCtx).getProcId(), shouldInterrupt, extraNewline);
|
||||
fCommandControl.queueCommand(
|
||||
miTargetAttach,
|
||||
new ImmediateDataRequestMonitor<MIInfo>(rm));
|
||||
}
|
||||
|
||||
},
|
||||
// Initialize memory data for this process.
|
||||
new Step() {
|
||||
|
@ -498,7 +503,20 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 implements IMultiTerminat
|
|||
dataRm.done();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GDB 7.11 had a bug that -target-attach sometimes did not flush its error
|
||||
* response. However sending a newline forced GDB to flush the buffer.
|
||||
*
|
||||
* See Bug 522367
|
||||
*
|
||||
* @return whether to add extra newline.
|
||||
* @since 5.4
|
||||
*/
|
||||
protected boolean targetAttachRequiresTrailingNewline() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void connectToTarget(IProcessDMContext procCtx, RequestMonitor rm) {
|
||||
ILaunch launch = procCtx.getAdapter(ILaunch.class);
|
||||
assert launch != null;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2016 Ericsson and others.
|
||||
* Copyright (c) 2008, 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
|
||||
|
@ -91,6 +91,8 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
|
|||
public static final String GDB_7_7_VERSION = "7.7"; //$NON-NLS-1$
|
||||
/** @since 4.8 */
|
||||
public static final String GDB_7_10_VERSION = "7.10"; //$NON-NLS-1$
|
||||
/** @since 5.4 */
|
||||
public static final String GDB_7_11_VERSION = "7.11"; //$NON-NLS-1$
|
||||
/** @since 5.2 */
|
||||
public static final String GDB_7_12_VERSION = "7.12"; //$NON-NLS-1$
|
||||
|
||||
|
@ -282,6 +284,9 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
|
|||
if (compareVersionWith(GDB_7_12_VERSION) >= 0) {
|
||||
return new GDBProcesses_7_12(session);
|
||||
}
|
||||
if (compareVersionWith(GDB_7_11_VERSION) >= 0) {
|
||||
return new GDBProcesses_7_11(session);
|
||||
}
|
||||
if (compareVersionWith(GDB_7_10_VERSION) >= 0) {
|
||||
return new GDBProcesses_7_10(session);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2016 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2017 QNX Software Systems 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
|
||||
|
@ -988,6 +988,11 @@ public class CommandFactory {
|
|||
return new MITargetAttach(ctx, groupId, interrupt);
|
||||
}
|
||||
|
||||
/** @since 5.4 */
|
||||
public ICommand<MIInfo> createMITargetAttach(IMIContainerDMContext ctx, String groupId, boolean interrupt, boolean extraNewline) {
|
||||
return new MITargetAttach(ctx, groupId, interrupt, extraNewline);
|
||||
}
|
||||
|
||||
public ICommand<MIInfo> createMITargetDetach(ICommandControlDMContext ctx, String groupId) {
|
||||
return new MITargetDetach(ctx, groupId);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2015 Ericsson and others.
|
||||
* Copyright (c) 2008, 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
|
||||
|
@ -12,6 +12,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.mi.service.command.commands;
|
||||
|
||||
import org.eclipse.cdt.dsf.gdb.service.GDBProcesses_7_2;
|
||||
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
||||
|
||||
|
@ -25,6 +26,8 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
|||
* @since 1.1
|
||||
*/
|
||||
public class MITargetAttach extends MICommand<MIInfo> {
|
||||
private boolean extraNewline;
|
||||
|
||||
/**
|
||||
* @param ctx indicates which inferior should be used when doing the attach
|
||||
* @param id the pid of the process to attach to
|
||||
|
@ -45,6 +48,38 @@ public class MITargetAttach extends MICommand<MIInfo> {
|
|||
* @since 4.0
|
||||
*/
|
||||
public MITargetAttach(IMIContainerDMContext ctx, String pid, boolean interrupt) {
|
||||
this(ctx, pid, interrupt, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ctx indicates which inferior should be used when doing the attach
|
||||
* @param id the pid of the process to attach to
|
||||
* @param interrupt indicates if the process should be interrupted once the attach is done
|
||||
* Leaving the process running is only support with target-async on, which
|
||||
* we currently only use in non-stop mode
|
||||
* @param extraNewline force an extra newline
|
||||
* @since 5.4
|
||||
*/
|
||||
public MITargetAttach(IMIContainerDMContext ctx, String pid, boolean interrupt, boolean extraNewline) {
|
||||
super(ctx, "-target-attach", new String[] { pid + (interrupt ? "" : "&") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
this.extraNewline = extraNewline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an extra newline to force GDB 7.11 to flush error response to the MI channel.
|
||||
* @see GDBProcesses_7_2#targetAttachRequiresTrailingNewline
|
||||
*/
|
||||
@Override
|
||||
public String constructCommand(String groupId, String threadId, int frameId) {
|
||||
/*
|
||||
* We need to add the newline in constructCommand because the newline has to be
|
||||
* after the parameters. The newline can't be added as a parameter because
|
||||
* parameters are trimmed before being added to the command.
|
||||
*/
|
||||
String command = super.constructCommand(groupId, threadId, frameId);
|
||||
if (extraNewline) {
|
||||
command += "\n"; //$NON-NLS-1$
|
||||
}
|
||||
return command;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue