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

Side by Side Diff: src/api.cc

Issue 171042: Added API call to get the stack trace for an exception (Closed)
Patch Set: Created 11 years, 4 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 unified diff | Download patch
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 if (HasCaught()) { 1212 if (HasCaught()) {
1213 // Check for out of memory exception. 1213 // Check for out of memory exception.
1214 i::Object* exception = reinterpret_cast<i::Object*>(exception_); 1214 i::Object* exception = reinterpret_cast<i::Object*>(exception_);
1215 return v8::Utils::ToLocal(i::Handle<i::Object>(exception)); 1215 return v8::Utils::ToLocal(i::Handle<i::Object>(exception));
1216 } else { 1216 } else {
1217 return v8::Local<Value>(); 1217 return v8::Local<Value>();
1218 } 1218 }
1219 } 1219 }
1220 1220
1221 1221
1222 v8::Local<Value> v8::TryCatch::StackTrace() const {
1223 if (HasCaught()) {
1224 i::Object* raw_ptr = reinterpret_cast<i::Object*>(exception_);
1225 if (!raw_ptr->IsJSObject()) return v8::Local<Value>();
1226 v8::HandleScope scope;
1227 i::Handle<i::Object> raw_obj(raw_ptr);
Søren Thygesen Gjesse 2009/08/17 13:30:16 Why not just i::Handle<i::JSObject> obj(i::JSObje
Christian Plesner Hansen 2009/08/17 13:33:59 Done
1228 i::Handle<i::JSObject> obj = i::Handle<i::JSObject>::cast(raw_obj);
1229 i::Handle<i::String> name = i::Factory::LookupAsciiSymbol("stack");
1230 if (!obj->HasProperty(*name))
1231 return v8::Local<Value>();
1232 return scope.Close(v8::Utils::ToLocal(i::GetProperty(obj, name)));
1233 } else {
1234 return v8::Local<Value>();
1235 }
1236 }
1237
1238
1222 v8::Local<v8::Message> v8::TryCatch::Message() const { 1239 v8::Local<v8::Message> v8::TryCatch::Message() const {
1223 if (HasCaught() && message_ != i::Smi::FromInt(0)) { 1240 if (HasCaught() && message_ != i::Smi::FromInt(0)) {
1224 i::Object* message = reinterpret_cast<i::Object*>(message_); 1241 i::Object* message = reinterpret_cast<i::Object*>(message_);
1225 return v8::Utils::MessageToLocal(i::Handle<i::Object>(message)); 1242 return v8::Utils::MessageToLocal(i::Handle<i::Object>(message));
1226 } else { 1243 } else {
1227 return v8::Local<v8::Message>(); 1244 return v8::Local<v8::Message>();
1228 } 1245 }
1229 } 1246 }
1230 1247
1231 1248
(...skipping 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after
3679 reinterpret_cast<HandleScopeImplementer*>(storage); 3696 reinterpret_cast<HandleScopeImplementer*>(storage);
3680 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); 3697 List<void**>* blocks_of_archived_thread = thread_local->Blocks();
3681 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = 3698 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread =
3682 &thread_local->handle_scope_data_; 3699 &thread_local->handle_scope_data_;
3683 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); 3700 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread);
3684 3701
3685 return storage + ArchiveSpacePerThread(); 3702 return storage + ArchiveSpacePerThread();
3686 } 3703 }
3687 3704
3688 } } // namespace v8::internal 3705 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698