Inspector should display information about non-object exceptions
https://bugs.webkit.org/show_bug.cgi?id=114123

Reviewed by Adele Peterson.

Source/JavaScriptCore:

Make sure we store the right stack information, even when throwing
a primitive.

* interpreter/CallFrame.h:
(JSC::ExecState::clearSupplementaryExceptionInfo):
(ExecState):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::addStackTraceIfNecessary):
(JSC::Interpreter::throwException):

Source/WebCore:

Make use of the stack trace for line information when we're reporting
an exception

* bindings/js/JSDOMBinding.cpp:
(WebCore::reportException):

LayoutTests:

All these tests throw primitives as exceptions, and now they have source
and line number information

* fast/dom/exception-getting-event-handler-expected.txt:
* fast/dom/javascript-url-exception-isolation-expected.txt:
* fast/dom/nested-script-exceptions-expected.txt:
* fast/events/onerror-no-constructor-expected.txt:
* fast/events/window-onerror13-expected.txt:
* fast/events/window-onerror16-expected.txt:
* fast/events/window-onerror2-expected.txt:
* fast/events/window-onerror8-expected.txt:
* fast/js/uncaught-exception-line-number-expected.txt:
* fast/sub-pixel/inline-block-with-padding-expected.txt:
* platform/mac/fast/AppleScript/001-expected.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147872 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 9c8bbdb..b1e0c4f 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,20 @@
+2013-04-07  Oliver Hunt  <oliver@apple.com>
+
+        Inspector should display information about non-object exceptions
+        https://bugs.webkit.org/show_bug.cgi?id=114123
+
+        Reviewed by Adele Peterson.
+
+        Make sure we store the right stack information, even when throwing
+        a primitive.
+
+        * interpreter/CallFrame.h:
+        (JSC::ExecState::clearSupplementaryExceptionInfo):
+        (ExecState):
+        * interpreter/Interpreter.cpp:
+        (JSC::Interpreter::addStackTraceIfNecessary):
+        (JSC::Interpreter::throwException):
+
 2013-04-06  Oliver Hunt  <oliver@apple.com>
 
         Unify the many and varied stack trace mechanisms, and make the result sane.
diff --git a/Source/JavaScriptCore/interpreter/CallFrame.h b/Source/JavaScriptCore/interpreter/CallFrame.h
index 716115ba..746d334 100644
--- a/Source/JavaScriptCore/interpreter/CallFrame.h
+++ b/Source/JavaScriptCore/interpreter/CallFrame.h
@@ -68,6 +68,11 @@
         // But they're used in many places in legacy code, so they're not going away any time soon.
 
         void clearException() { globalData().exception = JSValue(); }
+        void clearSupplementaryExceptionInfo()
+        {
+            globalData().exceptionStack = RefCountedArray<StackFrame>();
+        }
+
         JSValue exception() const { return globalData().exception; }
         bool hadException() const { return globalData().exception; }
 
diff --git a/Source/JavaScriptCore/interpreter/Interpreter.cpp b/Source/JavaScriptCore/interpreter/Interpreter.cpp
index 62a41da..e955428 100644
--- a/Source/JavaScriptCore/interpreter/Interpreter.cpp
+++ b/Source/JavaScriptCore/interpreter/Interpreter.cpp
@@ -761,9 +761,10 @@
 
     Vector<StackFrame> stackTrace;
     getStackTrace(&callFrame->globalData(), stackTrace);
-    
+    globalData->exceptionStack = RefCountedArray<StackFrame>(stackTrace);
     if (stackTrace.isEmpty() || !error.isObject())
         return;
+
     JSObject* errorObject = asObject(error);
     JSGlobalObject* globalObject = 0;
     if (isTerminatedExecutionException(error) || isInterruptedExecutionException(error))
@@ -810,6 +811,12 @@
         }
 
         isInterrupt = isInterruptedExecutionException(exception) || isTerminatedExecutionException(exception);
+    } else {
+        if (!callFrame->globalData().exceptionStack.size()) {
+            Vector<StackFrame> stack;
+            Interpreter::getStackTrace(&callFrame->globalData(), stack);
+            callFrame->globalData().exceptionStack = RefCountedArray<StackFrame>(stack);
+        }
     }
 
     if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) {