harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r519866 - in /harmony/enhanced/drlvm/trunk/vm: include/ interpreter/src/ jitrino/src/jet/ jitrino/src/vm/drl/ port/include/ vmcore/include/ vmcore/src/jit/ vmcore/src/kernel_classes/native/ vmcore/src/stack/ vmcore/src/util/em64t/base/ vmco...
Date Mon, 19 Mar 2007 07:50:21 GMT
Author: varlax
Date: Mon Mar 19 00:50:19 2007
New Revision: 519866

URL: http://svn.apache.org/viewvc?view=rev&rev=519866
Log:
HARMONY-1912 [drlvm] improved crash handler

Modified:
    harmony/enhanced/drlvm/trunk/vm/include/interpreter_exports.h
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_exports.cpp
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_stack_trace.cpp
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jet.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp
    harmony/enhanced/drlvm/trunk/vm/port/include/clog.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/dll_jit_intf.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_intf_cpp.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/stack_trace.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/dll_jit.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_dump.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/native_stack_em64t.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32_em64t/nt_exception_filter_common.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/include/interpreter_exports.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/interpreter_exports.h?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/interpreter_exports.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/interpreter_exports.h Mon Mar 19 00:50:19 2007
@@ -30,6 +30,8 @@
 
     FrameHandle* (*interpreter_get_last_frame) (class VM_thread *thread);
     FrameHandle* (*interpreter_get_prev_frame) (FrameHandle* frame);
+    Method_Handle (*interpreter_get_frame_method) (FrameHandle* frame);
+    uint8* (*interpreter_get_frame_bytecode_ptr) (FrameHandle* frame);
     // 'end' is not inclusive
     bool (*is_frame_in_native_frame) (struct FrameHandle* frame, void* begin, void* end);
 

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_exports.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_exports.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_exports.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_exports.cpp Mon Mar 19 00:50:19
2007
@@ -95,6 +95,8 @@
 
 extern FrameHandle* interpreter_get_last_frame(class VM_thread *thread);
 extern FrameHandle* interpreter_get_prev_frame(FrameHandle* frame);
+extern Method_Handle interpreter_get_frame_method(FrameHandle* frame);
+extern uint8* interpreter_get_frame_bytecode_ptr(FrameHandle* frame);
 extern bool is_frame_in_native_frame(FrameHandle* frame, void* begin, void* end);
 
 void EXPORT JIT_init(JIT_Handle UNREF h, const char* UNREF name) {
@@ -106,6 +108,8 @@
 
     interpreter->interpreter_get_last_frame = &interpreter_get_last_frame;
     interpreter->interpreter_get_prev_frame = &interpreter_get_prev_frame;
+    interpreter->interpreter_get_frame_method = &interpreter_get_frame_method;
+    interpreter->interpreter_get_frame_bytecode_ptr = &interpreter_get_frame_bytecode_ptr;
     interpreter->is_frame_in_native_frame = &is_frame_in_native_frame;
     interpreter->interpreter_ti_enumerate_thread = &interpreter_ti_enumerate_thread;
 #ifdef _IPF_
@@ -129,7 +133,7 @@
     interpreter->stack_dump = &stack_dump;
 
 #if defined (PLATFORM_NT) && defined (_DEBUG)
-    if (!get_boolean_property("vm.assert_dialog", false, VM_PROPERTIES))
+    if (!get_boolean_property("vm.assert_dialog", TRUE, VM_PROPERTIES))
     {
         disable_assert_dialogs();
     }

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_stack_trace.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_stack_trace.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_stack_trace.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_stack_trace.cpp Mon Mar 19 00:50:19
2007
@@ -140,6 +140,7 @@
         if (method) {
             stf->method = method;
             stf->ip = interp_si_get_ip(si);
+            stf->depth = -1;
             stf->outdated_this = si->This;
             assert(stf->outdated_this || method->is_static());
             stf++;

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp Mon Mar 19 00:50:19 2007
@@ -2418,15 +2418,15 @@
     while(f) {
         Method *m = f->method;
         Class *c = m->get_class();
+        const char* fname = NULL;
         int line = -2;
-        if ( !m->is_native() ) {
-            int ip = (int)((uint8*)frame.ip - (uint8*)m->get_byte_code_addr());
-            line = m->get_line_number((uint16)ip);
-        }
+        get_file_and_line(m, f->ip, false, -1, &fname, &line);
+        const char* filename = fname ? fname : "NULL";
+
 #ifdef INTERPRETER_DEEP_DEBUG
         fprintf(file, "%s.%s%s (%s:%i) last bcs: (8 of %i): %s %s %s %s %s %s %s %s",
             c->name->bytes, m->get_name()->bytes, m->get_descriptor()->bytes,
-            class_get_source_file_name(c), line, f->n_last_bytecode,
+            filename, line, f->n_last_bytecode,
             opcodeNames[f->last_bytecodes[(f->n_last_bytecode-1)&7]],
             opcodeNames[f->last_bytecodes[(f->n_last_bytecode-2)&7]],
             opcodeNames[f->last_bytecodes[(f->n_last_bytecode-3)&7]],
@@ -2436,9 +2436,8 @@
             opcodeNames[f->last_bytecodes[(f->n_last_bytecode-7)&7]],
             opcodeNames[f->last_bytecodes[(f->n_last_bytecode-8)&7]]);
 #else
-    const char *filename = class_get_source_file_name(c);
     fprintf(file, "  %s.%s%s (%s:%i)\n", class_get_name(c), m->get_name()->bytes,
-        m->get_descriptor()->bytes, (filename != NULL ? filename : "NULL"), line);
+        m->get_descriptor()->bytes, filename, line);
 #endif
         f = f->prev;
     }
@@ -2446,12 +2445,12 @@
 
 void stack_dump(VM_thread *thread) {
     StackFrame *frame = getLastStackFrame(thread);
-    stackDump(stdout, *frame);
+    stackDump(stderr, *frame);
 }
 
 void stack_dump() {
     StackFrame *frame = getLastStackFrame();
-    stackDump(stdout, *frame);
+    stackDump(stderr, *frame);
 }
 
 static inline

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp Mon Mar 19 00:50:19
2007
@@ -513,15 +513,25 @@
 
 FrameHandle* interpreter_get_prev_frame(FrameHandle* frame)
 {
-	if (frame == NULL)
-		return NULL;
+    if (frame == NULL)
+        return NULL;
 
-	return (FrameHandle*)(((StackFrame*)frame)->prev);
+    return (FrameHandle*)(((StackFrame*)frame)->prev);
+}
+
+Method_Handle interpreter_get_frame_method(FrameHandle* frame)
+{
+    return (Method_Handle)((StackFrame*)frame)->method;
+}
+
+uint8* interpreter_get_frame_bytecode_ptr(FrameHandle* frame)
+{
+    return ((StackFrame*)frame)->ip;
 }
 
 bool is_frame_in_native_frame(FrameHandle* frame, void* begin, void* end)
 {
-	return (frame >= begin && frame < end);
+    return (frame >= begin && frame < end);
 }
 
 /////////////////////////////////

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jet.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jet.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jet.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jet.cpp Mon Mar 19 00:50:19 2007
@@ -940,6 +940,17 @@
     return 0;
 }
 
