* [RFA] Implement multiple event notifications for JDWP
@ 2007-05-04 4:15 Keith Seitz
2007-05-04 18:38 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Keith Seitz @ 2007-05-04 4:15 UTC (permalink / raw)
To: Java Patch List
[-- Attachment #1: Type: text/plain, Size: 1652 bytes --]
Hi,
I committed this patch a little while ago in preparation for fixing a
"bug" (really an oversight) dealing with single stepping to a line with
a breakpoint.
Read the gory details here:
http://developer.classpath.org/pipermail/classpath-patches/2007-May/005417.html
Same patch applied to our tree appended.
QCC?
Keith
classpath/ChangeLog
2007-05-03 Keith Seitz <keiths@redhat.com>
* gnu/classpath/jdwp/Jdwp.java (notify): Rewrite to call
new array-based method.
(notify): New function.
(sendEvent): Rewrite to use sendEvents.
(sendEvents): New method.
* gnu/classpath/jdwp/event/Event.java (toPacket): Make static.
Change parameters to use arrays for events and requests.
Add suspendPolicy parameter.
Move per-event data transformation to...
(_toData): ... here.
* gnu/classpath/jdwp/transport/JdwpConnection.java
(sendEvent): Renamed to ...
(sendEvents): ... this.
Change parameters to use arrays for events and requests.
Add suspendPolicy parameter.
ChangeLog
2007-05-03 Keith Seitz <keiths@redhat.com>
* classpath/lib/gnu/classpath/jdwp/Jdwp.class: Regenerate.
* classpath/lib/gnu/classpath/jdwp/Jdwp$1.class: Regenerate.
* classpath/lib/gnu/classpath/jdwp/event/Event.class:
Regenerate.
* classpath/lib/gnu/classpath/jdwp/transport/JdwpConnection.class:
Regenerate.
* gnu/classpath/jdwp/Jdwp.h: Regenerate.
* gnu/classpath/jdwp/event/Event.h: Regenerate.
* gnu/classpath/jdwp/transport/JdwpConnection.h: Regenerate.
[-- Attachment #2: cp-multiple-events.patch --]
[-- Type: text/x-patch, Size: 7249 bytes --]
Index: classpath/gnu/classpath/jdwp/event/Event.java
===================================================================
--- classpath/gnu/classpath/jdwp/event/Event.java (revision 124402)
+++ classpath/gnu/classpath/jdwp/event/Event.java (working copy)
@@ -1,5 +1,5 @@
/* Event.java -- a base class for all event types
- Copyright (C) 2005 Free Software Foundation
+ Copyright (C) 2005, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -135,25 +135,30 @@
public abstract Object getParameter (int type);
/**
- * Converts this event into to a JDWP packet
+ * Converts the events into to a single JDWP Event.COMPOSITE packet
*
* @param dos the stream to which to write data
- * @param request the request the wanted this notification
+ * @param events the events to package into the packet
+ * @param requests the corresponding event requests
+ * @param suspendPolicy the suspend policy enforced by the VM
* @returns a <code>JdwpPacket</code> of the events
*/
- public JdwpPacket toPacket (DataOutputStream dos, EventRequest request)
+ public static JdwpPacket toPacket (DataOutputStream dos,
+ Event[] events,
+ EventRequest[] requests,
+ byte suspendPolicy)
{
JdwpPacket pkt;
try
{
- dos.writeByte (request.getSuspendPolicy ());
- dos.writeInt (1);
- dos.writeByte (_eventKind);
- dos.writeInt (request.getId ());
- _writeData (dos);
+ dos.writeByte (suspendPolicy);
+ dos.writeInt (events.length);
+ for (int i = 0; i < events.length; ++i)
+ _toData (dos, events[i], requests[i]);
- pkt = new JdwpCommandPacket (JdwpConstants.CommandSet.Event.CS_VALUE,
- JdwpConstants.CommandSet.Event.COMPOSITE);
+ pkt
+ = new JdwpCommandPacket (JdwpConstants.CommandSet.Event.CS_VALUE,
+ JdwpConstants.CommandSet.Event.COMPOSITE);
}
catch (IOException ioe)
{
@@ -162,4 +167,14 @@
return pkt;
}
+
+ // Helper function for toPacket
+ private static void _toData (DataOutputStream dos, Event event,
+ EventRequest request)
+ throws IOException
+ {
+ dos.writeByte (event._eventKind);
+ dos.writeInt (request.getId ());
+ event._writeData (dos);
+ }
}
Index: classpath/gnu/classpath/jdwp/Jdwp.java
===================================================================
--- classpath/gnu/classpath/jdwp/Jdwp.java (revision 124402)
+++ classpath/gnu/classpath/jdwp/Jdwp.java (working copy)
@@ -51,6 +51,7 @@
import java.io.IOException;
import java.security.AccessController;
+import java.util.ArrayList;
import java.util.HashMap;
/**
@@ -207,7 +208,6 @@
* The event is filtered through the event manager before being
* sent.
*
- * FIXME: Probably need logic to send multiple (different) events
* @param event the event to report
*/
public static void notify(Event event)
@@ -235,6 +235,62 @@
}
/**
+ * Notify the debugger of "co-located" events. This method should
+ * not be called if debugging is not active (but it would not
+ * cause any harm). Places where event notifications occur
+ * should check isDebugging before doing anything.
+ *
+ * The events are filtered through the event manager before being
+ * sent.
+ *
+ * @param events the events to report
+ */
+ public static void notify(Event[] events)
+ {
+ Jdwp jdwp = getDefault();
+
+ if (jdwp != null)
+ {
+ byte suspendPolicy = JdwpConstants.SuspendPolicy.NONE;
+ EventManager em = EventManager.getDefault();
+ ArrayList allEvents = new ArrayList ();
+ ArrayList allRequests = new ArrayList ();
+ for (int i = 0; i < events.length; ++i)
+ {
+ EventRequest[] r = em.getEventRequests(events[i]);
+ for (int j = 0; j < r.length; ++j)
+ {
+ /* This is hacky, but it's not clear whether this
+ can really happen, and if it does, what should
+ occur. */
+ allEvents.add (events[i]);
+ allRequests.add (r[j]);
+
+ // Perhaps this is overkill?
+ if (r[j].getSuspendPolicy() > suspendPolicy)
+ suspendPolicy = r[j].getSuspendPolicy();
+ }
+ }
+
+ try
+ {
+ Event[] e = new Event[allEvents.size()];
+ allEvents.toArray(e);
+ EventRequest[] r = new EventRequest[allRequests.size()];
+ allRequests.toArray(r);
+ sendEvents(r, e, suspendPolicy);
+ jdwp._enforceSuspendPolicy(suspendPolicy);
+ }
+ catch (Exception e)
+ {
+ /* Really not much we can do. For now, just print out
+ a warning to the user. */
+ System.out.println ("Jdwp.notify: caught exception: " + e);
+ }
+ }
+ }
+
+ /**
* Sends the event to the debugger.
*
* This method bypasses the event manager's filtering.
@@ -246,13 +302,30 @@
public static void sendEvent (EventRequest request, Event event)
throws IOException
{
- Jdwp jdwp = getDefault ();
+ sendEvents (new EventRequest[] { request }, new Event[] { event },
+ request.getSuspendPolicy());
+ }
+
+ /**
+ * Sends the events to the debugger.
+ *
+ * This method bypasses the event manager's filtering.
+ *
+ * @param requests list of debugger requests for the events
+ * @param events the events to send
+ * @param suspendPolicy the suspendPolicy enforced by the VM
+ * @throws IOException if a communications failure occurs
+ */
+ public static void sendEvents (EventRequest[] requests, Event[] events,
+ byte suspendPolicy)
+ throws IOException
+ {
+ Jdwp jdwp = getDefault();
if (jdwp != null)
{
- // !! May need to implement send queue?
synchronized (jdwp._connection)
{
- jdwp._connection.sendEvent (request, event);
+ jdwp._connection.sendEvents (requests, events, suspendPolicy);
}
}
}
Index: classpath/gnu/classpath/jdwp/transport/JdwpConnection.java
===================================================================
--- classpath/gnu/classpath/jdwp/transport/JdwpConnection.java (revision 124402)
+++ classpath/gnu/classpath/jdwp/transport/JdwpConnection.java (working copy)
@@ -1,5 +1,5 @@
/* JdwpConnection.java -- A JDWP-speaking connection
- Copyright (C) 2005, 2006 Free Software Foundation
+ Copyright (C) 2005, 2006, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -267,13 +267,17 @@
}
/**
- * Send an event notification to the debugger
+ * Send an event notification to the debugger. Note that this
+ * method will only send out one notification: all the events
+ * are passed in a single Event.COMPOSITE packet.
*
- * @param request the debugger request that wanted this event
- * @param event the event
+ * @param requests debugger requests for events
+ * @param events the events to send
+ * @param suspendPolicy the suspend policy enforced by the VM
* @throws IOException
*/
- public void sendEvent (EventRequest request, Event event)
+ public void sendEvents(EventRequest[] requests, Event[] events,
+ byte suspendPolicy)
throws IOException
{
JdwpPacket pkt;
@@ -281,7 +285,7 @@
synchronized (_bytes)
{
_bytes.reset ();
- pkt = event.toPacket (_doStream, request);
+ pkt = Event.toPacket (_doStream, events, requests, suspendPolicy);
pkt.setData (_bytes.toByteArray ());
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] Implement multiple event notifications for JDWP
2007-05-04 4:15 [RFA] Implement multiple event notifications for JDWP Keith Seitz
@ 2007-05-04 18:38 ` Tom Tromey
2007-05-07 20:48 ` Keith Seitz
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2007-05-04 18:38 UTC (permalink / raw)
To: Keith Seitz; +Cc: Java Patch List
>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
Keith> I committed this patch a little while ago in preparation for fixing a
Keith> "bug" (really an oversight) dealing with single stepping to a line
Keith> with a breakpoint.
Keith> Read the gory details here:
Keith> http://developer.classpath.org/pipermail/classpath-patches/2007-May/005417.html
Keith> Same patch applied to our tree appended.
Ok. Thanks.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] Implement multiple event notifications for JDWP
2007-05-04 18:38 ` Tom Tromey
@ 2007-05-07 20:48 ` Keith Seitz
0 siblings, 0 replies; 3+ messages in thread
From: Keith Seitz @ 2007-05-07 20:48 UTC (permalink / raw)
To: Java Patch List
Tom Tromey wrote:
>
> Ok. Thanks.
Done. Thank you.
Keith
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-05-07 20:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-04 4:15 [RFA] Implement multiple event notifications for JDWP Keith Seitz
2007-05-04 18:38 ` Tom Tromey
2007-05-07 20:48 ` Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).