Hi,
Well, there was a FIXME listed in Jdwp.notify about dealing with
multiple events. Recent testing with Eclipse has shown that we *do* need
to deal with multiple events (of the same kind). Despite what I would
have thought, when multiple breakpoints are set in a method with
Eclipse, JDT debug will set a CLASS_PREPARE event request for each
breakpoint. Go figure.
The attached patch fixes this "poor" assumption.
Keith
ChangeLog
2007-04-27 Keith Seitz <[EMAIL PROTECTED]>
* gnu/classpath/jdwp/event/EventManager.java
(getEventRequest): Rename to...
(getEventRequests): ...this.
Change return type to array of requests.
Construct a list of all matching events and return
them all.
* gnu/classpath/jdwp/Jdwp.java (notify): Use getEventRequests
and send event notifications for all matching requests.
Index: gnu/classpath/jdwp/event/EventManager.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/classpath/jdwp/event/EventManager.java,v
retrieving revision 1.6
diff -u -p -r1.6 EventManager.java
--- gnu/classpath/jdwp/event/EventManager.java 18 Jan 2007 01:11:06 -0000 1.6
+++ gnu/classpath/jdwp/event/EventManager.java 27 Apr 2007 21:25:04 -0000
@@ -44,6 +44,7 @@ import gnu.classpath.jdwp.VMVirtualMachi
import gnu.classpath.jdwp.exception.InvalidEventTypeException;
import gnu.classpath.jdwp.exception.JdwpException;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Hashtable;
import java.util.Iterator;
@@ -146,39 +147,39 @@ public class EventManager
}
/**
- * Returns a request for the given event. This method will only
+ * Returns all requests for the given event. This method will only
* be used if the <code>EventManager</code> is handling event filtering.
*
* @param event the event
- * @return request that was interested in this event
+ * @return requests that are interested in this event
* or <code>null</code> if none (and event should not be sent)
* @throws IllegalArgumentException for invalid event kind
*/
- public EventRequest getEventRequest (Event event)
+ public EventRequest[] getEventRequests(Event event)
{
- EventRequest interestedRequest = null;
+ ArrayList interestedEvents = new ArrayList();
Hashtable requests;
- Byte kind = new Byte (event.getEventKind ());
- requests = (Hashtable) _requests.get (kind);
+ Byte kind = new Byte(event.getEventKind());
+ requests = (Hashtable) _requests.get(kind);
if (requests == null)
{
// Did not get a valid event type
- throw new IllegalArgumentException ("invalid event kind: " + kind);
+ throw new IllegalArgumentException("invalid event kind: " + kind);
}
- boolean match = false;
// Loop through the requests. Must look at ALL requests in order
// to evaluate all filters (think count filter).
- // TODO: What if multiple matches? Spec isn't so clear on this.
- Iterator rIter = requests.values().iterator ();
- while (rIter.hasNext ())
+ Iterator rIter = requests.values().iterator();
+ while (rIter.hasNext())
{
- EventRequest request = (EventRequest) rIter.next ();
- if (request.matches (event))
- interestedRequest = request;
+ EventRequest request = (EventRequest) rIter.next();
+ if (request.matches(event))
+ interestedEvents.add(request);
}
- return interestedRequest;
+ EventRequest[] r = new EventRequest[interestedEvents.size()];
+ interestedEvents.toArray(r);
+ return r;
}
/**
Index: gnu/classpath/jdwp/Jdwp.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/classpath/jdwp/Jdwp.java,v
retrieving revision 1.8
diff -u -p -r1.8 Jdwp.java
--- gnu/classpath/jdwp/Jdwp.java 16 Jun 2006 19:40:04 -0000 1.8
+++ gnu/classpath/jdwp/Jdwp.java 27 Apr 2007 21:25:04 -0000
@@ -1,5 +1,5 @@
/* Jdwp.java -- Virtual machine to JDWP back-end programming interface
- Copyright (C) 2005, 2006 Free Software Foundation
+ Copyright (C) 2005, 2006, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -207,23 +207,22 @@ public class Jdwp
* The event is filtered through the event manager before being
* sent.
*
- * FIXME: Probably need logic to send multiple events
+ * FIXME: Probably need logic to send multiple (different) events
* @param event the event to report
*/
- public static void notify (Event event)
+ public static void notify(Event event)
{
- Jdwp jdwp = getDefault ();
+ Jdwp jdwp = getDefault();
if (jdwp != null)
{
- EventManager em = EventManager.getDefault ();
- EventRequest request = em.getEventRequest (event);
- if (request != null)
+ EventManager em = EventManager.getDefault();
+ EventRequest[] requests = em.getEventRequests(event);
+ for (int i = 0; i < requests.length; ++i)
{
try
{
- System.out.println ("Jdwp.notify: sending event " + event);
- sendEvent (request, event);
- jdwp._enforceSuspendPolicy (request.getSuspendPolicy ());
+ sendEvent(requests[i], event);
+ jdwp._enforceSuspendPolicy(requests[i].getSuspendPolicy());
}
catch (Exception e)
{