|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jde.debugger.EventHandler
EventHandler.java
Each debugee VM has an event handler thread on the jdebug side associated with it that receive 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
Field Summary | |
(package private) Application |
app
The application for which we're the event handler |
(package private) boolean |
completed
Keeping track of if the thread is over yet or not |
(package private) boolean |
connected
Are we connected to the VM? |
(package private) java.lang.Integer |
my_id
The ID of the application |
(package private) boolean |
resumeApp
Used by the event handlers to indicate if the app should be resumed after the event occured. |
(package private) java.lang.Thread |
thread
My own thread. |
Constructor Summary | |
EventHandler(Application app)
|
Method Summary | |
private LispForm |
breakpointEvent(com.sun.jdi.event.BreakpointEvent event)
A Breakpoint was hit. |
private LispForm |
classPrepareEvent(com.sun.jdi.event.ClassPrepareEvent event)
A class was prepared. |
private LispForm |
classUnloadEvent(com.sun.jdi.event.ClassUnloadEvent event)
A class was unloaded. |
private LispForm |
exceptionEvent(com.sun.jdi.event.ExceptionEvent event)
An exception event occured. |
private java.lang.String |
expressionSuccess(com.sun.jdi.event.Event event)
For events with corresponding specs (eg. |
private com.sun.jdi.ThreadReference |
getCurrentThread(com.sun.jdi.event.EventSet eventSet)
Get the current thread of this event set. |
private com.sun.jdi.ThreadReference |
getEventThread(com.sun.jdi.event.Event event)
Black magic to divine the ThreadReference of the event. |
private void |
handleDisconnectedException()
What we should do if we get disconnected while we're doing something else. |
private LispForm |
handleEvent(com.sun.jdi.event.Event event)
Handles the events that happened |
private LispForm |
methodEntryEvent(com.sun.jdi.event.MethodEntryEvent event)
A method was entered. |
private LispForm |
methodExitEvent(com.sun.jdi.event.MethodExitEvent event)
A method was exit. |
private java.lang.String |
objectIDMatches(com.sun.jdi.event.WatchpointEvent event)
For watchpoints, when the object-id specified during the command should match the object id of the event. |
private LispForm |
otherEvent(com.sun.jdi.event.Event event)
Duh... |
void |
run()
The thread reads an eventset at a time from the application queue, and processes it. |
void |
shutdown()
|
private LispForm |
stepEvent(com.sun.jdi.event.StepEvent event)
A step event occured. |
private LispForm |
threadDeathEvent(com.sun.jdi.event.ThreadDeathEvent event)
A thread died. |
private java.lang.String |
threadMatch(com.sun.jdi.event.Event event)
For events with corresponding specs (eg. |
private LispForm |
threadStartEvent(com.sun.jdi.event.ThreadStartEvent event)
A thread started |
private LispForm |
vmDeathEvent(com.sun.jdi.event.Event event)
|
private LispForm |
vmDisconnectEvent(com.sun.jdi.event.Event event)
|
private LispForm |
vmStartEvent(com.sun.jdi.event.Event event)
|
private LispForm |
watchpointEvent(com.sun.jdi.event.WatchpointEvent event)
A Watchpoint occured. |
Methods inherited from class java.lang.Object |
|
Field Detail |
boolean connected
final Application app
final java.lang.Integer my_id
final java.lang.Thread thread
boolean completed
boolean resumeApp
Constructor Detail |
public EventHandler(Application app)
Method Detail |
public void shutdown()
public void run()
This is the syntax of the event set:
(JDE_BUG_EVENTSET suspend-state thread [event-string]+)
protocol
) allow for specifying the suspend
policy for the corresponding event. For example, we might specify
that the vm resume automatically after a method entry event is
reported.
Firstly, when multiple events are sent (in an event-set), the suspend policy of the entire event set is the one that would suspend the most threads. So, if a breakpoint-hit is sent with the method-entry event, and the breakpoint-hit wants to suspend the vm, while method-entry wants to resume, overall, the event set suspend policy will be to suspend
Further, some of the events might occur that haven't been explicitly requested, and hence we haven't set their suspend policy anyway. In these cases, and even otherwise, another decision is made at the time of handling of events regarding the suspension/resumption of the vm.
So, when an event set is received, each event is handled (via
it's handler method). Each event ANDs to a variable resumeApp
what it thinks should be done to the app: for example, the
vmDeathEvent handler wants to resume, so it does
resumeApp &= true;
. In the same way, when a
breakpoint is hit (and matches the constraints), it does a
resumeApp &= false:
.
After all events have been handled, we check the value of resumeApp. If it's true, we resume the vm. If not, we check the suspend-policy of the event set, and take appropriate action.
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.
private LispForm handleEvent(com.sun.jdi.event.Event event)
event
- One of the events in the event set.private LispForm otherEvent(com.sun.jdi.event.Event event)
private void handleDisconnectedException()
private com.sun.jdi.ThreadReference getCurrentThread(com.sun.jdi.event.EventSet eventSet)
eventSet
- The event set that occurednull
if there is no thread associated, otherwise
the ThreadReference of the Threadprivate com.sun.jdi.ThreadReference getEventThread(com.sun.jdi.event.Event event)
event
- An event from the event set: any event will doprivate java.lang.String threadMatch(com.sun.jdi.event.Event event)
Syntax:
nil # If no such constraint # was found in the spec "Error mesg" # Constraint found, but error # during evaluation (list "on_thread_id" threadID) # Constraint found, satisfied (list "on_thread_name" "name")Comments:
private java.lang.String expressionSuccess(com.sun.jdi.event.Event event)
Syntax:
nil # If no such constraint # was found in the spec "Error mesg" # Constraint found, but error # during evaluation (list "expression") # Constraint found, satisfiedComments:
private java.lang.String objectIDMatches(com.sun.jdi.event.WatchpointEvent event)
Syntax:
nil # if no such constraint was in spec "Error mesg" # Constraint found, error in eval. (list object-id) # Constraint found, satisfied.Comments:
private LispForm breakpointEvent(com.sun.jdi.event.BreakpointEvent event)
Syntax:
(listComments:breakpoint-hit-function
specIDlocation
thread-string
expression-string
)
private LispForm stepEvent(com.sun.jdi.event.StepEvent event)
Syntax:
(liststep-function
location-string
)
private LispForm watchpointEvent(com.sun.jdi.event.WatchpointEvent event)
Syntax:
(listComments:watchpoint-hit-function
specIDobject-on-which-hit
field-and-value
location
object-id-string
thread-string
expression-string
)
private LispForm exceptionEvent(com.sun.jdi.event.ExceptionEvent event)
Syntax:
(listComments:exception-function
specIDexception
thread-string
)
private LispForm methodEntryEvent(com.sun.jdi.event.MethodEntryEvent event)
Syntax:
(listmethod-entry-function
method
)
private LispForm methodExitEvent(com.sun.jdi.event.MethodExitEvent event)
Syntax:
(listmethod-exit-function
method
)
private LispForm threadStartEvent(com.sun.jdi.event.ThreadStartEvent event)
Syntax:
(listthread-start-function
thread
)
private LispForm threadDeathEvent(com.sun.jdi.event.ThreadDeathEvent event)
Syntax:
(listthread-death-function
thread
)
private LispForm classPrepareEvent(com.sun.jdi.event.ClassPrepareEvent event)
Application
because we need it for resolution of specs.
If a user also requests for this event, a particular property is likely not set, and that is how we know that we're supposed to handle the event for the user.
Syntax:
(list class-prepare-function
reference-type)
private LispForm classUnloadEvent(com.sun.jdi.event.ClassUnloadEvent event)
Syntax:
(list class-unload-function
reference-type)
private LispForm vmStartEvent(com.sun.jdi.event.Event event)
private LispForm vmDeathEvent(com.sun.jdi.event.Event event)
private LispForm vmDisconnectEvent(com.sun.jdi.event.Event event)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |