Kyle Galloway wrote:
This patch changes ExceptionEvents so they behave more like Sun's VM for JDWP.

-Kyle

changelog:

2006-07-18  Kyle Galloway  <[EMAIL PROTECTED]>

* gnu/classpath/jdwp/event/ExceptionEvent.java: Added _klass field to hold
   defining class.
   (getParameter): Returns _klass field instead of determining
   class from _instance.
   (setCatchLoc): New method.
(writeData): Now assumes Location deals with empty locations instead of
   using null.
   * gnu/classpath/jdwp/util/Location.java (write): Check for empty
   locations and write out accordingly.
   (getEmptyLocation): New method.


Woops, here is the patch.
Index: event/ExceptionEvent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/classpath/jdwp/event/ExceptionEvent.java,v
retrieving revision 1.2
diff -u -r1.2 ExceptionEvent.java
--- event/ExceptionEvent.java	16 Jun 2006 18:16:32 -0000	1.2
+++ event/ExceptionEvent.java	18 Jul 2006 13:43:02 -0000
@@ -70,6 +70,9 @@
   
   //the location where the exception was caught
   private Location _catchLocation;
+  
+  //the class where the exeption was thrown
+  private Class _klass;
 
   /**
    * Constructs a new <code>ExceptionEvent</code> where the exception was
@@ -82,13 +85,14 @@
    * @param instance the instance that threw the exception
    */
   public ExceptionEvent(Throwable exception, Thread thread, Location location,
-                        Location catchLocation, Object instance)
+                        Location catchLocation, Class clazz, Object instance)
   {
     super(JdwpConstants.EventKind.EXCEPTION);
     _exception = exception;
     _thread = thread;
     _location = location;
     _catchLocation = catchLocation;
+    _klass = clazz;
     _instance = instance;
   }
 
@@ -108,7 +112,7 @@
     else if (type == EVENT_INSTANCE)
       return _instance;
     else if (type == EVENT_CLASS)
-      return _instance.getClass();
+      return _klass;
     else if (type == EVENT_EXCEPTION_CLASS)
       return _exception.getClass();
     else if (type == EVENT_EXCEPTION_CAUGHT)
@@ -119,6 +123,17 @@
 
     return null;
   }
+  
+  /**
+   * Sets the catchLocation, used for exceptions that are caught in different
+   * stack frames from where they are thrown.
+   * 
+   * @param catchLoc the location of the catch
+   */
+  public void setCatchLoc(Location catchLoc)
+  {
+    _catchLocation = catchLoc;
+  }
 
   /**
    * Writes the event to the given stream
@@ -136,9 +151,7 @@
     tid.write(outStream);
     _location.write(outStream);
     oid.writeTagged(outStream);
-    if(_catchLocation != null)
-      _catchLocation.write(outStream);
-    else
-      outStream.write(0);
+    _catchLocation.write(outStream);
+
   }
 }
Index: util/Location.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/classpath/jdwp/util/Location.java,v
retrieving revision 1.3
diff -u -r1.3 Location.java
--- util/Location.java	16 Mar 2006 01:01:18 -0000	1.3
+++ util/Location.java	18 Jul 2006 13:43:02 -0000
@@ -94,18 +94,40 @@
    * @param os stream to write to
    * @throws IOException when an error occurs writing to the stream
    */
-  public void write(DataOutputStream os)
+  public void write(DataOutputStream os) 
     throws IOException
   {
-    VMIdManager idm = VMIdManager.getDefault();
-    ClassReferenceTypeId crti = (ClassReferenceTypeId)
-      idm.getReferenceTypeId(method.getDeclaringClass());
+    // check if this is an empty location
+    if (method != null)
+      {
+        VMIdManager idm = VMIdManager.getDefault();
+        ClassReferenceTypeId crti = 
+          (ClassReferenceTypeId) 
+          idm.getReferenceTypeId(method.getDeclaringClass());
 
-    crti.writeTagged(os);
-    method.writeId(os);
-    os.writeLong(index);
+        crti.writeTagged(os);
+        method.writeId(os);
+        os.writeLong(index);
+      }
+    else
+      {
+        os.writeByte(1);
+        os.writeLong((long) 0);
+        os.writeLong((long) 0);
+        os.writeLong((long) 0);
+      }
   }
-
+  
+  /**
+   * Sets up an empty location
+   * 
+   * @return new Location (setup as empty)
+   */
+  public static Location getEmptyLocation()
+  {
+       return new Location(null, 0);
+  }
+   
   /**
    * Gets the method of this location
    * 

Reply via email to