3 import java.io.BufferedReader;
4 import java.io.IOException;
5 import java.io.InputStreamReader;
8 import jde.debugger.command.CommandHandler;
9 import jde.debugger.command.DebugCommand;
10 import jde.debugger.command.DebugCommandFactory;
13 * Class of JDEbug debuggers.
15 * This class defines methods for communicating with the JDE. It
16 * maintains a list of active applications. It passes application
17 * commands to the apps specified by the commands.
19 * See {@link Protocol Protocol class} for command/response formats and
20 * {@link EventHandler EventHandler} for event set formats.
22 * JDEbug responds to every command with either a result or error
28 * @author Paul Kinnucan
30 * @version $Revision: 1.13 $
32 public class JDEbug extends Thread implements Protocol {
35 * The ID of jdebug. This is used by jde when issuing commands that
36 * are not specific to any particular vm, for instance, 'quit', or
37 * the command used to launch new application/vms.<br>
38 * It is the Integer -1.
40 public static final Integer debuggerID = new Integer(-1);
42 public static JDEbug theDebugger = new JDEbug();
44 private boolean m_shutdown = false;
45 private CommandStream m_commandStream;
48 * Protected constructor, since this is a singleton class.
53 public void init() throws IOException {
54 // The debugger uses standard in to read commands from Emacs.
55 m_commandStream = new CommandStream(new BufferedReader(new InputStreamReader(System.in)));
60 * Runs the debugger thread. This method reads and executes commands
65 JDE.debug(FRAMEWORK, "Starting JDEbug main loop");
68 JDE.debug(FRAMEWORK, "JDEbug waiting for cmd");
69 List command = m_commandStream.nextCommand();
70 JDE.debug(FRAMEWORK, "JDEbug got cmd");
72 final Integer procID = Integer.valueOf(command.get(0).toString());
73 final Integer cmdID = Integer.valueOf(command.get(1).toString());
74 final String cmdName = command.get(2).toString().toLowerCase();
75 final List arguments = command.subList(3, command.size());
78 CommandHandler handler = SessionManager.getCommandHandler(procID);
80 if (handler == null) {
81 throw new JDEException("no command handler found for debugger process: " + procID);
84 JDE.debug(EVENTS, "JDEbug firing command event");
85 handler.fireCommandEvent(procID,
90 catch (JDEException ex) {
91 JDE.commandResult(cmdID, "Error occurred while executing " + cmdName +
97 JDE.debug(FRAMEWORK, "jdebug main loop terminating");
98 SessionManager.shutdown(); // Just in case no Quit command was issued
102 * Sets a flag that terminates the main loop (implemented in the
103 * {@link #run} method).
105 public void shutdown() {
112 * $Log: JDEbug.java,v $
113 * Revision 1.13 2003/04/29 16:51:57 troy
114 * Initial version of GUI. Includes display of local variables.
116 * Revision 1.12 2003/01/16 05:38:28 paulk
119 * Revision 1.11 2003/01/08 06:53:37 paulk
120 * Integrate Petter Mahlen's updates.
122 * Revision 1.10 2001/08/14 05:15:01 paulk
123 * Miscellaneous updates.
125 * Revision 1.9 2001/03/24 05:36:48 paulk
126 * Updated to reflect reorganization of debuggee code.
128 * Revision 1.8 2000/10/20 04:18:29 paulk
129 * *** empty log message ***
131 * Revision 1.7 2000/07/28 06:26:31 paulk
132 * Committing all modified files.
134 * Revision 1.6 2000/02/14 06:25:34 paulk
135 * Implemented workaround for JPDA bug that prevented setting of
136 * breakpoints in inner classes.
138 * Revision 1.5 2000/01/31 12:41:39 paulk
139 * * Continue converting commands from functional to OO implementation.
141 * Revision 1.4 2000/01/30 12:47:40 paulk
142 * Changed to a singleton class. Implemented support for object-oriented
143 * commands created by DebugCommandFactory. Reimplemented launch and
144 * listen commands as object-oriented commands.
146 * Revision 1.3 2000/01/28 04:24:55 paulk
147 * Threaded listen commands. Moved launch, attach, and listen commands
148 * from Application to Jdebug class. Did general cleanup of Jdebug and
149 * Application class, including using more specific names for some
150 * variables, moving fields to the end of files, rewriting comments.
155 // End of JDEbug.java