Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2017-11-09 18:01:57 +0000
committerJonah Graham2017-11-09 18:40:14 +0000
commit5fd3ddb84de5083e8e092f84a002084cdf9e8ec8 (patch)
treedb6851f99448e3c33a33ab2226b137253914af26
parent5f1962e0682d5fef8ff401c6638d0bb4c71b9a1e (diff)
downloadorg.eclipse.cdt-5fd3ddb84de5083e8e092f84a002084cdf9e8ec8.tar.gz
org.eclipse.cdt-5fd3ddb84de5083e8e092f84a002084cdf9e8ec8.tar.xz
org.eclipse.cdt-5fd3ddb84de5083e8e092f84a002084cdf9e8ec8.zip
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
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF2
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_11.java34
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_12.java9
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java30
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java7
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java7
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MITargetAttach.java37
7 files changed, 114 insertions, 12 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF
index 37857657c84..92d0937552d 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF
@@ -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,
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_11.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_11.java
new file mode 100644
index 00000000000..90f50d3cd3b
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_11.java
@@ -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;
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_12.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_12.java
index 4f996dc8d4d..7cc945a9f9b 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_12.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_12.java
@@ -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;
+ }
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java
index 1a5db0f232e..8be9548cf16 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java
@@ -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;
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java
index 90360caf175..ad1a95584ee 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java
@@ -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);
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java
index 1dedb89d0e1..5c6a15af5a5 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java
@@ -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);
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MITargetAttach.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MITargetAttach.java
index c9f94b0f1db..9da901e7ed8 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MITargetAttach.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MITargetAttach.java
@@ -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;
}
}

Back to the top