Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: src/api.cc

Issue 2028001: Adds C++ API for retrieving a stack trace without running JavaScript... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/api.h ('k') | src/messages.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
===================================================================
--- src/api.cc (revision 4596)
+++ src/api.cc (working copy)
@@ -1438,7 +1438,7 @@
int Message::GetLineNumber() const {
- ON_BAILOUT("v8::Message::GetLineNumber()", return -1);
+ ON_BAILOUT("v8::Message::GetLineNumber()", return kNoLineNumberInfo);
ENTER_V8;
HandleScope scope;
EXCEPTION_PREAMBLE();
@@ -1470,7 +1470,7 @@
int Message::GetStartColumn() const {
- if (IsDeadCheck("v8::Message::GetStartColumn()")) return 0;
+ if (IsDeadCheck("v8::Message::GetStartColumn()")) return kNoColumnInfo;
ENTER_V8;
HandleScope scope;
i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
@@ -1485,7 +1485,7 @@
int Message::GetEndColumn() const {
- if (IsDeadCheck("v8::Message::GetEndColumn()")) return 0;
+ if (IsDeadCheck("v8::Message::GetEndColumn()")) return kNoColumnInfo;
ENTER_V8;
HandleScope scope;
i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
@@ -1525,6 +1525,118 @@
}
+// --- S t a c k T r a c e ---
+
+Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
+ if (IsDeadCheck("v8::StackTrace::GetFrame()")) return Local<StackFrame>();
+ ENTER_V8;
+ HandleScope scope;
+ i::Handle<i::JSArray> self = Utils::OpenHandle(this);
+ i::Handle<i::JSObject> obj(i::JSObject::cast(self->GetElement(index)));
+ return scope.Close(Utils::StackFrameToLocal(obj));
+}
+
+
+int StackTrace::GetFrameCount() const {
+ if (IsDeadCheck("v8::StackTrace::GetFrameCount()")) return -1;
+ ENTER_V8;
+ return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
+}
+
+
+Local<Array> StackTrace::AsArray() {
+ if (IsDeadCheck("v8::StackTrace::AsArray()")) Local<Array>();
+ ENTER_V8;
+ return Utils::ToLocal(Utils::OpenHandle(this));
+}
+
+
+Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit,
+ StackTraceOptions options) {
+ if (IsDeadCheck("v8::StackTrace::CurrentStackTrace()")) Local<StackTrace>();
+ ENTER_V8;
+ return i::Top::CaptureCurrentStackTrace(frame_limit, options);
+}
+
+
+// --- S t a c k F r a m e ---
+
+int StackFrame::GetLineNumber() const {
+ if (IsDeadCheck("v8::StackFrame::GetLineNumber()")) {
+ return Message::kNoLineNumberInfo;
+ }
+ ENTER_V8;
+ i::HandleScope scope;
+ i::Handle<i::JSObject> self = Utils::OpenHandle(this);
+ i::Handle<i::Object> line = GetProperty(self, "lineNumber");
+ if (!line->IsSmi()) {
+ return Message::kNoLineNumberInfo;
+ }
+ return i::Smi::cast(*line)->value();
+}
+
+
+int StackFrame::GetColumn() const {
+ if (IsDeadCheck("v8::StackFrame::GetColumn()")) {
+ return Message::kNoColumnInfo;
+ }
+ ENTER_V8;
+ i::HandleScope scope;
+ i::Handle<i::JSObject> self = Utils::OpenHandle(this);
+ i::Handle<i::Object> column = GetProperty(self, "column");
+ if (!column->IsSmi()) {
+ return Message::kNoColumnInfo;
+ }
+ return i::Smi::cast(*column)->value();
+}
+
+
+Local<String> StackFrame::GetScriptName() const {
+ if (IsDeadCheck("v8::StackFrame::GetScriptName()")) return Local<String>();
+ ENTER_V8;
+ HandleScope scope;
+ i::Handle<i::JSObject> self = Utils::OpenHandle(this);
+ i::Handle<i::Object> name = GetProperty(self, "scriptName");
+ if (!name->IsString()) {
+ return Local<String>();
+ }
+ return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
+}
+
+
+Local<String> StackFrame::GetFunctionName() const {
+ if (IsDeadCheck("v8::StackFrame::GetFunctionName()")) return Local<String>();
+ ENTER_V8;
+ HandleScope scope;
+ i::Handle<i::JSObject> self = Utils::OpenHandle(this);
+ i::Handle<i::Object> name = GetProperty(self, "functionName");
+ if (!name->IsString()) {
+ return Local<String>();
+ }
+ return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
+}
+
+
+bool StackFrame::IsEval() const {
+ if (IsDeadCheck("v8::StackFrame::IsEval()")) return false;
+ ENTER_V8;
+ i::HandleScope scope;
+ i::Handle<i::JSObject> self = Utils::OpenHandle(this);
+ i::Handle<i::Object> is_eval = GetProperty(self, "isEval");
+ return is_eval->IsTrue();
+}
+
+
+bool StackFrame::IsConstructor() const {
+ if (IsDeadCheck("v8::StackFrame::IsConstructor()")) return false;
+ ENTER_V8;
+ i::HandleScope scope;
+ i::Handle<i::JSObject> self = Utils::OpenHandle(this);
+ i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor");
+ return is_constructor->IsTrue();
+}
+
+
// --- D a t a ---
bool Value::IsUndefined() const {
« no previous file with comments | « src/api.h ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698