Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Ryall2010-02-03 22:49:21 +0000
committerKen Ryall2010-02-03 22:49:21 +0000
commit65434b8d5a6df3342987c91f6d3693d86e2afc34 (patch)
treeaa76411e558b5bf80ef9d338d2bea79f2edd0e75
parentc8b415d0d5d57a5cc6b0b3ba749c09f2935b892b (diff)
downloadorg.eclipse.cdt-65434b8d5a6df3342987c91f6d3693d86e2afc34.tar.gz
org.eclipse.cdt-65434b8d5a6df3342987c91f6d3693d86e2afc34.tar.xz
org.eclipse.cdt-65434b8d5a6df3342987c91f6d3693d86e2afc34.zip
Bug 294538 - Debug launch takes 20 extra sec (CLI problem)
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOSCLIInfoPID.java83
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOSCLIInfoThreads.java50
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOsCLIInfoThreadsInfo.java77
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/StandardMacOSCommandFactory.java11
4 files changed, 220 insertions, 1 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOSCLIInfoPID.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOSCLIInfoPID.java
new file mode 100644
index 00000000000..d64eccc1a3c
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOSCLIInfoPID.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 ENEA Software AB 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:
+ * ENEA Software AB - CLI command extension - fix for bug 190277
+ * Marc-Andre Laperle - Replace info proc with info pid, patch for bug 294538
+ *******************************************************************************/
+package org.eclipse.cdt.debug.mi.core.command.factories.macos;
+
+import org.eclipse.cdt.debug.mi.core.MIException;
+import org.eclipse.cdt.debug.mi.core.command.CLIInfoProc;
+import org.eclipse.cdt.debug.mi.core.output.CLIInfoProcInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIOutput;
+import org.eclipse.cdt.debug.mi.core.output.MIResult;
+
+/**
+ * GDB/CLI info proc parsing. 18 info pid &"info pid\n"
+ * 18^done,process-id="89643"
+ *
+ */
+class MacOSCLIInfoPID extends CLIInfoProc {
+
+ // apple-gdb doesn't have info proc but has info pid
+ // Since info proc is only used to get the pid, it is valid to use info pid
+ // as a replacement
+ public MacOSCLIInfoPID() {
+ setOperation("info pid"); //$NON-NLS-1$
+ }
+
+ public MIInfo getMIInfo() throws MIException {
+ MIInfo info = null;
+ MIOutput out = getMIOutput();
+ if (out != null) {
+ info = new MacOSCLIInfoPIDOutput(out);
+ if (info.isError()) {
+ throwMIException(info, out);
+ }
+ }
+ return info;
+ }
+
+ class MacOSCLIInfoPIDOutput extends CLIInfoProcInfo {
+
+ int pid;
+
+ public MacOSCLIInfoPIDOutput(MIOutput out) {
+ super(out);
+ parsePID();
+ }
+
+ void parsePID() {
+ if (isDone()) {
+ MIOutput out = getMIOutput();
+ MIResult[] rr = out.getMIResultRecord().getMIResults();
+ for (int i = 0; i < rr.length; i++) {
+ parsePIDLine(rr[i].toString());
+ }
+ }
+ }
+
+ void parsePIDLine(String str) {
+ if (str != null && str.length() > 0) {
+ str = str.trim();
+ if (!str.startsWith("process-id=")) { //$NON-NLS-1$
+ return;
+ }
+
+ pid = Integer.decode(str.substring(12, str.length() - 1))
+ .intValue();
+ }
+ }
+
+ public int getPID() {
+ return pid;
+ }
+
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOSCLIInfoThreads.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOSCLIInfoThreads.java
new file mode 100644
index 00000000000..14fff6498c6
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOSCLIInfoThreads.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Marc-Andre Laperle - use -thread-list-ids for mac, fix for bug 294538
+ *******************************************************************************/
+package org.eclipse.cdt.debug.mi.core.command.factories.macos;
+
+import org.eclipse.cdt.debug.mi.core.MIException;
+import org.eclipse.cdt.debug.mi.core.command.CLIInfoThreads;
+import org.eclipse.cdt.debug.mi.core.output.CLIInfoThreadsInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIOutput;
+
+class MacOSCLIInfoThreads extends CLIInfoThreads {
+ public MacOSCLIInfoThreads() {
+ super();
+ // with apple-gdb, we use -thread-list-ids as a replacement for info
+ // threads
+ setOperation("-thread-list-ids"); //$NON-NLS-1$
+ }
+
+ // MI doesn't work with a space between the token and the
+ // operation, so we override CLICommmand's toString
+ public String toString() {
+ return getToken() + getOperation() + "\n"; //$NON-NLS-1$
+ }
+
+ public MIInfo getMIInfo() throws MIException {
+ MIInfo info = null;
+ MIOutput out = getMIOutput();
+ if (out != null) {
+ info = new MacOsCLIInfoThreadsInfo(out);
+ if (info.isError()) {
+ throwMIException(info, out);
+ }
+ }
+ return info;
+ }
+
+ public CLIInfoThreadsInfo getMIInfoThreadsInfo() throws MIException {
+ return (CLIInfoThreadsInfo) getMIInfo();
+ }
+
+}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOsCLIInfoThreadsInfo.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOsCLIInfoThreadsInfo.java
new file mode 100644
index 00000000000..27f93bb1423
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/MacOsCLIInfoThreadsInfo.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Marc-Andre Laperle - use -thread-list-ids for mac, fix for bug 294538
+ *******************************************************************************/
+package org.eclipse.cdt.debug.mi.core.command.factories.macos;
+
+import java.util.Arrays;
+
+import org.eclipse.cdt.debug.mi.core.output.CLIInfoThreadsInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIConst;
+import org.eclipse.cdt.debug.mi.core.output.MIOutput;
+import org.eclipse.cdt.debug.mi.core.output.MIResult;
+import org.eclipse.cdt.debug.mi.core.output.MIResultRecord;
+import org.eclipse.cdt.debug.mi.core.output.MITuple;
+import org.eclipse.cdt.debug.mi.core.output.MIValue;
+
+/**
+ * This class actually parses -thread-list-ids and converts it to the
+ * CLIInfoThreadsInfo 'format'
+ */
+class MacOsCLIInfoThreadsInfo extends CLIInfoThreadsInfo {
+
+ public MacOsCLIInfoThreadsInfo(MIOutput out) {
+ super(out);
+ }
+
+ protected void parse() {
+ if (isDone()) {
+ MIOutput out = getMIOutput();
+ MIResultRecord rr = out.getMIResultRecord();
+ if (rr != null) {
+ MIResult[] results = rr.getMIResults();
+ for (int i = 0; i < results.length; i++) {
+ String var = results[i].getVariable();
+ if (var.equals("thread-ids")) { //$NON-NLS-1$
+ MIValue val = results[i].getMIValue();
+ if (val instanceof MITuple) {
+ parseThreadIds((MITuple) val);
+ }
+ }
+ }
+ }
+ }
+ if (threadIds == null) {
+ threadIds = new int[0];
+ }
+ Arrays.sort(threadIds);
+ if (threadIds.length > 0) {
+ currentThreadId = threadIds[0];
+ }
+ }
+
+ void parseThreadIds(MITuple tuple) {
+ MIResult[] results = tuple.getMIResults();
+ threadIds = new int[results.length];
+ for (int i = 0; i < results.length; i++) {
+ String var = results[i].getVariable();
+ if (var.equals("thread-id")) { //$NON-NLS-1$
+ MIValue value = results[i].getMIValue();
+ if (value instanceof MIConst) {
+ String str = ((MIConst) value).getCString();
+ try {
+ threadIds[i] = Integer.parseInt(str.trim());
+ } catch (NumberFormatException e) {
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/StandardMacOSCommandFactory.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/StandardMacOSCommandFactory.java
index f2b4065d382..24a1617fd96 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/StandardMacOSCommandFactory.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/factories/macos/StandardMacOSCommandFactory.java
@@ -7,12 +7,14 @@
*
* Contributors:
* Nokia - Initial API and implementation
- * Marc-Andre Laperle - patch for bug #250037
+ * Marc-Andre Laperle - patch for bug #250037, 294538
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.command.factories.macos;
import java.io.File;
+import org.eclipse.cdt.debug.mi.core.command.CLIInfoProc;
+import org.eclipse.cdt.debug.mi.core.command.CLIInfoThreads;
import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentCD;
import org.eclipse.cdt.debug.mi.core.command.MIInfoSharedLibrary;
import org.eclipse.cdt.debug.mi.core.command.MIVarUpdate;
@@ -54,5 +56,12 @@ public class StandardMacOSCommandFactory extends StandardCommandFactory {
return new MacOSMIVarUpdate(getMIVersion(), name);
}
+ public CLIInfoProc createCLIInfoProc() {
+ return new MacOSCLIInfoPID();
+ }
+
+ public CLIInfoThreads createCLIInfoThreads() {
+ return new MacOSCLIInfoThreads();
+ }
}

Back to the top