+/**
+ * Inlining is unsupported by Jitrino.JET.
+ * @return 0
+ */
+extern "C" JITEXPORT
+uint16 JIT_get_inlined_bc(JIT_Handle jit, InlineInfoPtr ptr,
+                                     uint32 offset, uint32 inline_depth)
+{
+    return 0;
+}
+
 extern "C" JITEXPORT
 Boolean JIT_can_enumerate(JIT_Handle jit, Method_Handle method,
                           NativeCodePtr eip)

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlJITInterface.cpp Mon Mar 19 00:50:19
2007
@@ -86,7 +86,7 @@
     Jitrino::Init(jit, name);
 
 #if defined (PLATFORM_NT) && defined (_DEBUG)
-    if (!get_boolean_property("vm.assert_dialog", false, VM_PROPERTIES))
+    if (!get_boolean_property("vm.assert_dialog", TRUE, VM_PROPERTIES))
     {
         _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
         _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);

Modified: harmony/enhanced/drlvm/trunk/vm/port/include/clog.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/include/clog.h?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/include/clog.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/include/clog.h Mon Mar 19 00:50:19 2007
@@ -26,6 +26,11 @@
 #include "logger.h"
 #include "port_malloc.h"
 
+#define LOGGER_EXIT(code) { \
+    shutdown_log_system(); \
+    ::exit(code); \
+}
+
 #define DIE2(category, message) { \
     const char* formatted = log_printf message; \
     log4cxx_from_c(category, DIE, formatted, __FILE__, __LOG4CXX_FUNC__, __LINE__); \

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/dll_jit_intf.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/dll_jit_intf.h?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/dll_jit_intf.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/dll_jit_intf.h Mon Mar 19 00:50:19 2007
@@ -134,6 +134,17 @@
         return NULL;
     }
 
+    uint16
+    get_inlined_bc(InlineInfoPtr  ptr,
+                     uint32         offset,
+                     uint32         inline_depth)
+    {
+        if (_get_inlined_bc != NULL) {
+            return _get_inlined_bc(this, ptr, offset, inline_depth);
+        }
+        return 0;
+    }
+
     Boolean
     can_enumerate(Method_Handle method,
                   NativeCodePtr eip
@@ -328,6 +339,12 @@
     Method_Handle
     (*_get_inlined_method)(JIT_Handle jit,
                             InlineInfoPtr  ptr, 
+                            uint32         offset,
+                            uint32         inline_depth);
+
+    uint16
+    (*_get_inlined_bc)(JIT_Handle jit,
+                            InlineInfoPtr  ptr,
                             uint32         offset,
                             uint32         inline_depth);
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_intf_cpp.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_intf_cpp.h?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_intf_cpp.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_intf_cpp.h Mon Mar 19 00:50:19 2007
@@ -155,6 +155,11 @@
                        uint32         offset,
                        uint32         inline_depth) { return NULL; }
 
