[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Applied: CDT_1_1 Branch fixes for MI PR 36783
|
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.123
diff -u -r1.123 ChangeLog
--- ChangeLog 23 Apr 2003 17:09:43 -0000 1.123
+++ ChangeLog 29 Apr 2003 20:10:51 -0000
@@ -1,3 +1,37 @@
+2003-04-25 Alain Magloire
+
+ * src/org/eclipse/cdt/debug/mi/core/EventManager.java (update):
+ Remove the call to MIInferior.update(), wrong place.
+ * src/org/eclipse/cdt/debug/mi/core/EventThread.java (run):
+ Call MIInferior.update() when suspended.
+ * src/org/eclipse/cdt/debug/mi/core/MIInferior.java (update):
+ Do not do the call to "info program" for type "attached" sessions.
+ * src/org/eclipse/cdt/debug/mi/core/MISession.java (terminate):
+ When terminate() is call disable posting commands to the queue etc...
+
+2003-04-25 Mikhail Khodjaiants
+
+ Fix for bug 36909.
+ * MIFrame.java:
+ gdb returns "??" as a function name if symbols are not available.
+ Set the function name in this case to "";
+
+2003-04-24 Alain Magloire
+
+ * src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java (createMIInfoProgram):
+ New method.
+ * src/org/eclipse/cdt/debug/mi/core/command/MIInfoProgram.java:
+ New file, "info program".
+ * src/org/eclipse/cdt/debug/mi/core/output/MIInfoProgramInfo.java:
+ New file, parsing of "info Program".
+ * src/org/eclipse/cdt/debug/mi/core/output/EventManager.java (processSuspend):
+ Call MIInferio.update();
+ * src/org/eclipse/cdt/debug/mi/core/MIInferior.java (update):
+ New method to retrieve the pid.
+ (interrupt): Try doing Spawner.raise(pid, INT) as a fallback.
+ * src/org/eclipse/cdt/debug/mi/core/cdi/Configuration.java (supportSuspend):
+ Bug fix.
+
2003-04-23 Alain Magloire
* src/org/eclipse/cdt/debug/mi/core/cdi/SignalManager.java (update):
Index: src/org/eclipse/cdt/debug/mi/core/EventThread.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/EventThread.java,v
retrieving revision 1.4
diff -u -r1.4 EventThread.java
--- src/org/eclipse/cdt/debug/mi/core/EventThread.java 9 Oct 2002 14:08:42 -0000 1.4
+++ src/org/eclipse/cdt/debug/mi/core/EventThread.java 29 Apr 2003 20:10:51 -0000
@@ -6,6 +6,7 @@
package org.eclipse.cdt.debug.mi.core;
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
+import org.eclipse.cdt.debug.mi.core.event.MIStoppedEvent;
/**
* Event Thread blocks on the event Queue, wakes up
@@ -31,6 +32,9 @@
} catch (InterruptedException e) {
//e.printStackTrace();
}
+ if (event instanceof MIStoppedEvent) {
+ processSuspendedEvent((MIStoppedEvent)event);
+ }
try {
if (event != null) {
session.notifyObservers(event);
@@ -40,4 +44,11 @@
}
}
}
+
+ void processSuspendedEvent(MIStoppedEvent stopped) {
+ // give a chance also to the underlying inferior.
+ session.getMIInferior().update();
+
+ }
+
}
Index: src/org/eclipse/cdt/debug/mi/core/MIInferior.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java,v
retrieving revision 1.27
diff -u -r1.27 MIInferior.java
--- src/org/eclipse/cdt/debug/mi/core/MIInferior.java 22 Apr 2003 21:15:57 -0000 1.27
+++ src/org/eclipse/cdt/debug/mi/core/MIInferior.java 29 Apr 2003 20:10:51 -0000
@@ -14,8 +14,10 @@
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIExecAbort;
import org.eclipse.cdt.debug.mi.core.command.MIGDBShowExitCode;
+import org.eclipse.cdt.debug.mi.core.command.MIInfoProgram;
import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent;
import org.eclipse.cdt.debug.mi.core.output.MIGDBShowExitCodeInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIInfoProgramInfo;
import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.cdt.utils.spawner.Spawner;
@@ -43,6 +45,9 @@
PipedOutputStream errPiped;
PTY pty;
+ int inferiorPid;
+
+
MIInferior(MISession mi, PTY p) {
session = mi;
pty = p;
@@ -182,7 +187,17 @@
// Allow (5 secs) for the interrupt to propagate.
for (int i = 0; isRunning() && i < 5; i++) {
try {
- java.lang.Thread.sleep(2000);
+ java.lang.Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ }
+ if (isRunning() && inferiorPid > 0) {
+ // lets try something else.
+ gdbSpawner.raise(inferiorPid, gdbSpawner.INT);
+ }
+ for (int i = 0; isRunning() && i < 5; i++) {
+ try {
+ java.lang.Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
@@ -260,7 +275,7 @@
if (pty != null) {
if (in != null) {
try {
- in.close();
+ in.close();
} catch (IOException e) {
//e.printStackTrace();
}
@@ -291,5 +306,27 @@
public PTY getPTY() {
return pty;
+ }
+
+ public void update() {
+ if (inferiorPid == 0) {
+ // Do not try this on attach session.
+ if (!isConnected()) {
+ // Try to discover the pid
+ CommandFactory factory = session.getCommandFactory();
+ MIInfoProgram prog = factory.createMIInfoProgram();
+ try {
+ session.postCommand(prog);
+ MIInfoProgramInfo info = prog.getMIInfoProgramInfo();
+ inferiorPid = info.getPID();
+ } catch (MIException e) {
+ // no rethrown.
+ }
+ }
+ // We fail permantely.
+ if (inferiorPid == 0) {
+ inferiorPid = -1;
+ }
+ }
}
}
Index: src/org/eclipse/cdt/debug/mi/core/MISession.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java,v
retrieving revision 1.42
diff -u -r1.42 MISession.java
--- src/org/eclipse/cdt/debug/mi/core/MISession.java 22 Apr 2003 20:56:34 -0000 1.42
+++ src/org/eclipse/cdt/debug/mi/core/MISession.java 29 Apr 2003 20:10:51 -0000
@@ -275,9 +275,6 @@
*/
public synchronized void postCommand(Command cmd, long timeout) throws MIException {
- // TRACING: print the command;
- MIPlugin.getDefault().debugLog(cmd.toString());
-
// Test if we are in a sane state.
if (!txThread.isAlive() || !rxThread.isAlive()) {
throw new MIException("{R,T}xThread terminated");
@@ -288,9 +285,17 @@
// REMINDER: if we support -exec-interrupt
// Let it throught:
// if (cmd instanceof MIExecInterrupt) { }
+ // else
throw new MIException("Target is not suspended");
}
+ if (isTerminated()) {
+ throw new MIException("Session terminated");
+ }
+
+ // TRACING: print the command;
+ MIPlugin.getDefault().debugLog(cmd.toString());
+
txQueue.addCommand(cmd);
// Wait for the response or timedout
@@ -364,11 +369,20 @@
OutputStream outGDB = outChannel;
outChannel = null;
+ // Although we will close the pipe(). It is cleaner
+ // to give a chance to gdb to cleanup.
// send the exit(-gdb-exit).
- try {
- MIGDBExit exit = factory.createMIGDBExit();
- postCommand(exit);
- } catch (MIException e) {
+ MIGDBExit exit = factory.createMIGDBExit();
+ txQueue.addCommand(exit);
+
+ // Wait for the response
+ synchronized (exit) {
+ // RxThread will set the MIOutput on the cmd
+ // when the response arrive.
+ try {
+ exit.wait(2000);
+ } catch (InterruptedException e) {
+ }
}
// Make sure gdb is killed.
@@ -446,14 +460,8 @@
} catch (InterruptedException e) {
}
- // Flush the queue.
- queue.clearItems();
-
- // Tell the observers that the session
- // is finish, but we can not use the Event Thread.
- // The Event Thread was kill above.
+ // Tell the observers that the session is terminated
notifyObservers(new MIGDBExitEvent(0));
-
}
/**
Index: src/org/eclipse/cdt/debug/mi/core/cdi/Configuration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Configuration.java,v
retrieving revision 1.9
diff -u -r1.9 Configuration.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/Configuration.java 23 Jan 2003 20:00:36 -0000 1.9
+++ src/org/eclipse/cdt/debug/mi/core/cdi/Configuration.java 29 Apr 2003 20:10:51 -0000
@@ -122,23 +122,25 @@
}
Process gdb = miSession.getGDBProcess();
if (gdb instanceof Spawner) {
- // If we attached sending a control-c, seems to work.
+ // If we attached sending a control-c,
+ // seems to alays work.
if (fAttached) {
return true;
}
// If we have a pty, sending a control-c will work
// except for solaris.
- MIInferior inferior = miSession.getMIInferior();
- if (inferior.getPTY() != null) {
- // FIXME: bug in Solaris gdb when using -tty, sending a control-c
- // does not work.
- if (os.equals("SunOS")) {
+ if (os.equals("SunOS")) {
+ MIInferior inferior = miSession.getMIInferior();
+ if (inferior.getPTY() != null) {
+ // FIXME: bug in Solaris gdb when using -tty, sending a control-c
+ // does not work.
return false;
} else {
return true;
}
}
+ return true;
}
return false;
}
Index: src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java,v
retrieving revision 1.23
diff -u -r1.23 CommandFactory.java
--- src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java 4 Feb 2003 19:14:17 -0000 1.23
+++ src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java 29 Apr 2003 20:10:51 -0000
@@ -293,6 +293,10 @@
return new MIPType(name);
}
+ public MIInfoProgram createMIInfoProgram() {
+ return new MIInfoProgram();
+ }
+
public MIVarCreate createMIVarCreate(String expression) {
return new MIVarCreate(expression);
}
Index: src/org/eclipse/cdt/debug/mi/core/command/MIInfoProgram.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/command/MIInfoProgram.java
diff -N src/org/eclipse/cdt/debug/mi/core/command/MIInfoProgram.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/command/MIInfoProgram.java 29 Apr 2003 20:10:51 -0000
@@ -0,0 +1,40 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+
+package org.eclipse.cdt.debug.mi.core.command;
+
+import org.eclipse.cdt.debug.mi.core.MIException;
+import org.eclipse.cdt.debug.mi.core.output.MIInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIInfoProgramInfo;
+import org.eclipse.cdt.debug.mi.core.output.MIOutput;
+
+/**
+ *
+ * info threads
+ *
+ */
+public class MIInfoProgram extends CLICommand
+{
+ public MIInfoProgram() {
+ super("info program");
+ }
+
+ public MIInfoProgramInfo getMIInfoProgramInfo() throws MIException {
+ return (MIInfoProgramInfo)getMIInfo();
+ }
+
+ public MIInfo getMIInfo() throws MIException {
+ MIInfo info = null;
+ MIOutput out = getMIOutput();
+ if (out != null) {
+ info = new MIInfoProgramInfo(out);
+ if (info.isError()) {
+ throw new MIException(info.getErrorMsg());
+ }
+ }
+ return info;
+ }
+}
Index: src/org/eclipse/cdt/debug/mi/core/output/MIFrame.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIFrame.java,v
retrieving revision 1.6
diff -u -r1.6 MIFrame.java
--- src/org/eclipse/cdt/debug/mi/core/output/MIFrame.java 12 Aug 2002 03:16:56 -0000 1.6
+++ src/org/eclipse/cdt/debug/mi/core/output/MIFrame.java 29 Apr 2003 20:10:52 -0000
@@ -84,7 +84,7 @@
} catch (NumberFormatException e) {
}
} else if (var.equals("func")) {
- func = str;
+ func = ( str != null && str.equals( "??" ) ) ? "" : str;
} else if (var.equals("file")) {
file = str;
} else if (var.equals("line")) {
Index: src/org/eclipse/cdt/debug/mi/core/output/MIInfoProgramInfo.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/mi/core/output/MIInfoProgramInfo.java
diff -N src/org/eclipse/cdt/debug/mi/core/output/MIInfoProgramInfo.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/debug/mi/core/output/MIInfoProgramInfo.java 29 Apr 2003 20:10:52 -0000
@@ -0,0 +1,70 @@
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+package org.eclipse.cdt.debug.mi.core.output;
+
+import java.util.StringTokenizer;
+
+
+/**
+ * GDB/MI info program parsing.
+(gdb)
+info program
+&"info program\n"
+~"\tUsing the running image of child process 21301.\n"
+~"Program stopped at 0x804853f.\n"
+~"It stopped at breakpoint 1.\n"
+~"Type \"info stack\" or \"info registers\" for more information.\n"
+^done
+(gdb)
+
+ */
+public class MIInfoProgramInfo extends MIInfo {
+
+ int pid;
+
+ public MIInfoProgramInfo(MIOutput out) {
+ super(out);
+ parse();
+ }
+
+ public int getPID() {
+ return pid;
+ }
+
+ void parse() {
+ if (isDone()) {
+ MIOutput out = getMIOutput();
+ MIOOBRecord[] oobs = out.getMIOOBRecords();
+ for (int i = 0; i < oobs.length; i++) {
+ if (oobs[i] instanceof MIConsoleStreamOutput) {
+ MIStreamRecord cons = (MIStreamRecord) oobs[i];
+ String str = cons.getString();
+ // We are interested in the signal info
+ parseLine(str);
+ }
+ }
+ }
+ }
+
+ void parseLine(String str) {
+ if (str != null && str.length() > 0) {
+ str = str.replace('.', ' ');
+ str = str.trim();
+ if (str.startsWith("Using")) {
+ StringTokenizer st = new StringTokenizer(str);
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken();
+ if (Character.isDigit(s.charAt(0))) {
+ try {
+ pid = Integer.decode(s).intValue();
+ break;
+ } catch (NumberFormatException e) {
+ }
+ }
+ }
+ }
+ }
+ }
+}