Revision: 11516
Author:   [email protected]
Date:     Fri May  4 06:20:41 2012
Log: Intercept a crash, put debug information onto the stack and then abort gracefully.

BUG=125128
TEST=

Review URL: https://chromiumcodereview.appspot.com/10375009
http://code.google.com/p/v8/source/detail?r=11516

Modified:
 /branches/bleeding_edge/src/debug.cc
 /branches/bleeding_edge/src/debug.h

=======================================
--- /branches/bleeding_edge/src/debug.cc        Thu May  3 10:31:34 2012
+++ /branches/bleeding_edge/src/debug.cc        Fri May  4 06:20:41 2012
@@ -890,6 +890,16 @@
   v->VisitPointer(BitCast<Object**>(&(debug_break_return_)));
   v->VisitPointer(BitCast<Object**>(&(debug_break_slot_)));
 }
+
+
+void Debug::PutValuesOnStackAndDie(int start,
+                                   Address c_entry_fp,
+                                   Address last_fp,
+                                   Address larger_fp,
+                                   int count,
+                                   int end) {
+  OS::Abort();
+}


 Object* Debug::Break(Arguments args) {
@@ -984,10 +994,33 @@
       // Count frames until target frame
       int count = 0;
       JavaScriptFrameIterator it(isolate_);
-      while (!it.done() && it.frame()->fp() != thread_local_.last_fp_) {
+      while (!it.done() && it.frame()->fp() < thread_local_.last_fp_) {
         count++;
         it.Advance();
       }
+
+      // Catch the cases that would lead to crashes and capture
+      // - C entry FP at which to start stack crawl.
+      // - FP of the frame at which we plan to stop stepping out (last FP).
+      // - current FP that's larger than last FP.
+      // - Counter for the number of steps to step out.
+      if (it.done()) {
+        // We crawled the entire stack, never reaching last_fp_.
+        PutValuesOnStackAndDie(0xBEEEEEEE,
+                               frame->fp(),
+                               thread_local_.last_fp_,
+                               NULL,
+                               count,
+                               0xFEEEEEEE);
+      } else if (it.frame()->fp() != thread_local_.last_fp_) {
+        // We crawled over last_fp_, without getting a match.
+        PutValuesOnStackAndDie(0xBEEEEEEE,
+                               frame->fp(),
+                               thread_local_.last_fp_,
+                               it.frame()->fp(),
+                               count,
+                               0xFEEEEEEE);
+      }

       // If we found original frame
       if (it.frame()->fp() == thread_local_.last_fp_) {
=======================================
--- /branches/bleeding_edge/src/debug.h Thu May  3 10:31:34 2012
+++ /branches/bleeding_edge/src/debug.h Fri May  4 06:20:41 2012
@@ -232,6 +232,12 @@
   void PreemptionWhileInDebugger();
   void Iterate(ObjectVisitor* v);

+  NO_INLINE(void PutValuesOnStackAndDie(int start,
+                                        Address c_entry_fp,
+                                        Address last_fp,
+                                        Address larger_fp,
+                                        int count,
+                                        int end));
   Object* Break(Arguments args);
   void SetBreakPoint(Handle<SharedFunctionInfo> shared,
                      Handle<Object> break_point_object,

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to