blob: 993bd0a3c7a3d47effb58d806d5bd0cef9247448 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1998-2006 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
30/**
31 * Represents a request for notification of an event. Examples include
32 * {@link BreakpointRequest} and {@link ExceptionRequest}.
33 * When an event occurs for which an enabled request is present,
34 * an {@link com.sun.jdi.event.EventSet EventSet} will
35 * be placed on the {@link com.sun.jdi.event.EventQueue EventQueue}.
36 * The collection of existing event requests is
37 * managed by the {@link EventRequestManager}.
38 * <p>
39 * The number of events generated for an event request can be controlled
40 * through filters. Filters provide additional constraints that an event
41 * must satisfy before it is placed on the event queue. Multiple filters can
42 * be used by making multiple calls to filter addition methods such as
43 * {@link ExceptionRequest#addClassFilter(java.lang.String classPattern)}.
44 * Filters are added to an event one at a time only while the event is
45 * disabled. Multiple filters are applied with CUT-OFF AND, in the order
46 * it was added to the request. Only events that satisfy all filters are
47 * placed in the event queue.
48 * <p>
49 * The set of available filters is dependent on the event request,
50 * some examples of filters are:
51 * <ul>
52 * <li>Thread filters allow control over the thread for which events are
53 * generated.
54 * <li>Class filters allow control over the class in which the event
55 * occurs.
56 * <li>Instance filters allow control over the instance in which
57 * the event occurs.
58 * <li>Count filters allow control over the number of times an event
59 * is reported.
60 * </ul>
61 * Filters can dramatically improve debugger performance by reducing the
62 * amount of event traffic sent from the target VM to the debugger VM.
63 * <p>
64 * Any method on <code>EventRequest</code> which
65 * takes <code>EventRequest</code> as an parameter may throw
66 * {@link com.sun.jdi.VMDisconnectedException} if the target VM is
67 * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is
68 * available to be read from the {@link com.sun.jdi.event.EventQueue}.
69 * <p>
70 * Any method on <code>EventRequest</code> which
71 * takes <code>EventRequest</code> as an parameter may throw
72 * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory.
73 *
74 * @see com.sun.jdi.event.BreakpointEvent
75 * @see com.sun.jdi.event.EventQueue
76 * @see EventRequestManager
77 *
78 * @author Robert Field
79 * @since 1.3
80 */
81public interface EventRequest extends Mirror {
82
83 /**
84 * Determines if this event request is currently enabled.
85 *
86 * @return <code>true</code> if enabled;
87 * <code>false</code> otherwise.
88 */
89 boolean isEnabled();
90
91 /**
92 * Enables or disables this event request. While this event request is
93 * disabled, the event request will be ignored and the target VM
94 * will not be stopped if any of its threads reaches the
95 * event request. Disabled event requests still exist,
96 * and are included in event request lists such as
97 * {@link EventRequestManager#breakpointRequests()}.
98 *
99 * @param val <code>true</code> if the event request is to be enabled;
100 * <code>false</code> otherwise.
101 * @throws InvalidRequestStateException if this request
102 * has been deleted.
103 * @throws IllegalThreadStateException if this is a StepRequest,
104 * <code>val</code> is <code>true</code>, and the
105 * thread named in the request has died.
106 */
107 void setEnabled(boolean val);
108
109 /**
110 * Same as {@link #setEnabled <CODE>setEnabled(true)</CODE>}.
111 * @throws InvalidRequestStateException if this request
112 * has been deleted.
113 * @throws IllegalThreadStateException if this is a StepRequest
114 * and the thread named in the request has died.
115 */
116 void enable();
117
118 /**
119 * Same as {@link #setEnabled <CODE>setEnabled(false)</CODE>}.
120 * @throws InvalidRequestStateException if this request
121 * has been deleted.
122 */
123 void disable();
124
125 /**
126 * Limit the requested event to be reported at most once after a
127 * given number of occurrences. The event is not reported
128 * the first <code>count - 1</code> times this filter is reached.
129 * To request a one-off event, call this method with a count of 1.
130 * <p>
131 * Once the count reaches 0, any subsequent filters in this request
132 * are applied. If none of those filters cause the event to be
133 * suppressed, the event is reported. Otherwise, the event is not
134 * reported. In either case subsequent events are never reported for
135 * this request.
136 *
137 * @param count the number of ocurrences before generating an event.
138 * @throws InvalidRequestStateException if this request is currently
139 * enabled or has been deleted.
140 * Filters may be added only to disabled requests.
141 * @throws IllegalArgumentException if <CODE>count</CODE>
142 * is less than one.
143 */
144 void addCountFilter(int count);
145
146 /** Suspend no threads when the event occurs */
147 int SUSPEND_NONE = 0;
148 /** Suspend only the thread which generated the event when the event occurs */
149 int SUSPEND_EVENT_THREAD = 1;
150 /** Suspend all threads when the event occurs */
151 int SUSPEND_ALL = 2;
152
153 /**
154 * Determines the threads to suspend when the requested event occurs
155 * in the target VM. Use {@link #SUSPEND_ALL} to suspend all
156 * threads in the target VM (the default). Use {@link #SUSPEND_EVENT_THREAD}
157 * to suspend only the thread which generated the event. Use
158 * {@link #SUSPEND_NONE} to suspend no threads.
159 * <p>
160 * Thread suspensions through events have the same functionality
161 * as explicitly requested suspensions. See
162 * {@link com.sun.jdi.ThreadReference#suspend} and
163 * {@link com.sun.jdi.VirtualMachine#suspend} for details.
164 *
165 * @param policy the selected suspend policy.
166 * @throws InvalidRequestStateException if this request is currently
167 * enabled or has been deleted.
168 * Suspend policy may only be set in disabled requests.
169 * @throws IllegalArgumentException if the policy argument
170 * contains an illegal value.
171 */
172 void setSuspendPolicy(int policy);
173
174 /**
175 * Returns a value which describes the threads to suspend when the
176 * requested event occurs in the target VM.
177 * The returned value is {@link #SUSPEND_ALL},
178 * {@link #SUSPEND_EVENT_THREAD}, or {@link #SUSPEND_NONE}.
179 *
180 * @return the current suspend mode for this request
181 */
182 int suspendPolicy();
183
184 /**
185 * Add an arbitrary key/value "property" to this request.
186 * The property can be used by a client of the JDI to
187 * associate application information with the request;
188 * These client-set properties are not used internally
189 * by the JDI.
190 * <p>
191 * The <code>get/putProperty</code> methods provide access to
192 * a small per-instance map. This is <b>not</b> to be confused
193 * with {@link java.util.Properties}.
194 * <p>
195 * If value is null this method will remove the property.
196 *
197 * @see #getProperty
198 */
199 void putProperty(Object key, Object value);
200
201 /**
202 * Returns the value of the property with the specified key. Only
203 * properties added with {@link #putProperty} will return
204 * a non-null value.
205 *
206 * @return the value of this property or null
207 * @see #putProperty
208 */
209 Object getProperty(Object key);
210}