+    virtual uint16
+    get_inlined_bc(InlineInfoPtr  ptr,
+                       uint32         offset,
+                       uint32         inline_depth) { return 0; }
+
     virtual Boolean
     can_enumerate(Method_Handle method,
                   NativeCodePtr eip

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/stack_trace.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/stack_trace.h?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/stack_trace.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/stack_trace.h Mon Mar 19 00:50:19 2007
@@ -60,6 +60,7 @@
 struct StackTraceFrame {
     Method_Handle method;
     NativeCodePtr ip;
+    int depth; // Inlined depth for inlined methods, or -1 otherwise
     void *outdated_this;
 };
 
@@ -134,10 +135,13 @@
  *
  * @param[in]  method - the handle of the method information to identify the source file
  * @param[in]  ip     - the instruction pointer to identify the JIT and using the JIT line
number
+ * @param[in]  depth  - the inlined depth for inlined methods, starting from 0;
+ *                      (-1) for native methods and methods which were not inlined
  * @param[out] file   - the pointer to the file reference to be filled by this function
  * @param[out] line   - the pointer to the line number to be filled by this function
  */
-VMEXPORT void get_file_and_line(Method_Handle method, void *ip, bool is_ip_past, const char
**file, int *line);
+VMEXPORT void get_file_and_line(Method_Handle method, void *ip, bool is_ip_past,
+                                int depth, const char **file, int *line);
 
 #ifdef __cplusplus
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/dll_jit.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/dll_jit.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/dll_jit.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/dll_jit.cpp Mon Mar 19 00:50:19 2007
@@ -107,6 +107,9 @@
     GET_OPTIONAL_FUNCTION(fn, handle, "JIT_get_inlined_method");
     _get_inlined_method = (Method_Handle (*)(JIT_Handle, InlineInfoPtr, uint32, uint32))
fn;
 
+    GET_OPTIONAL_FUNCTION(fn, handle, "JIT_get_inlined_bc");
+    _get_inlined_bc = (uint16 (*)(JIT_Handle, InlineInfoPtr, uint32, uint32)) fn;
+
     GET_FUNCTION(fn, handle, "JIT_unwind_stack_frame");
     _unwind_stack_frame = (void (*)(JIT_Handle, Method_Handle, JitFrameContext *)) fn;
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp
Mon Mar 19 00:50:19 2007
@@ -371,10 +371,11 @@
     for(unsigned i = skip; i < size; i++) {
         Method_Handle method = frames[i].method;
         NativeCodePtr ip = frames[i].ip;
+        int inl_depth = frames[i].depth;
         int lineNumber;
         const char* fileName;
 
-        get_file_and_line(method, ip, true, &fileName, &lineNumber);
+        get_file_and_line(method, ip, true, inl_depth, &fileName, &lineNumber);
         jstring strFileName;
         if (fileName != NULL) {
             strFileName = jenv->NewStringUTF(fileName);
@@ -493,10 +494,11 @@
     for(unsigned i = 0; i < size; i++) {
         Method_Handle method = frames[i].method;
         NativeCodePtr ip = frames[i].ip;
+        int inl_depth = frames[i].depth;
         int lineNumber;
         const char* fileName;
 
-        get_file_and_line(method, ip, true, &fileName, &lineNumber);
+        get_file_and_line(method, ip, true, inl_depth, &fileName, &lineNumber);
         if (fileName == NULL) fileName = "";
 
         jstring strFileName = jenv->NewStringUTF(fileName);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_dump.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_dump.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_dump.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_dump.cpp Mon Mar 19 00:50:19 2007
@@ -29,6 +29,7 @@
 #include "stack_trace.h"
 #include "interpreter_exports.h"
 #include "cci.h"
+#include "m2n.h"
 #include <ctype.h>
 
 #ifdef PLATFORM_NT
@@ -169,17 +170,10 @@
 #endif
 }
 
-static void st_get_java_method_info(MethodInfo* info, Method* m, void* ip, bool is_ip_past)
{
-    info->file_name = NULL;
-    info->line = -1;
-    info->method_name = NULL;
-    assert(m);
-    if (m->get_class()->has_source_information() && m->get_class()->get_source_file_name())
{
-        const char* fname = m->get_class()->get_source_file_name();
-        size_t flen = m->get_class()->get_source_file_name_length();
-        info->file_name = (char*) STD_MALLOC(flen + 1);
-        strcpy(info->file_name, fname);
-    }
+static char* construct_java_method_name(Method* m)
+{
+    if (!m)
+        return NULL;
 
     const char* mname = m->get_name()->bytes;
     size_t mlen = m->get_name()->len;
@@ -188,15 +182,43 @@
     const char* descr = m->get_descriptor()->bytes;
     size_t dlen = m->get_descriptor()->len;
     
-    info->method_name = (char*) STD_MALLOC(mlen + clen + dlen + 2);
-    memcpy(info->method_name, cname, clen);
-    info->method_name[clen] = '.';
-    memcpy(info->method_name + clen + 1, mname, mlen);
-    memcpy(info->method_name + clen + mlen + 1, descr, dlen);
-    info->method_name[clen + mlen + dlen + 1] = '\0';
+    char* method_name = (char*)STD_MALLOC(mlen + clen + dlen + 2);
+    if (!method_name)
+        return NULL;
+
+    char* ptr = method_name;
+    memcpy(ptr, cname, clen);
+    ptr += clen;
+    *ptr++ = '.';
+    memcpy(ptr, mname, mlen);
+    ptr += mlen;
+    memcpy(ptr, descr, dlen);
+    ptr[dlen] = '\0';
+
+    return method_name;
+}
+
+static void st_get_java_method_info(MethodInfo* info, Method* m, void* ip,
+                                    bool is_ip_past, int inl_depth)
+{
+    info->method_name = NULL;
+    info->file_name = NULL;
+    info->line = -1;
 
-    const char* f;
-    get_file_and_line(m, ip, is_ip_past, &f, &info->line);
+    if (!m || !method_get_class(m))
+        return;
+
+    info->method_name = construct_java_method_name(m);
+    const char* fname = NULL;
+    get_file_and_line(m, ip, is_ip_past, inl_depth, &fname, &info->line);
+
+    if (fname)
+    {
+        size_t fsize = strlen(fname) + 1;
+        info->file_name = (char*)STD_MALLOC(fsize);
+        if (info->file_name)
+            memcpy(info->file_name, fname, fsize);
+    }
 }
 
 static void st_print_line(int count, MethodInfo* m) {
@@ -205,53 +227,187 @@
         m->method_name ? m->method_name : "??",
         m->file_name ? m->file_name : "??",
         m->line);
-    if (m->file_name) {
-        STD_FREE(m->file_name);
-    }
-    if (m->method_name) {
+
+    if (m->method_name)
         STD_FREE(m->method_name);
-    }
+
+    if (m->file_name)
+        STD_FREE(m->file_name);
 }
 
-void st_print_stack(Registers* regs) {
-    if(interpreter_enabled()) {
-       interpreter.stack_dump(get_thread_ptr());
-       return;
-    }
-    jint num_frames;
-    native_frame_t* frames;
-    num_frames = walk_native_stack_registers(regs, p_TLS_vmthread, -1, NULL);
-    frames = (native_frame_t*) STD_ALLOCA(sizeof(native_frame_t) * num_frames);
-    num_frames = walk_native_stack_registers(regs, p_TLS_vmthread, num_frames, frames);
-    StackIterator* si = si_create_from_native();
-    fprintf(stderr, "Stack trace:\n");
-    for (int i = 0; i < num_frames; i++) {		
-        static int count = 0;
-        MethodInfo m;
-        if (frames[i].java_depth == -1 && !native_is_ip_stub(frames[i].ip)) { //
Pure native method
-            st_get_c_method_info(&m, frames[i].ip);
-        } else if (frames[i].java_depth == -1) { // Generated stub
-            fprintf(stderr, "\t%d: IP is 0x%08X <native code>\n", ++count, (POINTER_SIZE_INT)
frames[i].ip); //FIXME: IA32 ONLY
+
+void st_print_stack_jit(VM_thread* thread,
+                        native_frame_t* frames, jint num_frames)
+{
+    jint frame_num = 0;
+    jint count = 0;
+    StackIterator* si = NULL;
+
+    if (thread)
+        si = si_create_from_native(thread);
+
+    while ((si && !si_is_past_end(si)) || frame_num < num_frames)
+    {
+        MethodInfo m = {NULL, NULL, 0};
+
+        if (frame_num < num_frames && frames[frame_num].java_depth < 0)
+        {
+            if (native_is_ip_stub(frames[frame_num].ip)) // Generated stub
+            {
+                fprintf(stderr, "\t%d: <Generated stub> IP is %p\n",
+                    count++, frames[frame_num].ip);
+                ++frame_num;
+                continue;
+            }
+
+            // pure native frame
+            st_get_c_method_info(&m, frames[frame_num].ip);
+            st_print_line(count++, &m);
+            ++frame_num;
             continue;
-        } else { // Java/JNI native method
+        }
+
+        // Java/JNI frame, look into stack iterator
+
+        // If iterator is exhausted
+        if (si_is_past_end(si) ||
+            (si_is_native(si) && !m2n_get_previous_frame(si_get_m2n(si))))
+            break;
+
+        if (si_is_native(si) && frame_num < num_frames)
+        {
+            // Print information from native stack trace for JNI frames
+            st_get_c_method_info(&m, frames[frame_num].ip);
+            st_print_line(count, &m);
+        }
+        else if (si_is_native(si) && frame_num >= num_frames)
+        {
+            // Print information about JNI frames from iterator
+            // when native stack trace is not available
+            Method* method = m2n_get_method(si_get_m2n(si));
+            void* ip = m2n_get_ip(si_get_m2n(si));
+            st_get_java_method_info(&m, method, ip, false, -1);
+            st_print_line(count, &m);
+        }
+        else // !si_is_native(si)
+        {
+            // Print information about Java method from iterator
             CodeChunkInfo* cci = si_get_code_chunk_info(si);
-            if (!cci) { // JNI native method
-                st_get_c_method_info(&m, frames[i].ip);
-            } else { // Java method
-                uint32 inlined_depth = si_get_inline_depth(si);
-                // FIXME64: on 64-bit architectures method bodies can be
-                // potentially greater than 2GB in size
-                uint32 offset = (uint32)((POINTER_SIZE_INT)si_get_ip(si) - (POINTER_SIZE_INT)cci->get_code_block_addr());
-                for (uint32 j = 0; j < inlined_depth; j++) {
-                    Method *real_method = cci->get_jit()->get_inlined_method(cci->get_inline_info(),
offset, j);
-                    st_get_java_method_info(&m, real_method, frames[i].ip, 0 == i);
-                    st_print_line(++count, &m);
-                }
-                st_get_java_method_info(&m, cci->get_method(), frames[i].ip, 0 ==
i);
-          }
-          si_goto_previous(si);
-      }
-      st_print_line(++count, &m);
-  }
+            Method* method = cci->get_method();
+            void* ip = (void*)si_get_ip(si);
+
+            uint32 inlined_depth = si_get_inline_depth(si);
+            uint32 offset = (uint32)((POINTER_SIZE_INT)ip -
+                (POINTER_SIZE_INT)cci->get_code_block_addr());
+            bool is_ip_past = (frame_num != 0);
+
+            for (uint32 i = 0; i < inlined_depth; i++)
+            {
+                Method* inl_method = cci->get_jit()->get_inlined_method(
+                                            cci->get_inline_info(), offset, i);
+
+                st_get_java_method_info(&m, inl_method, ip, is_ip_past, i);
+                st_print_line(count++, &m);
+
+                if (frame_num < num_frames)
+                    ++frame_num; // Go to the next native frame
+            }
+
+            st_get_java_method_info(&m, method, ip, is_ip_past, -1);
+            st_print_line(count, &m);
+        }
+
+        ++count;
+        si_goto_previous(si);
+
+        if (frame_num < num_frames)
+            ++frame_num; // Go to the next native frame
+    }
+
+    if (si)
+        si_free(si);
+}
+
+void st_print_stack_interpreter(VM_thread* thread,
+    native_frame_t* frames, jint num_frames)
+{
+    FrameHandle* frame = interpreter.interpreter_get_last_frame(thread);
+    jint frame_num = 0;
+    jint count = 0;
+
+    while (frame || frame_num < num_frames)
+    {
+        MethodInfo m = {NULL, NULL, 0};
+
+        if (frame_num < num_frames && frames[frame_num].java_depth < 0)
+        { // pure native frame
+            st_get_c_method_info(&m, frames[frame_num].ip);
+            st_print_line(count++, &m);
+            ++frame_num;
+            continue;
+        }
+
+        // Java/JNI frame, look into stack iterator
+
+        Method* method = (Method*)interpreter.interpreter_get_frame_method(frame);
+        uint8* bc_ptr = interpreter.interpreter_get_frame_bytecode_ptr(frame);
+
+        // Print information from native stack trace
+        // when method is not available or is native
+        if (frame_num < num_frames &&
+            (!method || method_is_native(method)))
+        {
+            st_get_c_method_info(&m, frames[frame_num].ip);
+            st_print_line(count, &m);
+        }
+
+        // Print information about method from iterator
+        // when is Java method or when native stack trace is not available
+        if (method &&
+            (!method_is_native(method) || frame_num >= num_frames))
+        {
+            st_get_java_method_info(&m, method, (void*)bc_ptr, false, -1);
+            st_print_line(count, &m);
+        }
+
+        ++count;
+        frame = interpreter.interpreter_get_prev_frame(frame);
+
+        if (frame_num < num_frames)
+            ++frame_num; // Go to the next native frame
+    }
+}
+
+void st_print_stack(Registers* regs)
+{
+    // We are trying to get native stack trace using walk_native_stack_registers
+    // function and get corresponding Java methods for stack trace from
+    // JIT/interpreter stack iterator.
+    // When native stack trace is not complete (for example, when
+    // walk_native_stack_registers cannot unwind frames in release build),
+    // we will use JIT/interpreter stack iterator to complete stack trace.
+
+    VM_thread* thread = get_thread_ptr(); // Can be NULL for pure native thread
+    native_frame_t* frames = NULL;
+
+    jint num_frames =
+        walk_native_stack_registers(regs, thread, -1, NULL);
+
+    if (num_frames)
+        frames = (native_frame_t*)STD_ALLOCA(sizeof(native_frame_t)*num_frames);
+
+    if (num_frames && frames)
+        walk_native_stack_registers(regs, thread, num_frames, frames);
+    else
+        num_frames = 0; // Consider native stack trace empty
+
+   fprintf(stderr, "Stack trace:\n");
+
+    if(interpreter_enabled() && thread)
+        st_print_stack_interpreter(thread, frames, num_frames);
+    else // It should be used also for threads without VM_thread structure
+        st_print_stack_jit(thread, frames, num_frames);
+
   fprintf(stderr, "<end of stack trace>\n");
+  fflush(stderr);
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp Mon Mar 19 00:50:19 2007
@@ -30,7 +30,8 @@
 #include "class_member.h"
 #include "open/hythread.h"
 
-void get_file_and_line(Method_Handle mh, void *ip, bool is_ip_past, const char **file, int
*line) {
+void get_file_and_line(Method_Handle mh, void *ip, bool is_ip_past,
+                        int depth, const char **file, int *line) {
     Method *method = (Method*)mh;
     *file = class_get_source_file_name(method_get_class(method));
 
@@ -58,18 +59,30 @@
     POINTER_SIZE_INT callLength = 5;
 
     Global_Env * vm_env = VM_Global_State::loader_env;
-    CodeChunkInfo* jit_info = vm_env->vm_methods->find((unsigned char*)ip - callLength);
-    if (jit_info->get_jit()->get_bc_location_for_native(
-        method,
-        (NativeCodePtr) ((POINTER_SIZE_INT) ip - callLength),
-        &bcOffset) != EXE_ERROR_NONE) {
-        //
-        return;
-    }
+    CodeChunkInfo* cci = vm_env->vm_methods->find(ip, is_ip_past);
+    assert(cci);
+
+    POINTER_SIZE_INT eff_ip = (POINTER_SIZE_INT)ip -
+                                (is_ip_past ? callLength : 0);
 
-    if (is_ip_past) {
-        bcOffset--;
+    if (depth < 0) // Not inlined method
+    {
+        if (cci->get_jit()->get_bc_location_for_native(
+            method, (NativeCodePtr)eff_ip, &bcOffset) != EXE_ERROR_NONE)
+            return;
+    }
+    else // Inlined method
+    {
+        InlineInfoPtr inl_info = cci->get_inline_info();
+
+        if (inl_info)
+        {
+            uint32 offset = (uint32) ((POINTER_SIZE_INT)ip -
+                (POINTER_SIZE_INT)cci->get_code_block_addr());
+            bcOffset = cci->get_jit()->get_inlined_bc(inl_info, offset, depth);
+        }
     }
+
     *line = method->get_line_number(bcOffset);
 #endif        
 }
@@ -99,6 +112,7 @@
     unsigned depth = 0;
     while (!si_is_past_end(si)) {
         stf->method = si_get_method(si);
+        stf->depth = -1;
         if (stf->method) {
             uint32 inlined_depth = si_get_inline_depth(si);
             if ( (target_depth >= depth) && 
@@ -112,6 +126,7 @@
                     uint32 offset = (uint32)((POINTER_SIZE_INT)stf->ip - (POINTER_SIZE_INT)cci->get_code_block_addr());
                     stf->method = cci->get_jit()->get_inlined_method(
                             cci->get_inline_info(), offset, target_depth - depth);
+                    stf->depth = target_depth - depth;
                 }
 
                 si_free(si);
@@ -173,7 +188,8 @@
 
                 for (uint32 i = 0; i < inlined_depth; i++) {
                     stf->method = jit->get_inlined_method(cci->get_inline_info(),
offset, i);
-                    stf->ip = NULL;
+                    stf->ip = ip;
+                    stf->depth = i;
                     stf->outdated_this = get_this(jit, method, si);
                     stf++;
                     depth++;
@@ -182,6 +198,7 @@
             }
             stf->method = method;
             stf->ip = ip;
+            stf->depth = -1;
             stf++;
             depth++;
         }
@@ -200,7 +217,7 @@
     buf->AppendFormatBlock("\tat %s.%s%s", cname, mname, dname);
     const char *file;
     int line;
-    get_file_and_line(stf->method, stf->ip, false, &file, &line);
+    get_file_and_line(stf->method, stf->ip, false, stf->depth, &file, &line);
 
     if (line==-2)
         // Native method

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/native_stack_em64t.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/native_stack_em64t.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/native_stack_em64t.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/native_stack_em64t.cpp Mon
Mar 19 00:50:19 2007
@@ -22,54 +22,170 @@
 #include "method_lookup.h"
 #include "native_stack.h"
 
-void native_get_frame_info(Registers* regs, void** ip, /* void** ret, */ void** bp, void**
sp)
+void native_get_frame_info(Registers* regs, void** ip, void** bp, void** sp)
 {
     *ip = (void*)regs->rip;
-    //
-    // FIXME: number of parameters should be fixed in public interface
-    //
-    //*ret = ((void**)regs->rbp)[1];
     *bp = (void*)regs->rbp;
     *sp = (void*)regs->rsp;
 }
 
 bool native_unwind_bp_based_frame(void* frame, void** ip, void** bp, void** sp)
 {
-    return false; // Not implemented
+    void** frame_ptr = (void**)frame;
+
+    *ip = frame_ptr[1];
+    *bp = frame_ptr[0];
+
+    *sp = (void*)((POINTER_SIZE_INT)frame + 2*sizeof(void*));
+
+    return (*bp != NULL && *ip != NULL);
 }
 
 void native_get_ip_bp_from_si_jit_context(StackIterator* si, void** ip, void** bp)
-{ // Not implemented
+{
+    JitFrameContext* jfc = si_get_jit_context(si);
+    *ip = (void*)*jfc->p_rip;
+    *bp = (void*)*jfc->p_rbp;
 }
 
 void native_get_sp_from_si_jit_context(StackIterator* si, void** sp)
-{ // Not implemented
+{
+    *sp = (void*)si_get_jit_context(si)->rsp;
 }
 
 bool native_is_out_of_stack(void* value)
 {
-    return true; // Not implemented
+    // FIXME: Invalid criterion
+    return (value < (void*)0x10000) || (value > (void*)0x800000000000);
 }
 
 bool native_is_frame_valid(native_module_t* modules, void* bp, void* sp)
 {
-    return false; // Not implemented
+    // Check for frame layout and stack values
+    if ((bp < sp) || native_is_out_of_stack(bp))
+        return false; // Invalid frame
+
+    void** dw_ptr = (void**)bp;
+    void* ret_ip = *(dw_ptr + 1); // Return address for frame
+
+    // Check return address for meaning
+    if (!native_is_ip_in_modules(modules, ret_ip) && !native_is_ip_stub(ret_ip))
+        return false;
+
+    return true;
+}
+
+// Searches for correct return address in the stack
+// Returns stack address pointing to return address
+static void** native_search_special_frame(native_module_t* modules, void* sp)
+{
+// Max search depth for return address
+#define MAX_SPECIAL_DEPTH 0x100
+
+    POINTER_SIZE_INT sp_begin = (POINTER_SIZE_INT)sp;
+    for (POINTER_SIZE_INT sp_int = sp_begin;
+         sp_int < sp_begin + MAX_SPECIAL_DEPTH;
+         sp_int += 8) // 8 is granularity of stack
+    {
+        void** sp_pointer = (void**)sp_int;
+
+        if (native_is_ip_in_modules(modules, *sp_pointer))
+            return sp_pointer;
+    }
+
+    return NULL;
 }
 
+// Tests if stack contains non-BP-based frames on top
 int native_test_unwind_special(native_module_t* modules, void* sp)
 {
-    return false; // Not implemented
+#define MAX_SPECIAL_COUNT 16
+
+#if (!defined PLATFORM_POSIX)
+    return -1; // Because we cannot identify executable code on Windows
+#endif
+
+    if (modules == NULL)
+        return false;
+
+    int count = 0;
+    void** sp_pointer = (void**)sp;
+
+    do
+    {
+        if (native_is_ip_stub(sp_pointer[-1]))
+            break; // We've found JNI stub
+
+        // We've reached Java without native stub
+        if (vm_identify_eip(sp_pointer[-1]) == VM_TYPE_JAVA)
+            break;
+
+        void** next_sp = native_search_special_frame(modules, sp_pointer);
+
+        if (next_sp == NULL)
+            break; // We cannot unwind anymore
+
+        if (count > 0 &&                     // Check BP-frame for upper frames
+            sp_pointer[-2] >= sp_pointer &&  // Correct frame layout
+            sp_pointer[-2] == next_sp - 1 && // is RBP saved correctly
+            next_sp[-1] >= next_sp + 1)      // Correct next frame layout
+        {
+            break;
+        }
+
+        sp_pointer = next_sp + 1;
+
+    } while (++count <= MAX_SPECIAL_COUNT);
+
+    return count;
 }
 
 bool native_unwind_special(native_module_t* modules,
                 void* stack, void** ip, void** sp, void** bp, bool is_last)
 {
-    return false; // Not implemented
+    if (modules == NULL)
+    {
+        *ip = NULL;
+        return false;
+    }
+
+    void** found = NULL;
+
+    POINTER_SIZE_INT sp_begin = (POINTER_SIZE_INT)stack;
+    for (POINTER_SIZE_INT sp_int = sp_begin;
+         sp_int < sp_begin + MAX_SPECIAL_DEPTH;
+         sp_int += 8) // 8 is granularity of stack
+    {
+        void** sp_pointer = (void**)sp_int;
+
+        if (native_is_ip_in_modules(modules, *sp_pointer))
+        {
+            found = sp_pointer;
+            break;
+        }
+    }
+
+    if (!found)
+    {
+        *ip = NULL;
+        return false;
+    }
+
+    *ip = *found;
+    *sp = found + 1;
+
+    if (is_last && !native_is_ip_stub(*ip))
+        *bp = found[-1];
+    else
+        *bp = *sp;
+
+    return true;
 }
 
 void native_unwind_interrupted_frame(VM_thread* pthread, void** p_ip, void** p_bp, void**
p_sp)
-{ // Not implemented yet
-    *p_ip = NULL;
-    *p_bp = NULL;
-    *p_sp = NULL;
+{
+    Registers* pregs = &pthread->jvmti_saved_exception_registers;
+    *p_ip = (void*)pregs->rip;
+    *p_bp = (void*)pregs->rbp;
+    *p_sp = (void*)pregs->rsp;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp Mon Mar 19 00:50:19
2007
@@ -67,6 +67,7 @@
 
 #include "exception_filter.h"
 #include "interpreter.h"
+#include "stack_dump.h"
 
 // Variables used to locate the context from the signal handler
 static int sc_nest = -1;
@@ -180,21 +181,6 @@
     }
 }
 
-/**
- * Print out the call stack.
- */
-void print_native_stack (unsigned *rbp) {
-    int depth = 17;
-    LWARN(42, "Fatal error");
-    char buf[1024];
-    int n = 0;
-    while (rbp && rbp[1] && --depth >= 0 && (n<int(sizeof(buf))-20))
{
-        n += sprintf(buf+n,"%08x\n",rbp[1]);
-        rbp = (unsigned *)POINTER_SIZE_INT(rbp[0]);
-    }
-    addr2line(buf);
-}
-
 /*
  * Information about stack
  */
@@ -391,6 +377,11 @@
         }
     }
 
+    fprintf(stderr, "SIGSEGV in VM code.\n");
+    Registers regs;
+    linux_ucontext_to_regs(&regs, uc);
+    st_print_stack(&regs);
+
     // crash with default handler
     signal(signum, 0);
 }
@@ -408,6 +399,11 @@
         }
     }
     
+    fprintf(stderr, "SIGFPE in VM code.\n");
+    Registers regs;
+    linux_ucontext_to_regs(&regs, uc);
+    st_print_stack(&regs);
+
     // crash with default handler
     signal(signum, 0);
 }
@@ -532,9 +528,11 @@
  * @note call stacks may be used for debugging
  */
 void abort_handler (int signal, siginfo_t* info, void* context) {
+    fprintf(stderr, "SIGABRT in VM code.\n");
     ucontext_t *uc = (ucontext_t *)context;
-    unsigned *rbp = (unsigned *) uc->uc_mcontext.gregs[REG_RBP];
-    print_native_stack(rbp);
+    Registers regs;
+    linux_ucontext_to_regs(&regs, uc);
+    st_print_stack(&regs);
 }
 
 void initialize_signals()

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp Mon
Mar 19 00:50:19 2007
@@ -14,10 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Intel, Evgueni Brevnov
- * @version $Revision: 1.1.2.1.4.5 $
- */  
 
 #include <stdio.h>
 #include "platform_lowlevel.h"
@@ -76,29 +72,29 @@
 
 void print_state(LPEXCEPTION_POINTERS nt_exception, const char *msg)
 {
-    fprintf(stderr, "...VM Crashed!\n");
     if (msg != 0)
         fprintf(stderr, "Windows reported exception: %s\n", msg);
     else
         fprintf(stderr, "Windows reported exception: 0x%x\n", nt_exception->ExceptionRecord->ExceptionCode);
 
     fprintf(stderr, "Registers:\n");
-    fprintf(stderr, "    RAX: 0x%16lx, RBX: 0x%16lx\n",
+    fprintf(stderr, "    RAX: 0x%016I64x, RBX: 0x%016I64x\n",
         nt_exception->ContextRecord->Rax, nt_exception->ContextRecord->Rbx);
-   fprintf(stderr, "    RCX: 0x%16lx, RDX: 0x%16lx\n",
+    fprintf(stderr, "    RCX: 0x%016I64x, RDX: 0x%016I64x\n",
         nt_exception->ContextRecord->Rcx, nt_exception->ContextRecord->Rdx);
-    fprintf(stderr, "    RSI: 0x%16lx, RDI: 0x%16lx\n",
+    fprintf(stderr, "    RSI: 0x%016I64x, RDI: 0x%016I64x\n",
         nt_exception->ContextRecord->Rsi, nt_exception->ContextRecord->Rdi);
-   fprintf(stderr, "    RSP: 0x%16lx, RBP: 0x%16lx\n",
+    fprintf(stderr, "    RSP: 0x%016I64x, RBP: 0x%016I64x\n",
         nt_exception->ContextRecord->Rsp, nt_exception->ContextRecord->Rbp);
-   fprintf(stderr, "    R8:  0x%16lx, R9: 0x%16lx\n",
+    fprintf(stderr, "    R8 : 0x%016I64x, R9 : 0x%016I64x\n",
         nt_exception->ContextRecord->R8, nt_exception->ContextRecord->R9);
-   fprintf(stderr, "    R10: 0x%16lx, R11P: 0x%16lx\n",
+    fprintf(stderr, "    R10: 0x%016I64x, R11: 0x%016I64x\n",
         nt_exception->ContextRecord->R10, nt_exception->ContextRecord->R11);
-    fprintf(stderr, "    RS12: 0x%16lx, R13: 0x%16lx\n",
+    fprintf(stderr, "    R12: 0x%016I64x, R13: 0x%016I64x\n",
         nt_exception->ContextRecord->R12, nt_exception->ContextRecord->R13);
-    fprintf(stderr, "    RS14: 0x%16lx, R15: 0x%16lx\n",
+    fprintf(stderr, "    R14: 0x%016I64x, R15: 0x%016I64x\n",
         nt_exception->ContextRecord->R14, nt_exception->ContextRecord->R15);
+    fprintf(stderr, "    RIP: 0x%016I64x\n", nt_exception->ContextRecord->Rip);
 }
 
 void* regs_get_sp(Registers* pregs)

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp Mon Mar
19 00:50:19 2007
@@ -14,10 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Intel, Evgueni Brevnov
- * @version $Revision: 1.1.2.1.4.4 $
- */  
 
 #include <stdio.h>
 #include "platform_lowlevel.h"
@@ -56,18 +52,16 @@
 
 void print_state(LPEXCEPTION_POINTERS nt_exception, const char *msg)
 {
-    fprintf(stderr, "...VM Crashed!\n");
-
-   if (msg != 0)
+    if (msg != 0)
         fprintf(stderr, "Windows reported exception: %s\n", msg);
     else
         fprintf(stderr, "Windows reported exception: 0x%x\n", nt_exception->ExceptionRecord->ExceptionCode);
 
     fprintf(stderr, "Registers:\n");
-   fprintf(stderr, "    EAX: 0x%08x, EBX: 0x%08x, ECX: 0x%08x, EDX: 0x%08x\n",
+    fprintf(stderr, "    EAX: 0x%08x, EBX: 0x%08x, ECX: 0x%08x, EDX: 0x%08x\n",
         nt_exception->ContextRecord->Eax, nt_exception->ContextRecord->Ebx,
         nt_exception->ContextRecord->Ecx, nt_exception->ContextRecord->Edx);
-   fprintf(stderr, "    ESI: 0x%08x, EDI: 0x%08x, ESP: 0x%08x, EBP: 0x%08x\n",
+    fprintf(stderr, "    ESI: 0x%08x, EDI: 0x%08x, ESP: 0x%08x, EBP: 0x%08x\n",
         nt_exception->ContextRecord->Esi, nt_exception->ContextRecord->Edi,
         nt_exception->ContextRecord->Esp, nt_exception->ContextRecord->Ebp);
     fprintf(stderr, "    EIP: 0x%08x\n", nt_exception->ContextRecord->Eip);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32_em64t/nt_exception_filter_common.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32_em64t/nt_exception_filter_common.cpp?view=diff&rev=519866&r1=519865&r2=519866
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32_em64t/nt_exception_filter_common.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32_em64t/nt_exception_filter_common.cpp
Mon Mar 19 00:50:19 2007
@@ -47,9 +47,30 @@
     Registers regs;
     nt_to_vm_context(context, &regs);
     st_print_stack(&regs);
-    fflush(stderr);
 }
 
+
+static LONG process_crash(LPEXCEPTION_POINTERS nt_exception, const char* msg = NULL)
+{
+    Registers regs;
+    nt_to_vm_context(nt_exception->ContextRecord, &regs);
+
+    // Check crash location to prevent infinite recursion
+    if (regs.get_ip() == p_TLS_vmthread->regs.get_ip())
+        return EXCEPTION_CONTINUE_SEARCH;
+    // Store registers to compare IP in future
+    p_TLS_vmthread->regs = regs;
+
+    if (get_boolean_property("vm.assert_dialog", TRUE, VM_PROPERTIES))
+        return EXCEPTION_CONTINUE_SEARCH;
+
+    print_state(nt_exception, msg);
+    print_callstack(nt_exception);
+    LOGGER_EXIT(-1);
+    return EXCEPTION_CONTINUE_EXECUTION;
+}
+
+
 /*
  * Information about stack
  */
@@ -188,6 +209,7 @@
     nt_to_vm_context(context, &regs);
     POINTER_SIZE_INT saved_eip = (POINTER_SIZE_INT)regs.get_ip();
 
+    assert(p_TLS_vmthread);
     // If exception is occured in processor instruction previously
     // instrumented by breakpoint, the actual exception address will reside
     // in jvmti_jit_breakpoints_handling_buffer
@@ -223,9 +245,10 @@
     // delegate "other" cases to default handler
     if (!in_java && code != STATUS_STACK_OVERFLOW)
     {
+        LONG result = process_crash(nt_exception);
         regs.set_ip((void*)saved_eip);
         vm_to_nt_context(&regs, context);
-        return EXCEPTION_CONTINUE_SEARCH;
+        return result;
     }
 
     // if HWE occured in java code, suspension should also have been disabled
@@ -300,10 +323,10 @@
         }
     default:
         // unexpected hardware exception occured in java code
-        print_callstack(nt_exception);
+        LONG result = process_crash(nt_exception);
         regs.set_ip((void*)saved_eip);
         vm_to_nt_context(&regs, context);
-        return EXCEPTION_CONTINUE_SEARCH;
+        return result;
     }
 
     // we must not call potentially blocking or suspendable code
@@ -316,7 +339,6 @@
 
     // save register context of hardware exception site
     // into thread-local registers snapshot
-    assert(p_TLS_vmthread);
     p_TLS_vmthread->regs = regs;
 
     // __cdecl <=> push parameters in the reversed order



Mime
View raw message