changeset 9573:a79e8020ad4b

added Stub.decipher() to print information about values in stubs
author Doug Simon <doug.simon@oracle.com>
date Mon, 06 May 2013 13:49:20 +0200
parents f64a3fec4e42
children df3aa336a313
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java src/share/vm/graal/graalRuntime.cpp
diffstat 4 files changed, 58 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java	Mon May 06 12:52:22 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java	Mon May 06 13:49:20 2013 +0200
@@ -70,7 +70,11 @@
         writeExceptionOop(thread(), exception);
         writeExceptionPc(thread(), exceptionPc);
         if (logging()) {
-            printf("handling exception %p at %p\n", Word.fromObject(exception).rawValue(), exceptionPc.rawValue());
+            printf("handling exception %p (", Word.fromObject(exception).rawValue());
+            decipher(Word.fromObject(exception).rawValue());
+            printf(") at %p (", Word.fromObject(exception).rawValue(), exceptionPc.rawValue());
+            decipher(exceptionPc.rawValue());
+            printf(")\n");
         }
 
         // patch throwing pc into return address so that deoptimization finds the right debug info
@@ -79,7 +83,9 @@
         Word handlerPc = exceptionHandlerForPc(EXCEPTION_HANDLER_FOR_PC, thread());
 
         if (logging()) {
-            printf("handler for exception %p at %p is at %p\n", Word.fromObject(exception).rawValue(), exceptionPc.rawValue(), handlerPc.rawValue());
+            printf("handler for exception %p at %p is at %p (", Word.fromObject(exception).rawValue(), exceptionPc.rawValue(), handlerPc.rawValue());
+            decipher(handlerPc.rawValue());
+            printf(")\n");
         }
 
         // patch the return address so that this stub returns to the exception handler
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Mon May 06 12:52:22 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Mon May 06 13:49:20 2013 +0200
@@ -301,6 +301,13 @@
     }
 
     /**
+     * Analyzes a given value and prints information about it to the log stream.
+     */
+    public static void decipher(long value) {
+        vmMessageC(VM_MESSAGE_C, false, Word.zero(), value, 0L, 0L);
+    }
+
+    /**
      * Exits the VM with a given error message.
      * <p>
      * <b>Stubs must use this instead of {@link VMErrorNode#vmError(String, long)} to avoid an
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java	Mon May 06 12:52:22 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java	Mon May 06 13:49:20 2013 +0200
@@ -61,16 +61,23 @@
 
     @Snippet
     private static void unwindExceptionToCaller(Object exception, Word returnAddress) {
+        Pointer exceptionOop = Word.fromObject(exception);
+        if (logging()) {
+            printf("unwinding exception %p (", exceptionOop.rawValue());
+            decipher(exceptionOop.rawValue());
+            printf(") at %p (", exceptionOop.rawValue(), returnAddress.rawValue());
+            decipher(returnAddress.rawValue());
+            printf(")\n");
+        }
         checkNoExceptionInThread(assertionsEnabled());
         checkExceptionNotNull(assertionsEnabled(), exception);
-        if (logging()) {
-            printf("unwinding exception %p at return address %p\n", Word.fromObject(exception).rawValue(), returnAddress.rawValue());
-        }
 
         Word handlerInCallerPc = exceptionHandlerForReturnAddress(EXCEPTION_HANDLER_FOR_RETURN_ADDRESS, thread(), returnAddress);
 
         if (logging()) {
-            printf("handler for exception %p at return address %p is at %p\n", Word.fromObject(exception).rawValue(), returnAddress.rawValue(), handlerInCallerPc.rawValue());
+            printf("handler for exception %p at return address %p is at %p (", exceptionOop.rawValue(), returnAddress.rawValue(), handlerInCallerPc.rawValue());
+            decipher(handlerInCallerPc.rawValue());
+            printf(")\n");
         }
 
         jumpToExceptionHandlerInCaller(handlerInCallerPc, exception, returnAddress);
--- a/src/share/vm/graal/graalRuntime.cpp	Mon May 06 12:52:22 2013 +0200
+++ b/src/share/vm/graal/graalRuntime.cpp	Mon May 06 13:49:20 2013 +0200
@@ -568,13 +568,43 @@
   tty->print(buf, v1, v2, v3);
 JRT_END
 
+static void decipher(jlong v, bool ignoreZero) {
+  if (v != 0 || !ignoreZero) {
+    void* p = (void *)(address) v;
+    CodeBlob* cb = CodeCache::find_blob(p);
+    if (cb) {
+      if (cb->is_nmethod()) {
+        char buf[O_BUFLEN];
+        tty->print("%s [%p+%d]", cb->as_nmethod_or_null()->method()->name_and_sig_as_C_string(buf, O_BUFLEN), cb->code_begin(), (address)v - cb->code_begin());
+        return;
+      }
+      cb->print_value_on(tty);
+      return;
+    }
+    if (Universe::heap()->is_in(p)) {
+      oop obj = oop(p);
+      obj->print_value_on(tty);
+      return;
+    }
+    tty->print("%p [long: %d, double %f, char %c]", v, v, v, v);
+  }
+}
+
 JRT_LEAF(void, GraalRuntime::vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3))
   ResourceMark rm;
   char *buf = (char*) (address) format;
   if (vmError) {
-    fatal(err_msg(buf, v1, v2, v3));
+    if (buf != NULL) {
+      fatal(err_msg(buf, v1, v2, v3));
+    } else {
+      fatal("<anonymous error>");
+    }
+  } else if (buf != NULL) {
+    tty->print(buf, v1, v2, v3);
   } else {
-    tty->print(buf, v1, v2, v3);
+    assert(v2 == 0, "v2 != 0");
+    assert(v3 == 0, "v3 != 0");
+    decipher(v1, false);
   }
 JRT_END