• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. 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.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 package com.sun.jdi.request;
27 
28 import 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  */
81 @jdk.Exported
82 public interface EventRequest extends Mirror {
83 
84     /**
85      * Determines if this event request is currently enabled.
86      *
87      * @return <code>true</code> if enabled;
88      * <code>false</code> otherwise.
89      */
isEnabled()90     boolean isEnabled();
91 
92     /**
93      * Enables or disables this event request. While this event request is
94      * disabled, the event request will be ignored and the target VM
95      * will not be stopped if any of its threads reaches the
96      * event request.  Disabled event requests still exist,
97      * and are included in event request lists such as
98      * {@link EventRequestManager#breakpointRequests()}.
99      *
100      * @param val <code>true</code> if the event request is to be enabled;
101      * <code>false</code> otherwise.
102      * @throws InvalidRequestStateException if this request
103      * has been deleted.
104      * @throws IllegalThreadStateException if this is a StepRequest,
105      * <code>val</code> is <code>true</code>, and the
106      * thread named in the request has died.
107      */
setEnabled(boolean val)108     void setEnabled(boolean val);
109 
110     /**
111      * Same as {@link #setEnabled <CODE>setEnabled(true)</CODE>}.
112      * @throws InvalidRequestStateException if this request
113      * has been deleted.
114      * @throws IllegalThreadStateException if this is a StepRequest
115      * and the thread named in the request has died.
116      */
enable()117     void enable();
118 
119     /**
120      * Same as {@link #setEnabled <CODE>setEnabled(false)</CODE>}.
121      * @throws InvalidRequestStateException if this request
122      * has been deleted.
123      */
disable()124     void disable();
125 
126     /**
127      * Limit the requested event to be reported at most once after a
128      * given number of occurrences.  The event is not reported
129      * the first <code>count - 1</code> times this filter is reached.
130      * To request a one-off event, call this method with a count of 1.
131      * <p>
132      * Once the count reaches 0, any subsequent filters in this request
133      * are applied. If none of those filters cause the event to be
134      * suppressed, the event is reported. Otherwise, the event is not
135      * reported. In either case subsequent events are never reported for
136      * this request.
137      *
138      * @param count the number of ocurrences before generating an event.
139      * @throws InvalidRequestStateException if this request is currently
140      * enabled or has been deleted.
141      * Filters may be added only to disabled requests.
142      * @throws IllegalArgumentException if <CODE>count</CODE>
143      * is less than one.
144      */
addCountFilter(int count)145     void addCountFilter(int count);
146 
147     /** Suspend no threads when the event occurs */
148     int SUSPEND_NONE = 0;
149     /** Suspend only the thread which generated the event when the event occurs */
150     int SUSPEND_EVENT_THREAD = 1;
151     /** Suspend all threads when the event occurs */
152     int SUSPEND_ALL = 2;
153 
154     /**
155      * Determines the threads to suspend when the requested event occurs
156      * in the target VM. Use {@link #SUSPEND_ALL} to suspend all
157      * threads in the target VM (the default). Use {@link #SUSPEND_EVENT_THREAD}
158      * to suspend only the thread which generated the event. Use
159      * {@link #SUSPEND_NONE} to suspend no threads.
160      * <p>
161      * Thread suspensions through events have the same functionality
162      * as explicitly requested suspensions. See
163      * {@link com.sun.jdi.ThreadReference#suspend} and
164      * {@link com.sun.jdi.VirtualMachine#suspend} for details.
165      *
166      * @param policy the selected suspend policy.
167      * @throws InvalidRequestStateException if this request is currently
168      * enabled or has been deleted.
169      * Suspend policy may only be set in disabled requests.
170      * @throws IllegalArgumentException if the policy argument
171      * contains an illegal value.
172      */
setSuspendPolicy(int policy)173     void setSuspendPolicy(int policy);
174 
175     /**
176      * Returns a value which describes the threads to suspend when the
177      * requested event occurs in the target VM.
178      * The returned value is  {@link #SUSPEND_ALL},
179      * {@link #SUSPEND_EVENT_THREAD}, or {@link #SUSPEND_NONE}.
180      *
181      * @return the current suspend mode for this request
182      */
suspendPolicy()183     int suspendPolicy();
184 
185     /**
186      * Add an arbitrary key/value "property" to this request.
187      * The property can be used by a client of the JDI to
188      * associate application information with the request;
189      * These client-set properties are not used internally
190      * by the JDI.
191      * <p>
192      * The <code>get/putProperty</code> methods provide access to
193      * a small per-instance map. This is <b>not</b> to be confused
194      * with {@link java.util.Properties}.
195      * <p>
196      * If value is null this method will remove the property.
197      *
198      * @see #getProperty
199      */
putProperty(Object key, Object value)200     void putProperty(Object key, Object value);
201 
202     /**
203      * Returns the value of the property with the specified key.  Only
204      * properties added with {@link #putProperty} will return
205      * a non-null value.
206      *
207      * @return the value of this property or null
208      * @see #putProperty
209      */
getProperty(Object key)210     Object getProperty(Object key);
211 }
212