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

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

Issue 2815863002: Detect unhandled exceptions in async functions without an awaiter (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/debugger.h" 5 #include "vm/debugger.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "platform/address_sanitizer.h" 9 #include "platform/address_sanitizer.h"
10 10
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 intptr_t var_desc_len = var_descriptors_.Length(); 932 intptr_t var_desc_len = var_descriptors_.Length();
933 for (intptr_t i = 0; i < var_desc_len; i++) { 933 for (intptr_t i = 0; i < var_desc_len; i++) {
934 RawLocalVarDescriptors::VarInfo var_info; 934 RawLocalVarDescriptors::VarInfo var_info;
935 var_descriptors_.GetInfo(i, &var_info); 935 var_descriptors_.GetInfo(i, &var_info);
936 const int8_t kind = var_info.kind(); 936 const int8_t kind = var_info.kind();
937 if (kind == RawLocalVarDescriptors::kSavedCurrentContext) { 937 if (kind == RawLocalVarDescriptors::kSavedCurrentContext) {
938 if (FLAG_trace_debugger_stacktrace) { 938 if (FLAG_trace_debugger_stacktrace) {
939 OS::PrintErr("\tFound saved current ctx at index %d\n", 939 OS::PrintErr("\tFound saved current ctx at index %d\n",
940 var_info.index()); 940 var_info.index());
941 } 941 }
942 ctx_ ^= GetStackVar(var_info.index()); 942 const Object& obj = Object::Handle(GetStackVar(var_info.index()));
943 if (obj.IsClosure()) {
944 // Closure.call frames.
945 ctx_ ^= Closure::Cast(obj).context();
rmacnak 2017/04/12 16:53:03 The parser is uniformly creating a scope entry for
946 } else if (obj.IsContext()) {
947 ctx_ ^= Context::Cast(obj).raw();
948 } else {
949 ASSERT(obj.IsNull());
950 }
943 return ctx_; 951 return ctx_;
944 } 952 }
945 } 953 }
946 return Context::ZoneHandle(Context::null()); 954 return Context::ZoneHandle(Context::null());
947 } 955 }
948 956
949 957
950 RawObject* ActivationFrame::GetAsyncOperation() { 958 RawObject* ActivationFrame::GetAsyncOperation() {
951 GetVarDescriptors(); 959 GetVarDescriptors();
952 intptr_t var_desc_len = var_descriptors_.Length(); 960 intptr_t var_desc_len = var_descriptors_.Length();
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 } else { 2050 } else {
2043 function = code.function(); 2051 function = code.function();
2044 if (function.IsAsyncClosure() || function.IsAsyncGenClosure()) { 2052 if (function.IsAsyncClosure() || function.IsAsyncGenClosure()) {
2045 ActivationFrame* activation = CollectDartFrame( 2053 ActivationFrame* activation = CollectDartFrame(
2046 isolate, frame->pc(), frame, code, Object::null_array(), 0, 2054 isolate, frame->pc(), frame, code, Object::null_array(), 0,
2047 ActivationFrame::kAsyncActivation); 2055 ActivationFrame::kAsyncActivation);
2048 ASSERT(activation != NULL); 2056 ASSERT(activation != NULL);
2049 stack_trace->AddActivation(activation); 2057 stack_trace->AddActivation(activation);
2050 // Grab the awaiter. 2058 // Grab the awaiter.
2051 async_activation ^= activation->GetAsyncAwaiter(); 2059 async_activation ^= activation->GetAsyncAwaiter();
2060 async_stack_trace ^= activation->GetCausalStack();
2052 break; 2061 break;
2053 } else { 2062 } else {
2054 stack_trace->AddActivation(CollectDartFrame( 2063 stack_trace->AddActivation(CollectDartFrame(
2055 isolate, frame->pc(), frame, code, Object::null_array(), 0)); 2064 isolate, frame->pc(), frame, code, Object::null_array(), 0));
2056 } 2065 }
2057 } 2066 }
2058 } 2067 }
2059 } 2068 }
2060 2069
2061 // Return NULL to indicate that there is no useful information in this stack
2062 // trace because we never found an awaiter.
2063 if (async_activation.IsNull()) {
2064 return NULL;
2065 }
2066
2067 // Append the awaiter return call stack. 2070 // Append the awaiter return call stack.
2068 while (!async_activation.IsNull()) { 2071 while (!async_activation.IsNull()) {
2069 ActivationFrame* activation = new (zone) ActivationFrame(async_activation); 2072 ActivationFrame* activation = new (zone) ActivationFrame(async_activation);
2070 activation->ExtractTokenPositionFromAsyncClosure(); 2073 activation->ExtractTokenPositionFromAsyncClosure();
2071 stack_trace->AddActivation(activation); 2074 stack_trace->AddActivation(activation);
2072 next_async_activation = activation->GetAsyncAwaiter(); 2075 next_async_activation = activation->GetAsyncAwaiter();
2073 if (next_async_activation.IsNull()) { 2076 if (next_async_activation.IsNull()) {
2074 // No more awaiters. Extract the causal stack trace (if it exists). 2077 // No more awaiters. Extract the causal stack trace (if it exists).
2075 async_stack_trace ^= activation->GetCausalStack(); 2078 async_stack_trace ^= activation->GetCausalStack();
2076 break; 2079 break;
(...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after
4354 4357
4355 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 4358 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
4356 ASSERT(bpt->next() == NULL); 4359 ASSERT(bpt->next() == NULL);
4357 bpt->set_next(code_breakpoints_); 4360 bpt->set_next(code_breakpoints_);
4358 code_breakpoints_ = bpt; 4361 code_breakpoints_ = bpt;
4359 } 4362 }
4360 4363
4361 #endif // !PRODUCT 4364 #endif // !PRODUCT
4362 4365
4363 } // namespace dart 4366 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698