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

Side by Side Diff: runtime/vm/object.cc

Issue 12316116: Add functionality to get full stack trace when exceptions are thrown. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 #define INVISIBLE_LIST(V) \ 126 #define INVISIBLE_LIST(V) \
127 V(CoreLibrary, Object, _noSuchMethod) \ 127 V(CoreLibrary, Object, _noSuchMethod) \
128 V(CoreLibrary, List, _throwArgumentError) \ 128 V(CoreLibrary, List, _throwArgumentError) \
129 V(CoreLibrary, AssertionErrorImplementation, _throwNew) \ 129 V(CoreLibrary, AssertionErrorImplementation, _throwNew) \
130 V(CoreLibrary, TypeErrorImplementation, _throwNew) \ 130 V(CoreLibrary, TypeErrorImplementation, _throwNew) \
131 V(CoreLibrary, FallThroughErrorImplementation, _throwNew) \ 131 V(CoreLibrary, FallThroughErrorImplementation, _throwNew) \
132 V(CoreLibrary, AbstractClassInstantiationErrorImplementation, _throwNew) \ 132 V(CoreLibrary, AbstractClassInstantiationErrorImplementation, _throwNew) \
133 V(CoreLibrary, NoSuchMethodError, _throwNew) \ 133 V(CoreLibrary, NoSuchMethodError, _throwNew) \
134 V(CoreLibrary, int, _throwFormatException) \ 134 V(CoreLibrary, int, _throwFormatException) \
135 V(CoreLibrary, int, _parse) \ 135 V(CoreLibrary, int, _parse) \
136 V(CoreLibrary, StackTrace, _setupFullStackTrace) \
136 137
137 138
138 static void MarkFunctionAsInvisible(const Library& lib, 139 static void MarkFunctionAsInvisible(const Library& lib,
139 const char* class_name, 140 const char* class_name,
140 const char* function_name) { 141 const char* function_name) {
141 ASSERT(!lib.IsNull()); 142 ASSERT(!lib.IsNull());
142 const Class& cls = Class::Handle( 143 const Class& cls = Class::Handle(
143 lib.LookupClass(String::Handle(String::New(class_name)))); 144 lib.LookupClass(String::Handle(String::New(class_name))));
144 ASSERT(!cls.IsNull()); 145 ASSERT(!cls.IsNull());
145 const Function& function = 146 const Function& function =
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 RegisterPrivateClass(cls, Symbols::ExternalOneByteString(), core_lib); 776 RegisterPrivateClass(cls, Symbols::ExternalOneByteString(), core_lib);
776 pending_classes.Add(cls, Heap::kOld); 777 pending_classes.Add(cls, Heap::kOld);
777 778
778 cls = Class::NewStringClass(kExternalTwoByteStringCid); 779 cls = Class::NewStringClass(kExternalTwoByteStringCid);
779 object_store->set_external_two_byte_string_class(cls); 780 object_store->set_external_two_byte_string_class(cls);
780 RegisterPrivateClass(cls, Symbols::ExternalTwoByteString(), core_lib); 781 RegisterPrivateClass(cls, Symbols::ExternalTwoByteString(), core_lib);
781 pending_classes.Add(cls, Heap::kOld); 782 pending_classes.Add(cls, Heap::kOld);
782 783
783 cls = Class::New<Stacktrace>(); 784 cls = Class::New<Stacktrace>();
784 object_store->set_stacktrace_class(cls); 785 object_store->set_stacktrace_class(cls);
785 RegisterClass(cls, Symbols::Stacktrace(), core_lib); 786 RegisterClass(cls, Symbols::StackTrace(), core_lib);
786 pending_classes.Add(cls, Heap::kOld); 787 pending_classes.Add(cls, Heap::kOld);
787 // Super type set below, after Object is allocated. 788 // Super type set below, after Object is allocated.
788 789
789 cls = Class::New<JSRegExp>(); 790 cls = Class::New<JSRegExp>();
790 object_store->set_jsregexp_class(cls); 791 object_store->set_jsregexp_class(cls);
791 RegisterPrivateClass(cls, Symbols::JSSyntaxRegExp(), core_lib); 792 RegisterPrivateClass(cls, Symbols::JSSyntaxRegExp(), core_lib);
792 pending_classes.Add(cls, Heap::kOld); 793 pending_classes.Add(cls, Heap::kOld);
793 794
794 // Initialize the base interfaces used by the core VM classes. 795 // Initialize the base interfaces used by the core VM classes.
795 script = Bootstrap::LoadCoreScript(false); 796 script = Bootstrap::LoadCoreScript(false);
(...skipping 12071 matching lines...) Expand 10 before | Expand all | Expand 10 after
12867 void Stacktrace::set_code_array(const Array& code_array) const { 12868 void Stacktrace::set_code_array(const Array& code_array) const {
12868 StorePointer(&raw_ptr()->code_array_, code_array.raw()); 12869 StorePointer(&raw_ptr()->code_array_, code_array.raw());
12869 } 12870 }
12870 12871
12871 12872
12872 void Stacktrace::set_pc_offset_array(const Array& pc_offset_array) const { 12873 void Stacktrace::set_pc_offset_array(const Array& pc_offset_array) const {
12873 StorePointer(&raw_ptr()->pc_offset_array_, pc_offset_array.raw()); 12874 StorePointer(&raw_ptr()->pc_offset_array_, pc_offset_array.raw());
12874 } 12875 }
12875 12876
12876 12877
12878 void Stacktrace::set_catch_func_array(const Array& function_array) const {
12879 StorePointer(&raw_ptr()->catch_func_array_, function_array.raw());
12880 }
12881
12882
12883 void Stacktrace::set_catch_code_array(const Array& code_array) const {
12884 StorePointer(&raw_ptr()->catch_code_array_, code_array.raw());
12885 }
12886
12887
12888 void Stacktrace::set_catch_pc_offset_array(const Array& pc_offset_array) const {
12889 StorePointer(&raw_ptr()->catch_pc_offset_array_, pc_offset_array.raw());
12890 }
12891
12892
12877 RawStacktrace* Stacktrace::New(const Array& func_array, 12893 RawStacktrace* Stacktrace::New(const Array& func_array,
12878 const Array& code_array, 12894 const Array& code_array,
12879 const Array& pc_offset_array, 12895 const Array& pc_offset_array,
12880 Heap::Space space) { 12896 Heap::Space space) {
12881 ASSERT(Isolate::Current()->object_store()->stacktrace_class() != 12897 ASSERT(Isolate::Current()->object_store()->stacktrace_class() !=
12882 Class::null()); 12898 Class::null());
12883 Stacktrace& result = Stacktrace::Handle(); 12899 Stacktrace& result = Stacktrace::Handle();
12884 { 12900 {
12885 RawObject* raw = Object::Allocate(Stacktrace::kClassId, 12901 RawObject* raw = Object::Allocate(Stacktrace::kClassId,
12886 Stacktrace::InstanceSize(), 12902 Stacktrace::InstanceSize(),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
12921 obj = func_list.At(j); 12937 obj = func_list.At(j);
12922 function_array.SetAt(i, obj); 12938 function_array.SetAt(i, obj);
12923 obj = code_list.At(j); 12939 obj = code_list.At(j);
12924 code_array.SetAt(i, obj); 12940 code_array.SetAt(i, obj);
12925 obj = pc_offset_list.At(j); 12941 obj = pc_offset_list.At(j);
12926 pc_offset_array.SetAt(i, obj); 12942 pc_offset_array.SetAt(i, obj);
12927 } 12943 }
12928 } 12944 }
12929 12945
12930 12946
12947 void Stacktrace::SetCatchStacktrace(const Array& func_array,
12948 const Array& code_array,
12949 const Array& pc_offset_array) const {
12950 StorePointer(&raw_ptr()->catch_func_array_, func_array.raw());
12951 StorePointer(&raw_ptr()->catch_code_array_, code_array.raw());
12952 StorePointer(&raw_ptr()->catch_pc_offset_array_, pc_offset_array.raw());
12953 }
12954
12955
12956 RawString* Stacktrace::FullStacktrace() const {
12957 const Array& func_array = Array::Handle(raw_ptr()->catch_func_array_);
12958 if (!func_array.IsNull()) {
12959 const Array& code_array = Array::Handle(raw_ptr()->catch_code_array_);
12960 const Array& pc_offset_array =
12961 Array::Handle(raw_ptr()->catch_pc_offset_array_);
12962 const Stacktrace& catch_trace = Stacktrace::Handle(
12963 Stacktrace::New(func_array, code_array, pc_offset_array));
12964 const String& trace =
12965 String::Handle(String::New(catch_trace.ToCStringInternal()));
12966 const String& throw_trace =
12967 String::Handle(String::New(ToCStringInternal()));
12968 return String::Concat(throw_trace, trace);
12969 }
12970 return String::New(ToCStringInternal());
12971 }
12972
12973
12931 const char* Stacktrace::ToCString() const { 12974 const char* Stacktrace::ToCString() const {
12975 const String& trace = String::Handle(FullStacktrace());
12976 return trace.ToCString();
12977 }
12978
12979
12980 const char* Stacktrace::ToCStringInternal() const {
12932 Isolate* isolate = Isolate::Current(); 12981 Isolate* isolate = Isolate::Current();
12933 Function& function = Function::Handle(); 12982 Function& function = Function::Handle();
12934 Code& code = Code::Handle(); 12983 Code& code = Code::Handle();
12935 Script& script = Script::Handle(); 12984 Script& script = Script::Handle();
12936 String& function_name = String::Handle(); 12985 String& function_name = String::Handle();
12937 String& url = String::Handle(); 12986 String& url = String::Handle();
12938 12987
12939 // Iterate through the stack frames and create C string description 12988 // Iterate through the stack frames and create C string description
12940 // for each frame. 12989 // for each frame.
12941 intptr_t total_len = 0; 12990 intptr_t total_len = 0;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
13106 } 13155 }
13107 return result.raw(); 13156 return result.raw();
13108 } 13157 }
13109 13158
13110 13159
13111 const char* WeakProperty::ToCString() const { 13160 const char* WeakProperty::ToCString() const {
13112 return "_WeakProperty"; 13161 return "_WeakProperty";
13113 } 13162 }
13114 13163
13115 } // namespace dart 13164 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698