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

Unified Diff: runtime/vm/debugger.cc

Issue 51793002: Add an API function to get a debugger stack trace from an error handle. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
Index: runtime/vm/debugger.cc
diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc
index 940147b5064855b745b67dca379056e0801125af..3aa53abe62f01e51f3eb4a2986f54e2853d68920 100644
--- a/runtime/vm/debugger.cc
+++ b/runtime/vm/debugger.cc
@@ -1271,6 +1271,79 @@ DebuggerStackTrace* Debugger::StackTrace() {
}
+ExceptionStackTrace* Debugger::BuildExceptionStackTrace() {
+ Isolate* isolate = Isolate::Current();
+ ExceptionStackTrace* result = new ExceptionStackTrace(8);
+ StackFrameIterator iterator(false);
+ Function& function = Function::Handle(isolate);
+ Code& code = Code::Handle(isolate);
+ Code& inlined_code = Code::Handle(isolate);
+
+ String& function_name = String::Handle(isolate);
+ String& script_uri = String::Handle(isolate);
+ Script& script = Script::Handle(isolate);
+
+ for (StackFrame* frame = iterator.NextFrame();
+ frame != NULL;
+ frame = iterator.NextFrame()) {
+ ASSERT(frame->IsValid());
+ if (frame->IsEntryFrame()) {
+ } else if (frame->IsDartFrame()) {
+ code = frame->LookupDartCode();
+ if (code.is_optimized()) {
+ for (InlinedFunctionsIterator it(code, frame->pc());
+ !it.Done();
+ it.Advance()) {
+ function = it.function();
+ inlined_code = it.code();
+ uword pc = it.pc();
+
+ if (!function.is_visible()) continue;
+
+ function_name = function.QualifiedUserVisibleName();
+ script = function.script();
+ script_uri = script.url();
+ const intptr_t token_pos = inlined_code.GetTokenIndexOfPC(pc);
+ intptr_t line = -1;
+ intptr_t column = -1;
+ if (token_pos >= 0) {
+ if (script.HasSource()) {
+ script.GetTokenLocation(token_pos, &line, &column);
+ } else {
+ script.GetTokenLocation(token_pos, &line, NULL);
+ }
+ }
+ result->AddFrame(
+ new ExceptionStackFrame(function_name, script_uri, line, column));
+ }
+ } else {
+ function = frame->LookupDartFunction();
+ uword pc = frame->pc();
+
+ if (!function.is_visible()) continue;
+
+ function_name = function.QualifiedUserVisibleName();
+ script = function.script();
+ script_uri = script.url();
+ const intptr_t token_pos = code.GetTokenIndexOfPC(pc);
+ intptr_t line = -1;
+ intptr_t column = -1;
+ if (token_pos >= 0) {
+ if (script.HasSource()) {
+ script.GetTokenLocation(token_pos, &line, &column);
+ } else {
+ script.GetTokenLocation(token_pos, &line, NULL);
+ }
+ }
+ result->AddFrame(
+ new ExceptionStackFrame(function_name, script_uri, line, column));
+ }
+ }
+ }
+ return result;
+}
+
+
void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) {
ASSERT((pause_info == kNoPauseOnExceptions) ||
(pause_info == kPauseOnUnhandledExceptions) ||

Powered by Google App Engine
This is Rietveld 408576698