jde.debugger
Class Debugger

java.lang.Object
  |
  +--jde.debugger.Debugger
All Implemented Interfaces:
Protocol

public class Debugger
extends java.lang.Object
implements Protocol

The main class for debugging a specific process. A Debugger instance handles the following tasks:

Created: Tue Jan 08 12:24:36 2002

Version:
$Revision: 1.3 $
Author:
Petter Måhlén

Field Summary
protected  java.util.Map m_identifiableEventRequests
          This map stores the event requests that are NOT specs.
 
Fields inherited from interface jde.debugger.Protocol
APP_IO, ATTACH_SHMEM, ATTACH_SOCKET, BR, BREAK, CANCEL_TRACE_CLASSES, CANCEL_TRACE_METHODS, CANCEL_TRACE_THREADS, CLEAR, CMD_NOK, CMD_OK, COMMAND_ERROR, COMMAND_RESULT, COMMANDS, CONNECTED_TO_VM, DEBUG, ERROR, EVALUATE, EVENT_BREAKPOINT_HIT, EVENT_CLASS_PREPARE, EVENT_CLASS_UNLOAD, EVENT_EXCEPTION, EVENT_METHOD_ENTRY, EVENT_METHOD_EXIT, EVENT_OTHER, EVENT_STEP_COMPLETED, EVENT_THREAD_DEATH, EVENT_THREAD_START, EVENT_VM_DEATH, EVENT_VM_DISCONNECT, EVENT_VM_START, EVENT_WATCHPOINT_HIT, EVENTS, EVENTSET, EXCEPTION, EXIT, FINISH, FRAMEWORK, GET_ARRAY, GET_LOADED_CLASSES, GET_LOCALS, GET_OBJECT, GET_OBJECT_MONITORS, GET_PATH_INFORMATION, GET_STRING, GET_THREAD, GET_THREADS, GUI, INTERRUPT, INVALID, JDE_BUG, JDE_INIT_DEBUG_SESSION, JDE_PIPE, KILL_THREAD, LAUNCH, LISTEN_SHMEM, LISTEN_SOCKET, MESSAGE, NONE, NOQUOTE, QUIT, QUOTE, REPORT_IDS_IN_USE, RESUME, RUN, SPEC_RESOLVED, STEP, SUSPEND, TRACE_CLASSES, TRACE_EXCEPTIONS, TRACE_METHODS, TRACE_THREADS, WARNING, WATCH
 
Constructor Summary
Debugger(java.lang.Integer procID, boolean useGUI)
          Creates a new Debugger instance.
 
Method Summary
 void addCommandListener(CommandListener listener)
          Add an CommandListener.
 void addEventSetListener(EventSetListener listener)
          Add an EventSetListener.
 java.lang.Long addIdentifiableRequest(com.sun.jdi.request.EventRequest e)
          Adds an event request to the identifiable events, for future reference.
 void attachVMShmem(java.util.List args)
          Attaches to a currently running VM through shared memory.
 void attachVMSocket(java.util.List args)
          Attaches to a currently running VM through socket communication.
 void deleteIdentifiableRequest(java.lang.Long id)
          Removes an event request.
 CommandHandler getCommandHandler()
           
 EventRequestSpecList getEventRequestSpecList()
           
 GUI getGUI()
           
 java.lang.Integer getProcID()
           
 ObjectStore getStore()
           
 com.sun.jdi.ThreadReference getThreadReference(java.lang.String name)
          Returns the thread corresponding to a given name, or null if there is no such thread.
 com.sun.jdi.VirtualMachine getVM()
           
 boolean isValid()
          Returns true if this is a valid debugger.
 void launchVM(java.lang.Integer cmdID, java.util.List args)
          Launches a virtual machine for the process to be debugged, and sets up the standard in/out/err streams for the process.
 void listenShmem(java.lang.String address)
          Starts a thread that waits for a VM to be launched and connect to a given address using shared memory.
 void listenSocket(java.lang.String address)
          Starts a thread that waits for a VM to be launched and connect to a given address using socket communication.
 void removeCommandListener(CommandListener listener)
          Remove an CommandListener.
 void removeEventSetListener(EventSetListener listener)
          Remove an EventSetListener.
 void shutdown()
          Shuts the debugger down and deregisters it from the SessionManager.
 void signalCommandResult(java.lang.Integer cmdID, java.lang.String message, boolean success)
           
 void signalCommandResult(java.lang.Integer cmdID, java.lang.String message, boolean success, boolean quote)
           
 void start()
          Starts up the threads that make the debugger go.
 void stopExecution()
          Tells the debugger to stop executing, meaning that the VM is shut down.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_identifiableEventRequests

protected java.util.Map m_identifiableEventRequests
This map stores the event requests that are NOT specs. storing it here allows the user to cancel them easily: they just specify the id, that gets reverse-looked up here, uniquely identifying the actual request.

