You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2008/03/20 17:05:56 UTC
svn commit: r639337 - in
/harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler:
em64t/native_unwind_arch.cpp ia32/native_unwind_arch.cpp native_unwind.cpp
Author: gshimansky
Date: Thu Mar 20 09:05:54 2008
New Revision: 639337
URL: http://svn.apache.org/viewvc?rev=639337&view=rev
Log:
Applied patch from HARMONY-5618
[drlvm][port][signals] Fix for native stack unwinding
Modified:
harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/em64t/native_unwind_arch.cpp
harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/ia32/native_unwind_arch.cpp
harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/native_unwind.cpp
Modified: harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/em64t/native_unwind_arch.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/em64t/native_unwind_arch.cpp?rev=639337&r1=639336&r2=639337&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/em64t/native_unwind_arch.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/em64t/native_unwind_arch.cpp Thu Mar 20 09:05:54 2008
@@ -24,49 +24,6 @@
#include "native_unwind.h"
-bool native_is_frame_exists(UnwindContext* context, Registers* regs)
-{
- // Check for frame layout and stack values
- if ((regs->rbp < regs->rsp) || !native_is_in_stack(context, (void*)regs->rbp))
- return false; // Invalid frame
-
- void** frame_ptr = (void**)regs->rbp;
- void* rip = frame_ptr[1]; // Return address
-
- // Check return address for meaning
- return (native_is_in_code(context, rip));
-}
-
-bool native_unwind_stack_frame(UnwindContext* context, Registers* regs)
-{
- void** frame = (void**)regs->rbp;
-
- void* rbp = frame[0];
- void* rip = frame[1];
-// void* rsp = (void*)(frame + 2);
- void* rsp = &frame[2];
-
-
- if (native_is_in_stack(context, rsp) &&
- (native_is_in_code(context, rip)))
- {
- regs->rbp = (uint64)rbp;
- regs->rsp = (uint64)rsp;
- regs->rip = (uint64)rip;
- return true;
- }
-
- return false;
-}
-
-static bool fill_regs_from_sp(UnwindContext* context, Registers* regs, void** sp)
-{
- regs->rsp = (uint64)(sp + 1);
- regs->rip = (uint64)*sp;
- regs->rbp = native_is_in_stack(context, sp[-1]) ? (uint64)sp[-1] : regs->rsp;
- return true;
-}
-
static unsigned native_dec_instr(UnwindContext* context, void* addr, void** target)
{
Inst inst;
@@ -112,6 +69,49 @@
}
return false;
+}
+
+bool native_is_frame_exists(UnwindContext* context, Registers* regs)
+{
+ // Check for frame layout and stack values
+ if ((regs->rbp < regs->rsp) || !native_is_in_stack(context, (void*)regs->rbp))
+ return false; // Invalid frame
+
+ void** frame_ptr = (void**)regs->rbp;
+ void* rip = frame_ptr[1]; // Return address
+
+ // Check return address for meaning
+ return (native_is_in_code(context, rip) && native_check_caller(context, regs, frame_ptr + 1));
+}
+
+bool native_unwind_stack_frame(UnwindContext* context, Registers* regs)
+{
+ void** frame = (void**)regs->rbp;
+
+ void* rbp = frame[0];
+ void* rip = frame[1];
+// void* rsp = (void*)(frame + 2);
+ void* rsp = &frame[2];
+
+
+ if (native_is_in_stack(context, rsp) &&
+ (native_is_in_code(context, rip)))
+ {
+ regs->rbp = (uint64)rbp;
+ regs->rsp = (uint64)rsp;
+ regs->rip = (uint64)rip;
+ return true;
+ }
+
+ return false;
+}
+
+static bool fill_regs_from_sp(UnwindContext* context, Registers* regs, void** sp)
+{
+ regs->rsp = (uint64)(sp + 1);
+ regs->rip = (uint64)*sp;
+ regs->rbp = native_is_in_stack(context, sp[-1]) ? (uint64)sp[-1] : regs->rsp;
+ return true;
}
Modified: harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/ia32/native_unwind_arch.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/ia32/native_unwind_arch.cpp?rev=639337&r1=639336&r2=639337&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/ia32/native_unwind_arch.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/ia32/native_unwind_arch.cpp Thu Mar 20 09:05:54 2008
@@ -24,49 +24,6 @@
#include "native_unwind.h"
-bool native_is_frame_exists(UnwindContext* context, Registers* regs)
-{
- // Check for frame layout and stack values
- if ((regs->ebp < regs->esp) || !native_is_in_stack(context, (void*)regs->ebp))
- return false; // Invalid frame
-
- void** frame_ptr = (void**)regs->ebp;
- void* eip = frame_ptr[1]; // Return address
-
- // Check return address for meaning
- return (native_is_in_code(context, eip));
-}
-
-bool native_unwind_stack_frame(UnwindContext* context, Registers* regs)
-{
- void** frame = (void**)regs->ebp;
-
- void* ebp = frame[0];
- void* eip = frame[1];
-// void* esp = (void*)(frame + 2);
- void* esp = &frame[2];
-
-
- if (native_is_in_stack(context, esp) &&
- (native_is_in_code(context, eip)))
- {
- regs->ebp = (uint32)ebp;
- regs->esp = (uint32)esp;
- regs->eip = (uint32)eip;
- return true;
- }
-
- return false;
-}
-
-static bool fill_regs_from_sp(UnwindContext* context, Registers* regs, void** sp)
-{
- regs->esp = (uint32)(sp + 1);
- regs->eip = (uint32)*sp;
- regs->ebp = native_is_in_stack(context, sp[-1]) ? (uint32)sp[-1] : regs->esp;
- return true;
-}
-
static unsigned native_dec_instr(UnwindContext* context, void* addr, void** target)
{
Inst inst;
@@ -112,6 +69,49 @@
}
return false;
+}
+
+bool native_is_frame_exists(UnwindContext* context, Registers* regs)
+{
+ // Check for frame layout and stack values
+ if ((regs->ebp < regs->esp) || !native_is_in_stack(context, (void*)regs->ebp))
+ return false; // Invalid frame
+
+ void** frame_ptr = (void**)regs->ebp;
+ void* eip = frame_ptr[1]; // Return address
+
+ // Check return address for meaning
+ return (native_is_in_code(context, eip) && native_check_caller(context, regs, frame_ptr + 1));
+}
+
+bool native_unwind_stack_frame(UnwindContext* context, Registers* regs)
+{
+ void** frame = (void**)regs->ebp;
+
+ void* ebp = frame[0];
+ void* eip = frame[1];
+// void* esp = (void*)(frame + 2);
+ void* esp = &frame[2];
+
+
+ if (native_is_in_stack(context, esp) &&
+ (native_is_in_code(context, eip)))
+ {
+ regs->ebp = (uint32)ebp;
+ regs->esp = (uint32)esp;
+ regs->eip = (uint32)eip;
+ return true;
+ }
+
+ return false;
+}
+
+static bool fill_regs_from_sp(UnwindContext* context, Registers* regs, void** sp)
+{
+ regs->esp = (uint32)(sp + 1);
+ regs->eip = (uint32)*sp;
+ regs->ebp = native_is_in_stack(context, sp[-1]) ? (uint32)sp[-1] : regs->esp;
+ return true;
}
Modified: harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/native_unwind.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/native_unwind.cpp?rev=639337&r1=639336&r2=639337&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/native_unwind.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/native_unwind.cpp Thu Mar 20 09:05:54 2008
@@ -87,11 +87,11 @@
bool port_unwind_frame(UnwindContext* context, Registers* regs)
{
-// if (native_is_frame_exists(context, regs))
-// { // Stack frame (x86)
-// return native_unwind_stack_frame(context, regs);
-// }
-// else
+ if (native_is_frame_exists(context, regs))
+ { // Stack frame (x86)
+ return native_unwind_stack_frame(context, regs);
+ }
+ else
{ // Stack frame does not exist, try using heuristics
return native_unwind_special(context, regs);
}