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

Unified Diff: runtime/vm/exceptions.cc

Issue 248213002: Expose functionality to create a stack trace to internal vm code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 | « runtime/vm/exceptions.h ('k') | runtime/vm/flow_graph_builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/exceptions.cc
===================================================================
--- runtime/vm/exceptions.cc (revision 35317)
+++ runtime/vm/exceptions.cc (working copy)
@@ -345,6 +345,28 @@
}
+RawStacktrace* Exceptions::CurrentStacktrace() {
+ Isolate* isolate = Isolate::Current();
+ RegularStacktraceBuilder frame_builder(true);
+ BuildStackTrace(&frame_builder);
+
+ // Create arrays for code and pc_offset tuples of each frame.
+ const Array& full_code_array = Array::Handle(isolate,
+ Array::MakeArray(frame_builder.code_list()));
+ const Array& full_pc_offset_array = Array::Handle(isolate,
+ Array::MakeArray(frame_builder.pc_offset_list()));
+ const Array& full_catch_code_array = Array::Handle(isolate,
+ Array::MakeArray(frame_builder.catch_code_list()));
+ const Array& full_catch_pc_offset_array = Array::Handle(isolate,
+ Array::MakeArray(frame_builder.catch_pc_offset_list()));
+ const Stacktrace& full_stacktrace = Stacktrace::Handle(
+ Stacktrace::New(full_code_array, full_pc_offset_array));
+ full_stacktrace.SetCatchStacktrace(full_catch_code_array,
+ full_catch_pc_offset_array);
+ return full_stacktrace.raw();
+}
+
+
static void ThrowExceptionHelper(const Instance& incoming_exception,
const Instance& existing_stacktrace) {
bool use_preallocated_stacktrace = false;
@@ -391,22 +413,8 @@
// This is an error object and we need to capture the full stack trace
// here implicitly, so we set up the stack trace. The stack trace field
// is set only once, it is not overriden.
- RegularStacktraceBuilder frame_builder(true);
- BuildStackTrace(&frame_builder);
-
- // Create arrays for code and pc_offset tuples of each frame.
- const Array& full_code_array = Array::Handle(isolate,
- Array::MakeArray(frame_builder.code_list()));
- const Array& full_pc_offset_array = Array::Handle(isolate,
- Array::MakeArray(frame_builder.pc_offset_list()));
- const Array& full_catch_code_array = Array::Handle(isolate,
- Array::MakeArray(frame_builder.catch_code_list()));
- const Array& full_catch_pc_offset_array = Array::Handle(isolate,
- Array::MakeArray(frame_builder.catch_pc_offset_list()));
- const Stacktrace& full_stacktrace = Stacktrace::Handle(isolate,
- Stacktrace::New(full_code_array, full_pc_offset_array));
- full_stacktrace.SetCatchStacktrace(full_catch_code_array,
- full_catch_pc_offset_array);
+ const Stacktrace& full_stacktrace =
+ Stacktrace::Handle(isolate, Exceptions::CurrentStacktrace());
exception.SetField(stacktrace_field, full_stacktrace);
}
}
« no previous file with comments | « runtime/vm/exceptions.h ('k') | runtime/vm/flow_graph_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698