[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [cdt-patch] Debug timeout and cleanup patch.
|
Here is a cleaner, more complete patch to address these two PR's
(again at least partially). It would be great to get some feedback
on these patches to determine what course of action needs to be
taken in order to get these applied. This is a rather pressing
concern for several of our customers with large projects.
Thanks,
Thomas
-----Original Message-----
From: Thomas Fletcher [mailto:ThomasF@xxxxxxx]
Sent: Tuesday, September 23, 2003 9:07 AM
To: 'cdt-patch@xxxxxxxxxxx'
Subject: RE: [cdt-patch] Debug timeout and cleanup patch.
Incidentally there are related PRs on this already:
PR 39758 - Request for a change in the timeout behaviour (improved by this
patch).
PR 43496 - Describes the problem of having gdb processes not properly
terminated.
This patch helps the situation of both.
Thomas
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.41
diff -u -r1.41 MIPlugin.java
--- src/org/eclipse/cdt/debug/mi/core/MIPlugin.java 10 Jul 2003 19:25:10 -0000 1.41
+++ src/org/eclipse/cdt/debug/mi/core/MIPlugin.java 23 Sep 2003 14:42:26 -0000
@@ -132,7 +132,19 @@
}
Process pgdb = ProcessFactory.getFactory().exec(args);
- MISession session = createMISession(pgdb, pty, MISession.PROGRAM);
+
+ int timeout = getAdjustedTimeout(program);
+
+ //If anything goes wrong during this time we need to destroy the process
+ //since if the session isn't around there isn't anything to reap it.
+ MISession session = null;
+ try {
+ session = createMISession(pgdb, pty, timeout, MISession.PROGRAM);
+ } catch(MIException ex){
+ pgdb.destroy();
+ throw ex;
+ }
+
// Try to detect if we have been attach via "target remote localhost:port"
// and set the state to be suspended.
try {
@@ -149,6 +161,7 @@
// If an exception is thrown that means ok
// we did not attach to any target.
}
+
return new Session(session, false);
}
@@ -175,7 +188,19 @@
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", "-c", core.getAbsolutePath(), program.getAbsolutePath()};
}
Process pgdb = ProcessFactory.getFactory().exec(args);
- MISession session = createMISession(pgdb, null, MISession.CORE);
+
+ int timeout = getAdjustedTimeout(program);
+
+ //If anything goes wrong during this time we need to destroy the process
+ //since if the session isn't around there isn't anything to reap it.
+ MISession session = null;
+ try {
+ session = createMISession(pgdb, null, timeout, MISession.CORE);
+ } catch(MIException ex){
+ pgdb.destroy();
+ throw ex;
+ }
+
return new Session(session);
}
@@ -202,28 +227,69 @@
args = new String[] {gdb, "--cd="+cwd.getAbsolutePath(), "--command="+gdbinit, "--quiet", "-nw", "-i", "mi1", program.getAbsolutePath()};
}
Process pgdb = ProcessFactory.getFactory().exec(args);
- MISession session = createMISession(pgdb, null, MISession.ATTACH);
- CommandFactory factory = session.getCommandFactory();
- if (targetParams != null && targetParams.length > 0) {
- MITargetSelect target = factory.createMITargetSelect(targetParams);
- session.postCommand(target);
- MIInfo info = target.getMIInfo();
- if (info == null) {
- throw new MIException("No answer");
- }
+
+ int timeout = getAdjustedTimeout(program);
+
+ //If anything goes wrong during this time we need to destroy the process
+ //since if the session isn't around there isn't anything to reap it.
+ MISession session = null;
+ try {
+ session = createMISession(pgdb, null, timeout, MISession.ATTACH);
+ } catch(MIException ex){
+ pgdb.destroy();
+ throw ex;
}
- if (pid > 0) {
- MITargetAttach attach = factory.createMITargetAttach(pid);
- session.postCommand(attach);
- MIInfo info = attach.getMIInfo();
- if (info == null) {
- throw new MIException("No answer");
+
+ try {
+ CommandFactory factory = session.getCommandFactory();
+ if (targetParams != null && targetParams.length > 0) {
+ MITargetSelect target = factory.createMITargetSelect(targetParams);
+ session.postCommand(target);
+ MIInfo info = target.getMIInfo();
+ if (info == null) {
+ throw new MIException("No answer");
+ }
}
+ if (pid > 0) {
+ MITargetAttach attach = factory.createMITargetAttach(pid);
+ session.postCommand(attach);
+ MIInfo info = attach.getMIInfo();
+ if (info == null) {
+ throw new MIException("No answer");
+ }
+ }
+ //@@@ We have to manually set the suspended state when we attach
+ session.getMIInferior().setSuspended();
+ session.getMIInferior().update();
+ } catch(MIException ex) {
+ session.terminate();
+ throw ex;
}
- //@@@ We have to manually set the suspended state when we attach
- session.getMIInferior().setSuspended();
- session.getMIInferior().update();
+
return new Session(session, true);
+ }
+
+ /**
+ * 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;
}
/**