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

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, 10 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 12697 matching lines...) Expand 10 before | Expand all | Expand 10 after
12843 void Stacktrace::set_code_array(const Array& code_array) const { 12844 void Stacktrace::set_code_array(const Array& code_array) const {
12844 StorePointer(&raw_ptr()->code_array_, code_array.raw()); 12845 StorePointer(&raw_ptr()->code_array_, code_array.raw());
12845 } 12846 }
12846 12847
12847 12848
12848 void Stacktrace::set_pc_offset_array(const Array& pc_offset_array) const { 12849 void Stacktrace::set_pc_offset_array(const Array& pc_offset_array) const {
12849 StorePointer(&raw_ptr()->pc_offset_array_, pc_offset_array.raw()); 12850 StorePointer(&raw_ptr()->pc_offset_array_, pc_offset_array.raw());
12850 } 12851 }
12851 12852
12852 12853
12853 RawStacktrace* Stacktrace::New(const GrowableObjectArray& func_list, 12854 RawStacktrace* Stacktrace::New(const Array& func_array,
12854 const GrowableObjectArray& code_list, 12855 const Array& code_array,
12855 const GrowableObjectArray& pc_offset_list, 12856 const Array& pc_offset_array,
12856 Heap::Space space) { 12857 Heap::Space space) {
12857 ASSERT(Isolate::Current()->object_store()->stacktrace_class() != 12858 ASSERT(Isolate::Current()->object_store()->stacktrace_class() !=
12858 Class::null()); 12859 Class::null());
12859 Stacktrace& result = Stacktrace::Handle(); 12860 Stacktrace& result = Stacktrace::Handle();
12860 { 12861 {
12861 RawObject* raw = Object::Allocate(Stacktrace::kClassId, 12862 RawObject* raw = Object::Allocate(Stacktrace::kClassId,
12862 Stacktrace::InstanceSize(), 12863 Stacktrace::InstanceSize(),
12863 space); 12864 space);
12864 NoGCScope no_gc; 12865 NoGCScope no_gc;
12865 result ^= raw; 12866 result ^= raw;
12866 } 12867 }
12867 // Create arrays for the function, code and pc_offset triplet for each frame. 12868 // Create arrays for the function, code and pc_offset triplet for each frame.
12868 const Array& function_array = Array::Handle(Array::MakeArray(func_list)); 12869 result.set_function_array(func_array);
12869 const Array& code_array = Array::Handle(Array::MakeArray(code_list));
12870 const Array& pc_offset_array =
12871 Array::Handle(Array::MakeArray(pc_offset_list));
12872 result.set_function_array(function_array);
12873 result.set_code_array(code_array); 12870 result.set_code_array(code_array);
12874 result.set_pc_offset_array(pc_offset_array); 12871 result.set_pc_offset_array(pc_offset_array);
12875 return result.raw(); 12872 return result.raw();
12876 } 12873 }
12877 12874
12878 12875
12879 void Stacktrace::Append(const GrowableObjectArray& func_list, 12876 void Stacktrace::Append(const GrowableObjectArray& func_list,
12880 const GrowableObjectArray& code_list, 12877 const GrowableObjectArray& code_list,
12881 const GrowableObjectArray& pc_offset_list) const { 12878 const GrowableObjectArray& pc_offset_list) const {
12882 intptr_t old_length = Length(); 12879 intptr_t old_length = Length();
(...skipping 19 matching lines...) Expand all
12902 obj = func_list.At(j); 12899 obj = func_list.At(j);
12903 function_array.SetAt(i, obj); 12900 function_array.SetAt(i, obj);
12904 obj = code_list.At(j); 12901 obj = code_list.At(j);
12905 code_array.SetAt(i, obj); 12902 code_array.SetAt(i, obj);
12906 obj = pc_offset_list.At(j); 12903 obj = pc_offset_list.At(j);
12907 pc_offset_array.SetAt(i, obj); 12904 pc_offset_array.SetAt(i, obj);
12908 } 12905 }
12909 } 12906 }
12910 12907
12911 12908
12909 void Stacktrace::SetCatchStacktrace(const Array& func_array,
12910 const Array& code_array,
12911 const Array& pc_offset_array) const {
12912 StorePointer(&raw_ptr()->catch_func_array_, func_array.raw());
12913 StorePointer(&raw_ptr()->catch_code_array_, code_array.raw());
12914 StorePointer(&raw_ptr()->catch_pc_offset_array_, pc_offset_array.raw());
12915 }
12916
12917
12918 RawString* Stacktrace::FullStacktrace() const {
12919 const Array& func_array = Array::Handle(raw_ptr()->catch_func_array_);
12920 const Array& code_array = Array::Handle(raw_ptr()->catch_code_array_);
12921 const Array& pc_offset_array =
12922 Array::Handle(raw_ptr()->catch_pc_offset_array_);
12923 const Stacktrace& catch_trace = Stacktrace::Handle(
12924 Stacktrace::New(func_array, code_array, pc_offset_array));
12925 const String& trace = String::Handle(String::New(catch_trace.ToCString()));
12926 const String& throw_trace = String::Handle(String::New(ToCString()));
12927 return String::Concat(throw_trace, trace);
12928 }
12929
12930
12912 const char* Stacktrace::ToCString() const { 12931 const char* Stacktrace::ToCString() const {
12913 Function& function = Function::Handle(); 12932 Function& function = Function::Handle();
12914 Code& code = Code::Handle(); 12933 Code& code = Code::Handle();
12915 Script& script = Script::Handle(); 12934 Script& script = Script::Handle();
12916 String& function_name = String::Handle(); 12935 String& function_name = String::Handle();
12917 String& url = String::Handle(); 12936 String& url = String::Handle();
12918 12937
12919 // Iterate through the stack frames and create C string description 12938 // Iterate through the stack frames and create C string description
12920 // for each frame. 12939 // for each frame.
12921 intptr_t total_len = 0; 12940 intptr_t total_len = 0;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
13073 } 13092 }
13074 return result.raw(); 13093 return result.raw();
13075 } 13094 }
13076 13095
13077 13096
13078 const char* WeakProperty::ToCString() const { 13097 const char* WeakProperty::ToCString() const {
13079 return "_WeakProperty"; 13098 return "_WeakProperty";
13080 } 13099 }
13081 13100
13082 } // namespace dart 13101 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698