Reviewers: yangguo,

Description:
Introduce v8::Exception::GetStackTrace API method.

This will be needed to get a stack trace from a DOMException.

API=v8::Exception::GetStackTrace
R=yangguo
LOG=Y

Please review this at https://codereview.chromium.org/655243002/

Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+17, -0 lines):
  M include/v8.h
  M src/api.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index b231912eeb2ae91f19e8890206055ffb9a987b9a..f2f47a66e721b29b6eeb3da0f12311c2171e2e64 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -4164,6 +4164,8 @@ class V8_EXPORT Exception {
   static Local<Value> SyntaxError(Handle<String> message);
   static Local<Value> TypeError(Handle<String> message);
   static Local<Value> Error(Handle<String> message);
+
+  static Local<StackTrace> GetStackTrace(Handle<Value> exception);
 };


Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index fe56c2b8904d590a2861f2d991625a574bd82373..0febe84e589482166394086a14fc54825f3edda7 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -6926,6 +6926,21 @@ DEFINE_ERROR(Error)
 #undef DEFINE_ERROR


+Local<StackTrace> Exception::GetStackTrace(Handle<Value> exception) {
+  i::Handle<i::Object> obj = Utils::OpenHandle(*exception);
+  if (!obj->IsJSObject()) return Local<StackTrace>();
+  i::Handle<i::JSObject> js_obj = i::Handle<i::JSObject>::cast(obj);
+  i::Isolate* isolate = js_obj->GetIsolate();
+  ENTER_V8(isolate);
+ i::Handle<i::Name> key = isolate->factory()->detailed_stack_trace_symbol(); + i::Handle<i::Object> property = i::JSObject::GetDataProperty(js_obj, key);
+  if (property->IsJSArray()) {
+    return Utils::StackTraceToLocal(i::Handle<i::JSArray>::cast(property));
+  }
+  return Local<StackTrace>();
+}
+
+
 // --- D e b u g   S u p p o r t ---

 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) {


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to