blob: 5fa2a22c25fdf1c56db1fe8b8c28cfbcbea3f20b [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package com.sun.jdi.request;
27
28import com.sun.jdi.*;
29
30import java.util.List;
31
32/**
33 * Manages the creation and deletion of {@link EventRequest}s. A single
34 * implementor of this interface exists in a particuar VM and
35 * is accessed through {@link VirtualMachine#eventRequestManager()}
36 *
37 * @see EventRequest
38 * @see com.sun.jdi.event.Event
39 * @see BreakpointRequest
40 * @see com.sun.jdi.event.BreakpointEvent
41 * @see VirtualMachine
42 *
43 * @author Robert Field
44 * @since 1.3
45 */
46
47public interface EventRequestManager extends Mirror {
48
49 /**
50 * Creates a new disabled {@link ClassPrepareRequest}.
51 * The new event request is added to the list managed by this
52 * EventRequestManager. Use {@link EventRequest#enable()} to
53 * activate this event request.
54 *
55 * @return the created {@link ClassPrepareRequest}
56 */
57 ClassPrepareRequest createClassPrepareRequest();
58
59 /**
60 * Creates a new disabled {@link ClassUnloadRequest}.
61 * The new event request is added to the list managed by this
62 * EventRequestManager. Use {@link EventRequest#enable()} to
63 * activate this event request.
64 *
65 * @return the created {@link ClassUnloadRequest}
66 */
67 ClassUnloadRequest createClassUnloadRequest();
68
69 /**
70 * Creates a new disabled {@link ThreadStartRequest}.
71 * The new event request is added to the list managed by this
72 * EventRequestManager. Use {@link EventRequest#enable()} to
73 * activate this event request.
74 *
75 * @return the created {@link ThreadStartRequest}
76 */
77 ThreadStartRequest createThreadStartRequest();
78
79 /**
80 * Creates a new disabled {@link ThreadDeathRequest}.
81 * The new event request is added to the list managed by this
82 * EventRequestManager. Use {@link EventRequest#enable()} to
83 * activate this event request.
84 *
85 * @return the created {@link ThreadDeathRequest}
86 */
87 ThreadDeathRequest createThreadDeathRequest();
88
89 /**
90 * Creates a new disabled {@link ExceptionRequest}.
91 * The new event request is added to the list managed by this
92 * EventRequestManager. Use {@link EventRequest#enable()} to
93 * activate this event request.
94 * <P>
95 * A specific exception type and its subclasses can be selected
96 * for exception events. Caught exceptions, uncaught exceptions,
97 * or both can be selected. Note, however, that
98 * at the time an exception is thrown, it is not always
99 * possible to determine whether it is truly caught. See
100 * {@link com.sun.jdi.event.ExceptionEvent#catchLocation} for
101 * details.
102 * @param refType If non-null, specifies that exceptions which are
103 * instances of refType will be reported. Note: this
104 * will include instances of sub-types. If null,
105 * all instances will be reported
106 * @param notifyCaught If true, caught exceptions will be reported.
107 * @param notifyUncaught If true, uncaught exceptions will be reported.
108 *
109 * @return the created {@link ExceptionRequest}
110 */
111 ExceptionRequest createExceptionRequest(ReferenceType refType,
112 boolean notifyCaught,
113 boolean notifyUncaught);
114
115 /**
116 * Creates a new disabled {@link MethodEntryRequest}.
117 * The new event request is added to the list managed by this
118 * EventRequestManager. Use {@link EventRequest#enable()} to
119 * activate this event request.
120 *
121 * @return the created {@link MethodEntryRequest}
122 */
123 MethodEntryRequest createMethodEntryRequest();
124
125 /**
126 * Creates a new disabled {@link MethodExitRequest}.
127 * The new event request is added to the list managed by this
128 * EventRequestManager. Use {@link EventRequest#enable()} to
129 * activate this event request.
130 *
131 * @return the created {@link MethodExitRequest}
132 */
133 MethodExitRequest createMethodExitRequest();
134
135 /**
136 * Creates a new disabled {@link MonitorContendedEnterRequest}.
137 * The new event request is added to the list managed by this
138 * EventRequestManager. Use {@link EventRequest#enable()} to
139 * activate this event request.
140 *
141 * Not all target virtual machines support this operation.
142 * Use {@link VirtualMachine#canRequestMonitorEvents()}
143 * to determine if the operation is supported.
144 *
145 * @return the created {@link MonitorContendedEnterRequest}
146 * @throws java.lang.UnsupportedOperationException if
147 * the target VM does not support this
148 * operation.
149 *
150 * @since 1.6
151 */
152 MonitorContendedEnterRequest createMonitorContendedEnterRequest();
153
154 /**
155 * Creates a new disabled {@link MonitorContendedEnteredRequest}.
156 * The new event request is added to the list managed by this
157 * EventRequestManager. Use {@link EventRequest#enable()} to
158 * activate this event request.
159 *
160 * Not all target virtual machines support this operation.
161 * Use {@link VirtualMachine#canRequestMonitorEvents()}
162 * to determine if the operation is supported.
163 *
164 * @return the created {@link MonitorContendedEnteredRequest}
165 * @throws java.lang.UnsupportedOperationException if
166 * the target VM does not support this
167 * operation.
168 *
169 * @since 1.6
170 */
171
172 MonitorContendedEnteredRequest createMonitorContendedEnteredRequest();
173
174 /**
175 * Creates a new disabled {@link MonitorWaitRequest}.
176 * The new event request is added to the list managed by this
177 * EventRequestManager. Use {@link EventRequest#enable()} to
178 * activate this event request.
179 *
180 * Not all target virtual machines support this operation.
181 * Use {@link VirtualMachine#canRequestMonitorEvents()}
182 * to determine if the operation is supported.
183 *
184 * @return the created {@link MonitorWaitRequest}
185 * @throws java.lang.UnsupportedOperationException if
186 * the target VM does not support this
187 * operation.
188 *
189 * @since 1.6
190 */
191 MonitorWaitRequest createMonitorWaitRequest();
192
193 /**
194 * Creates a new disabled {@link MonitorWaitedRequest}.
195 * The new event request is added to the list managed by this
196 * EventRequestManager. Use {@link EventRequest#enable()} to
197 * activate this event request.
198 *
199 * Not all target virtual machines support this operation.
200 * Use {@link VirtualMachine#canRequestMonitorEvents()}
201 * to determine if the operation is supported.
202 *
203 * @return the created {@link MonitorWaitedRequest}
204 * @throws java.lang.UnsupportedOperationException if
205 * the target VM does not support this
206 * operation.
207 *
208 * @since 1.6
209 */
210 MonitorWaitedRequest createMonitorWaitedRequest();
211
212 /**
213 * Creates a new disabled {@link StepRequest}.
214 * The new event request is added to the list managed by this
215 * EventRequestManager. Use {@link EventRequest#enable()} to
216 * activate this event request.
217 * <p>
218 * The returned request will control stepping only in the specified
219 * <code>thread</code>; all other threads will be unaffected.
220 * A <code>size</code>value of {@link com.sun.jdi.request.StepRequest#STEP_MIN} will generate a
221 * step event each time the code index changes. It represents the
222 * smallest step size available and often maps to the instruction
223 * level.
224 * A <code>size</code> value of {@link com.sun.jdi.request.StepRequest#STEP_LINE} will generate a
225 * step event each time the source line changes unless line number information is not available,
226 * in which case a STEP_MIN will be done instead. For example, no line number information is
227 * available during the execution of a method that has been rendered obsolete by
228 * by a {@link com.sun.jdi.VirtualMachine#redefineClasses} operation.
229 * A <code>depth</code> value of {@link com.sun.jdi.request.StepRequest#STEP_INTO} will generate
230 * step events in any called methods. A <code>depth</code> value
231 * of {@link com.sun.jdi.request.StepRequest#STEP_OVER} restricts step events to the current frame
232 * or caller frames. A <code>depth</code> value of {@link com.sun.jdi.request.StepRequest#STEP_OUT}
233 * restricts step events to caller frames only. All depth
234 * restrictions are relative to the call stack immediately before the
235 * step takes place.
236 * <p>
237 * Only one pending step request is allowed per thread.
238 * <p>
239 * Note that a typical debugger will want to cancel stepping
240 * after the first step is detected. Thus a next line method
241 * would do the following:
242 * <code>
243 * <pre>
244 * EventRequestManager mgr = myVM.{@link VirtualMachine#eventRequestManager eventRequestManager}();
245 * StepRequest request = mgr.createStepRequest(myThread,
246 * StepRequest.{@link StepRequest#STEP_LINE STEP_LINE},
247 * StepRequest.{@link StepRequest#STEP_OVER STEP_OVER});
248 * request.{@link EventRequest#addCountFilter addCountFilter}(1); // next step only
249 * request.enable();
250 * myVM.{@link VirtualMachine#resume resume}();
251 * </pre>
252 * </code>
253 *
254 * @param thread the thread in which to step
255 * @param depth the step depth
256 * @param size the step size
257 * @return the created {@link StepRequest}
258 * @throws DuplicateRequestException if there is already a pending
259 * step request for the specified thread.
260 * @throws IllegalArgumentException if the size or depth arguments
261 * contain illegal values.
262 */
263 StepRequest createStepRequest(ThreadReference thread,
264 int size,
265 int depth);
266
267 /**
268 * Creates a new disabled {@link BreakpointRequest}.
269 * The given {@link Location} must have a valid
270 * (that is, non-negative) code index. The new
271 * breakpoint is added to the list managed by this
272 * EventRequestManager. Multiple breakpoints at the
273 * same location are permitted. Use {@link EventRequest#enable()} to
274 * activate this event request.
275 *
276 * @param location the location of the new breakpoint.
277 * @return the created {@link BreakpointRequest}
278 * @throws NativeMethodException if location is within a native method.
279 */
280 BreakpointRequest createBreakpointRequest(Location location);
281
282 /**
283 * Creates a new disabled watchpoint which watches accesses to the
284 * specified field. The new
285 * watchpoint is added to the list managed by this
286 * EventRequestManager. Multiple watchpoints on the
287 * same field are permitted.
288 * Use {@link EventRequest#enable()} to
289 * activate this event request.
290 * <P>
291 * Not all target virtual machines support this operation.
292 * Use {@link VirtualMachine#canWatchFieldAccess()}
293 * to determine if the operation is supported.
294 *
295 * @param field the field to watch
296 * @return the created watchpoint
297 * @throws java.lang.UnsupportedOperationException if
298 * the target virtual machine does not support this
299 * operation.
300 */
301 AccessWatchpointRequest createAccessWatchpointRequest(Field field);
302
303 /**
304 * Creates a new disabled watchpoint which watches accesses to the
305 * specified field. The new
306 * watchpoint is added to the list managed by this
307 * EventRequestManager. Multiple watchpoints on the
308 * same field are permitted.
309 * Use {@link EventRequest#enable()} to
310 * activate this event request.
311 * <P>
312 * Not all target virtual machines support this operation.
313 * Use {@link VirtualMachine#canWatchFieldModification()}
314 * to determine if the operation is supported.
315 *
316 * @param field the field to watch
317 * @return the created watchpoint
318 * @throws java.lang.UnsupportedOperationException if
319 * the target virtual machine does not support this
320 * operation.
321 */
322 ModificationWatchpointRequest createModificationWatchpointRequest(Field field);
323
324 /**
325 * Creates a new disabled {@link VMDeathRequest}.
326 * The new request is added to the list managed by this
327 * EventRequestManager.
328 * Use {@link EventRequest#enable()} to
329 * activate this event request.
330 * <P>
331 * This request (if enabled) will cause a
332 * {@link com.sun.jdi.event.VMDeathEvent}
333 * to be sent on termination of the target VM.
334 * <P>
335 * A VMDeathRequest with a suspend policy of
336 * {@link EventRequest#SUSPEND_ALL SUSPEND_ALL}
337 * can be used to assure processing of incoming
338 * {@link EventRequest#SUSPEND_NONE SUSPEND_NONE} or
339 * {@link EventRequest#SUSPEND_EVENT_THREAD SUSPEND_EVENT_THREAD}
340 * events before VM death. If all event processing is being
341 * done in the same thread as event sets are being read,
342 * enabling the request is all that is needed since the VM
343 * will be suspended until the {@link com.sun.jdi.event.EventSet}
344 * containing the {@link com.sun.jdi.event.VMDeathEvent}
345 * is resumed.
346 * <P>
347 * Not all target virtual machines support this operation.
348 * Use {@link VirtualMachine#canRequestVMDeathEvent()}
349 * to determine if the operation is supported.
350 *
351 * @return the created request
352 * @throws java.lang.UnsupportedOperationException if
353 * the target VM does not support this
354 * operation.
355 *
356 * @since 1.4
357 */
358 VMDeathRequest createVMDeathRequest();
359
360 /**
361 * Removes an eventRequest. The eventRequest is disabled and
362 * the removed from the requests managed by this
363 * EventRequestManager. Once the eventRequest is deleted, no
364 * operations (for example, {@link EventRequest#setEnabled})
365 * are permitted - attempts to do so will generally cause an
366 * {@link InvalidRequestStateException}.
367 * No other eventRequests are effected.
368 * <P>
369 * Because this method changes the underlying lists of event
370 * requests, attempting to directly delete from a list returned
371 * by a request accessor (e.g. below):
372 * <PRE>
373 * Iterator iter = requestManager.stepRequests().iterator();
374 * while (iter.hasNext()) {
375 * requestManager.deleteEventRequest(iter.next());
376 * }
377 * </PRE>
378 * may cause a {@link java.util.ConcurrentModificationException}.
379 * Instead use
380 * {@link #deleteEventRequests(List) deleteEventRequests(List)}
381 * or copy the list before iterating.
382 *
383 * @param eventRequest the eventRequest to remove
384 */
385 void deleteEventRequest(EventRequest eventRequest);
386
387 /**
388 * Removes a list of {@link EventRequest}s.
389 *
390 * @see #deleteEventRequest(EventRequest)
391 *
392 * @param eventRequests the list of eventRequests to remove
393 */
394 void deleteEventRequests(List<? extends EventRequest> eventRequests);
395
396 /**
397 * Remove all breakpoints managed by this EventRequestManager.
398 *
399 * @see #deleteEventRequest(EventRequest)
400 */
401 void deleteAllBreakpoints();
402
403 /**
404 * Return an unmodifiable list of the enabled and disabled step requests.
405 * This list is a live view of these requests and thus changes as requests
406 * are added and deleted.
407 * @return the all {@link StepRequest} objects.
408 */
409 List<StepRequest> stepRequests();
410
411 /**
412 * Return an unmodifiable list of the enabled and disabled class prepare requests.
413 * This list is a live view of these requests and thus changes as requests
414 * are added and deleted.
415 * @return the all {@link ClassPrepareRequest} objects.
416 */
417 List<ClassPrepareRequest> classPrepareRequests();
418
419 /**
420 * Return an unmodifiable list of the enabled and disabled class unload requests.
421 * This list is a live view of these requests and thus changes as requests
422 * are added and deleted.
423 * @return the all {@link ClassUnloadRequest} objects.
424 */
425 List<ClassUnloadRequest> classUnloadRequests();
426
427 /**
428 * Return an unmodifiable list of the enabled and disabled thread start requests.
429 * This list is a live view of these requests and thus changes as requests
430 * are added and deleted.
431 * @return the all {@link ThreadStartRequest} objects.
432 */
433 List<ThreadStartRequest> threadStartRequests();
434
435 /**
436 * Return an unmodifiable list of the enabled and disabled thread death requests.
437 * This list is a live view of these requests and thus changes as requests
438 * are added and deleted.
439 * @return the all {@link ThreadDeathRequest} objects.
440 */
441 List<ThreadDeathRequest> threadDeathRequests();
442
443 /**
444 * Return an unmodifiable list of the enabled and disabled exception requests.
445 * This list is a live view of these requests and thus changes as requests
446 * are added and deleted.
447 * @return the all {@link ExceptionRequest} objects.
448 */
449 List<ExceptionRequest> exceptionRequests();
450
451 /**
452 * Return an unmodifiable list of the enabled and disabled breakpoint requests.
453 * This list is a live view of these requests and thus changes as requests
454 * are added and deleted.
455 * @return the list of all {@link BreakpointRequest} objects.
456 */
457 List<BreakpointRequest> breakpointRequests();
458
459 /**
460 * Return an unmodifiable list of the enabled and disabled access
461 * watchpoint requests.
462 * This list is a live view of these requests and thus changes as requests
463 * are added and deleted.
464 * @return the all {@link AccessWatchpointRequest} objects.
465 */
466 List<AccessWatchpointRequest> accessWatchpointRequests();
467
468 /**
469 * Return an unmodifiable list of the enabled and disabled modification
470 * watchpoint requests.
471 * This list is a live view of these requests and thus changes as requests
472 * are added and deleted.
473 * @return the all {@link ModificationWatchpointRequest} objects.
474 */
475 List<ModificationWatchpointRequest> modificationWatchpointRequests();
476
477 /**
478 * Return an unmodifiable list of the enabled and disabled method entry requests.
479 * This list is a live view of these requests and thus changes as requests
480 * are added and deleted.
481 * @return the list of all {@link MethodEntryRequest} objects.
482 */
483 List<MethodEntryRequest> methodEntryRequests();
484
485 /**
486 * Return an unmodifiable list of the enabled and disabled method exit requests.
487 * This list is a live view of these requests and thus changes as requests
488 * are added and deleted.
489 * @return the list of all {@link MethodExitRequest} objects.
490 */
491 List<MethodExitRequest> methodExitRequests();
492
493 /**
494 * Return an unmodifiable list of the enabled and disabled monitor contended enter requests.
495 * This list is a live view of these requests and thus changes as requests
496 * are added and deleted.
497 * @return the list of all {@link MonitorContendedEnterRequest} objects.
498 *
499 * @since 1.6
500 */
501 List<MonitorContendedEnterRequest> monitorContendedEnterRequests();
502
503 /**
504 * Return an unmodifiable list of the enabled and disabled monitor contended entered requests.
505 * This list is a live view of these requests and thus changes as requests
506 * are added and deleted.
507 * @return the list of all {@link MonitorContendedEnteredRequest} objects.
508 *
509 * @since 1.6
510 */
511 List<MonitorContendedEnteredRequest> monitorContendedEnteredRequests();
512
513 /**
514 * Return an unmodifiable list of the enabled and disabled monitor wait requests.
515 * This list is a live view of these requests and thus changes as requests
516 * are added and deleted.
517 * @return the list of all {@link MonitorWaitRequest} objects.
518 *
519 * @since 1.6
520 */
521 List<MonitorWaitRequest> monitorWaitRequests();
522
523 /**
524 * Return an unmodifiable list of the enabled and disabled monitor waited requests.
525 * This list is a live view of these requests and thus changes as requests
526 * are added and deleted.
527 * @return the list of all {@link MonitorWaitedRequest} objects.
528 *
529 * @since 1.6
530 */
531 List<MonitorWaitedRequest> monitorWaitedRequests();
532
533 /**
534 * Return an unmodifiable list of the enabled and disabled VM death requests.
535 * This list is a live view of these requests and thus changes as requests
536 * are added and deleted.
537 * Note: the unsolicited VMDeathEvent does not have a
538 * corresponding request.
539 * @return the list of all {@link VMDeathRequest} objects.
540 *
541 * @since 1.4
542 */
543 List<VMDeathRequest> vmDeathRequests();
544}