[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Second part of PR 43496
|
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.179
diff -u -r1.179 ChangeLog
--- ChangeLog 25 Sep 2003 16:05:22 -0000 1.179
+++ ChangeLog 26 Sep 2003 16:56:30 -0000
@@ -1,3 +1,11 @@
+2003-09-26 Alain Magloire
+
+ Second part of PR 43496.
+ On the startup of GDB, we have to wait for "(gdb)" prompt
+ to make sure that gdb is ready to accept command.
+
+ * src/org/eclipse/cdt/debug/mi/core/MIPlugin.java
+
2003-09-25 Alain Magloire
Fix for PR 43496.
Index: src/org/eclipse/cdt/debug/mi/core/MIPlugin.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java,v
retrieving revision 1.42
diff -u -r1.42 MIPlugin.java
--- src/org/eclipse/cdt/debug/mi/core/MIPlugin.java 25 Sep 2003 16:04:49 -0000 1.42
+++ src/org/eclipse/cdt/debug/mi/core/MIPlugin.java 26 Sep 2003 16:56:31 -0000
@@ -4,8 +4,12 @@
*/
package org.eclipse.cdt.debug.mi.core;
+import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
import java.text.MessageFormat;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
@@ -131,7 +135,8 @@
}
}
- Process pgdb = ProcessFactory.getFactory().exec(args);
+ Process pgdb = getGDBProcess(args, program);
+
MISession session;
try {
session = createMISession(pgdb, pty, MISession.PROGRAM);
@@ -181,7 +186,7 @@
} else {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", "-c", core.getAbsolutePath(), program.getAbsolutePath()};
}
- Process pgdb = ProcessFactory.getFactory().exec(args);
+ Process pgdb = getGDBProcess(args, program);
MISession session;
try {
session = createMISession(pgdb, null, MISession.CORE);
@@ -214,7 +219,7 @@
} else {
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", program.getAbsolutePath()};
}
- Process pgdb = ProcessFactory.getFactory().exec(args);
+ Process pgdb = getGDBProcess(args, program);
MISession session;
try {
session = createMISession(pgdb, null, MISession.ATTACH);
@@ -281,6 +286,79 @@
System.err.println(message);
}
}
+ }
+
+ /**
+ * Retrieve the session timeout.
+ *
+ * Allow at least one second per megabyte as a minimum on the timeout
+ * (note one second is an arbitrary choice based on swapping performance).
+ * This is required for loading the symbols from very large programs.
+ */
+ private int getAdjustedTimeout(File program) {
+ Preferences prefs = plugin.getPluginPreferences();
+ int timeout = prefs.getInt(IMIConstants.PREF_REQUEST_TIMEOUT); //milliseconds
+ if(program != null && program.exists()) {
+ long programSize = program.length();
+ int minimumTimeout = (int)(programSize / 1000L);
+ if(timeout < minimumTimeout) {
+ //debugLog("Adjusting timeout from " + timeout + "ms to " + minimumTimeout + "ms");
+ timeout = minimumTimeout;
+ }
+ }
+ return timeout;
+ }
+
+ /**
+ * Do some basic synchronisation, gdb make take some time to load
+ * for whatever reasons.
+ * @param args
+ * @param program
+ * @return Process
+ * @throws IOException
+ */
+ protected Process getGDBProcess(String[] args, File program) throws IOException {
+ final Process pgdb = ProcessFactory.getFactory().exec(args);
+ Thread syncStartup = new Thread("GDB Start") {
+ public void run() {
+ try {
+ String line;
+ InputStream stream = pgdb.getInputStream();
+ Reader r = new InputStreamReader(stream);
+ BufferedReader reader = new BufferedReader(r);
+ while ((line = reader.readLine()) != null) {
+ line = line.trim();
+ //System.out.println("GDB " + line);
+ if (line.startsWith("(gdb)")) {
+ break;
+ }
+ }
+ } catch (Exception e) {
+ // Do nothing
+ }
+ synchronized (pgdb) {
+ pgdb.notifyAll();
+ }
+ }
+ };
+ syncStartup.start();
+
+ synchronized (pgdb) {
+ int timeout = getAdjustedTimeout(program);
+ while (syncStartup.isAlive()) {
+ try {
+ pgdb.wait(timeout);
+ break;
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ try {
+ syncStartup.interrupt();
+ syncStartup.join(1000);
+ } catch (InterruptedException e) {
+ }
+ return pgdb;
}
/* (non-Javadoc)
Index: src/org/eclipse/cdt/debug/mi/core/RxThread.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/RxThread.java,v
retrieving revision 1.45
diff -u -r1.45 RxThread.java
--- src/org/eclipse/cdt/debug/mi/core/RxThread.java 19 Aug 2003 02:01:53 -0000 1.45
+++ src/org/eclipse/cdt/debug/mi/core/RxThread.java 26 Sep 2003 16:56:31 -0000
@@ -84,8 +84,8 @@
if (session.getChannelInputStream() != null) {
Runnable cleanup = new Runnable() {
public void run() {
- // Change the state of the inferior.
- session.getMIInferior().setTerminated();
+ // Change the state of the inferior.
+ session.getMIInferior().setTerminated();
session.terminate();
}
};
- Prev by Date:
Re: [cdt-patch] Fixes for 43099, 43100, 42400, 42717
- Next by Date:
Re: [cdt-patch] Fixes for 43099, 43100, 42400, 42717
- Previous by thread:
[cdt-patch] Fixes for 43099, 43100, 42400, 42717
- Next by thread:
Applied: [cdt-patch] Fixes for 43099, 43100, 42400, 42717
- Index(es):