[Swift-commit] r2352 - trunk/src/org/griphyn/vdl/karajan

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Mon Dec 1 20:56:12 CST 2008


Author: benc
Date: 2008-12-01 20:56:11 -0600 (Mon, 01 Dec 2008)
New Revision: 2352

Modified:
   trunk/src/org/griphyn/vdl/karajan/InHook.java
   trunk/src/org/griphyn/vdl/karajan/Monitor.java
Log:
rearrange console debugger so that it will take more than one cmmand; previously it would enter an infinite loop unable to process the end-of-line character at the end of a command line

Modified: trunk/src/org/griphyn/vdl/karajan/InHook.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/InHook.java	2008-11-28 06:52:55 UTC (rev 2351)
+++ trunk/src/org/griphyn/vdl/karajan/InHook.java	2008-12-02 02:56:11 UTC (rev 2352)
@@ -7,7 +7,12 @@
 import java.io.IOException;
 import java.io.InputStream;
 
+import org.apache.log4j.Logger;
+
 public class InHook extends InputStream implements Runnable {
+
+	public static final Logger logger = Logger.getLogger(InHook.class);
+
 	public synchronized static void install(Monitor m) {
 		if (!(System.in instanceof InHook)) {
 			System.setIn(new InHook(System.in, m));
@@ -21,9 +26,11 @@
 		if (is instanceof BufferedInputStream) {
 			this.is = (BufferedInputStream) is;
 			this.m = m;
-			Thread t = new Thread(this, "stdin debugger");
+			Thread t = new Thread(this, "Swift console debugger");
 			t.setDaemon(true);
 			t.start();
+		} else {
+			logger.error("Attempt to start console debugger with stdin not an instance of BufferedInputStream. InputStream class is "+is.getClass());
 		}
 	}
 
@@ -32,29 +39,29 @@
 	}
 
 	public void run() {
+		logger.debug("Starting console debugger thread");
 		while (true) {
+			logger.debug("Console debugger outer loop");
 			try {
-				while (is.available() > 0) {
-					is.mark(1);
-					int c = is.read();
-					if (c == 'd') {
-						m.toggle();
-					}
-					else if (c == 'v') {
-						m.dumpVariables();
-					}
-					else if (c == 't') {
-						m.dumpThreads();
-					}
-					else {
-						is.reset();
-					}
+				int c = is.read();
+				logger.debug("Command: "+c); // TODO display as char?
+				if (c == 'd') {
+					m.toggle();
 				}
-				if (is.available() == 0) {
-					Thread.sleep(250);
+				else if (c == 'v') {
+					m.dumpVariables();
 				}
+				else if (c == 't') {
+					m.dumpThreads();
+				} else if (c == 10) {
+					logger.debug("Ignoring LF");
+				}
+				else {
+					logger.warn("Unknown console debugger command "+c);
+				}
 			}
 			catch (IOException e) {
+				logger.debug("Console debugger encountered IOException",e);
 				return;
 			}
 			catch (Exception e) {

Modified: trunk/src/org/griphyn/vdl/karajan/Monitor.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/Monitor.java	2008-11-28 06:52:55 UTC (rev 2351)
+++ trunk/src/org/griphyn/vdl/karajan/Monitor.java	2008-12-02 02:56:11 UTC (rev 2352)
@@ -64,7 +64,7 @@
 
 	private synchronized void init() {
 		frame = new JFrame();
-		frame.setTitle("VDS Debugga'");
+		frame.setTitle("VDS Debugger");
 		buttons = new JPanel();
 		frame.getContentPane().setLayout(new BorderLayout());
 		frame.getContentPane().add(buttons, BorderLayout.NORTH);




More information about the Swift-commit mailing list