jde.debugger
Class EventHandler

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--jde.debugger.EventHandler
All Implemented Interfaces:
Protocol, java.lang.Runnable

public class EventHandler
extends java.lang.Thread
implements Protocol

Each Debugger has an event handler thread on the jdebug side associated with it that receives all the events from the debugee vm. In turn, the event handler thread passes the events on to the jde, indicating if the vm/current thread was suspended.

Created: Tue Jul 6 14:08:44 1999

Since:
0.1
Version:
$Revision: 1.7 $
Author:
Amit Kumar
See Also:
Debugger

Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
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
EventHandler(Debugger debugger)
           
 
Method Summary
 void run()
          The thread reads an eventset at a time from the application queue, and processes it.
 void shutdown()
          Indicates that the thread executing the event handling should stop as the first opportunity.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventHandler

public EventHandler(Debugger debugger)
Method Detail

shutdown

public void shutdown()
Indicates that the thread executing the event handling should stop as the first opportunity.

run

public void run()
The thread reads an eventset at a time from the application queue, and processes it.

First, it notifies all EventSetListener that an event set has arrived. The listeners can set a flag in the event to indicate if the JVM should be resumed. The old method of setting the resumeApp variable is also supported for the old code.

Next, all listeners are again notified whether we are suspending or resuming the JVM. If we are resuming the JVM, the listener registered in this class' constructor does the resume, so all other listeners will be notified after the JVM has been resumed. This two-tier suspend-policy handling might be simplified to some extent once all commands support setting of a suspend policy, with that and that alone being used to decide on what to do with the vm.

A problem with that approach is that since we do a second pass on the events when we get the eventset to determine if the events should be sent to the user (eg. a breakpoint-hit is still not interesting if it doesn't occur on the "right" thread), the latter approach might not work well at all.

Overrides:
run in class java.lang.Thread