Of course, the id is sent back to the user when the actual command is responded to, so that the handle is available to jde in the first place

Constructor Detail

Debugger

public Debugger(java.lang.Integer procID,
                boolean useGUI)
Creates a new Debugger instance. Before the instance can be used, the following things must happen:
Parameters:
procID - an Integer value identifying this process in the communication with Emacs.
Method Detail

start

public void start()
           throws JDEException
Starts up the threads that make the debugger go. Also makes sure that a ClassPrepareRequest is sent to the VM, so that it's possible to resolve breakpoints, etc.
Throws:
JDEException - if an error occurs

stopExecution

public void stopExecution()
Tells the debugger to stop executing, meaning that the VM is shut down. The actual execution of the threads is not stopped until the shutdown() method is called, which is only done when a VM disconnect event is sent from the VM.
See Also:
EventHandler#vmDisconnectEvent

shutdown

public void shutdown()
              throws JDEException
Shuts the debugger down and deregisters it from the SessionManager.
Throws:
JDEException - if an error occurs
See Also:
SessionManager.deregisterDebugger(jde.debugger.Debugger)

launchVM

public void launchVM(java.lang.Integer cmdID,
                     java.util.List args)
              throws JDEException
Launches a virtual machine for the process to be debugged, and sets up the standard in/out/err streams for the process.
Parameters:
cmdID - an Integer value used for setting up SIO streams.
args - a List value
Throws:
JDEException - if an error occurs

attachVMShmem

public void attachVMShmem(java.util.List args)
                   throws JDEException
Attaches to a currently running VM through shared memory. The JPDA framework currently only supports that on Windows systems.
Parameters:
args - a List value
Throws:
JDEException - if an error occurs

attachVMSocket

public void attachVMSocket(java.util.List args)
                    throws JDEException
Attaches to a currently running VM through socket communication. Works for all platforms, but is slower than shared memory.
Parameters:
args - a List value
Throws:
JDEException - if an error occurs

listenShmem

public void listenShmem(java.lang.String address)
                 throws JDEException
Starts a thread that waits for a VM to be launched and connect to a given address using shared memory. Executing this in a separate thread means that the command handler can go on waiting for new commands, without freezing up. The new thread dies as soon as the VM connects.
Parameters:
address - a String value
Throws:
JDEException - if an error occurs

listenSocket

public void listenSocket(java.lang.String address)
                  throws JDEException
Starts a thread that waits for a VM to be launched and connect to a given address using socket communication. Executing this in a separate thread means that the command handler can go on waiting for new commands, without freezing up. The new thread dies as soon as the VM connects.
Parameters:
address - a String value
Throws:
JDEException - if an error occurs

getEventRequestSpecList

public EventRequestSpecList getEventRequestSpecList()

getCommandHandler

public CommandHandler getCommandHandler()

getProcID

public java.lang.Integer getProcID()

getStore

public ObjectStore getStore()

signalCommandResult

public void signalCommandResult(java.lang.Integer cmdID,
                                java.lang.String message,
                                boolean success)

signalCommandResult

public void signalCommandResult(java.lang.Integer cmdID,
                                java.lang.String message,
                                boolean success,
                                boolean quote)

getVM

public com.sun.jdi.VirtualMachine getVM()

getGUI

public GUI getGUI()

isValid

public boolean isValid()
Returns true if this is a valid debugger. A debugger is valid if the start() method has been called, but not the shutdown() method. XXX - actually not correct at the moment, but it doesn't matter. The method returns true from the moment the Debugger instance has been created until the shutdown() method is called.
Returns:
a boolean value

getThreadReference

public com.sun.jdi.ThreadReference getThreadReference(java.lang.String name)
Returns the thread corresponding to a given name, or null if there is no such thread.
Parameters:
name -  

addIdentifiableRequest

public java.lang.Long addIdentifiableRequest(com.sun.jdi.request.EventRequest e)
Adds an event request to the identifiable events, for future reference. Also enables the event.
Returns:
an identifier for the request

deleteIdentifiableRequest

public void deleteIdentifiableRequest(java.lang.Long id)
                               throws JDEException
Removes an event request. Also disables/deletes from the vm.

addEventSetListener

public void addEventSetListener(EventSetListener listener)
Add an EventSetListener. If the listener is already in the list, nothing is done.

This is handled by the eventHandler, but there is no public access to that


removeEventSetListener

public void removeEventSetListener(EventSetListener listener)
Remove an EventSetListener. If the listener is already in the list, nothing is done

addCommandListener

public void addCommandListener(CommandListener listener)
Add an CommandListener. If the listener is already in the list, nothing is done.


removeCommandListener

public void removeCommandListener(CommandListener listener)
Remove an CommandListener. If the listener is already in the list, nothing is done