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

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

Issue 2366463002: Fix stepping over await statements (Closed)
Patch Set: wip Created 4 years, 2 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 | « runtime/observatory/tests/service/step_over_await_test.dart ('k') | 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 "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 369
370 370
371 Breakpoint* BreakpointLocation::AddPerClosure(Debugger* dbg, 371 Breakpoint* BreakpointLocation::AddPerClosure(Debugger* dbg,
372 const Instance& closure, 372 const Instance& closure,
373 bool for_over_await) { 373 bool for_over_await) {
374 Breakpoint* bpt = breakpoints(); 374 Breakpoint* bpt = breakpoints();
375 while (bpt != NULL) { 375 while (bpt != NULL) {
376 if (bpt->IsPerClosure() && bpt->closure() == closure.raw()) break; 376 if (bpt->IsPerClosure() && bpt->closure() == closure.raw()) break;
377 bpt = bpt->next(); 377 bpt = bpt->next();
378 } 378 }
379 if (for_over_await &&
380 (bpt != NULL) &&
381 (bpt == dbg->synthetic_async_breakpoint_)) {
382 // If the debugger is paused after stepping over an await statement,
Cutch 2016/09/21 23:43:45 I wonder if we could just do the following in this
hausner 2016/09/21 23:59:28 Why is it important to create a new synthetic BP e
383 // the synthetic breakpoint is temporarily kept in
384 // synthetic_async_breakpoint_ so it can be deleted when the step
385 // command resumes.
386 // If another step request over an async statement is issued, make
387 // sure the synthetic breakpoint does not get deleted.
388 dbg->synthetic_async_breakpoint_ = NULL;
389 }
379 if (bpt == NULL) { 390 if (bpt == NULL) {
380 bpt = new Breakpoint(dbg->nextId(), this); 391 bpt = new Breakpoint(dbg->nextId(), this);
381 bpt->SetIsPerClosure(closure); 392 bpt->SetIsPerClosure(closure);
382 bpt->set_is_synthetic_async(for_over_await); 393 bpt->set_is_synthetic_async(for_over_await);
383 AddBreakpoint(bpt, dbg); 394 AddBreakpoint(bpt, dbg);
384 } 395 }
385 return bpt; 396 return bpt;
386 } 397 }
387 398
388 399
(...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 String::Handle(frame->SourceUrl()).ToCString(), 2717 String::Handle(frame->SourceUrl()).ToCString(),
2707 frame->LineNumber(), 2718 frame->LineNumber(),
2708 String::Handle(frame->QualifiedFunctionName()).ToCString(), 2719 String::Handle(frame->QualifiedFunctionName()).ToCString(),
2709 frame->TokenPos().ToCString()); 2720 frame->TokenPos().ToCString());
2710 } 2721 }
2711 2722
2712 ASSERT(stack_trace_ == NULL); 2723 ASSERT(stack_trace_ == NULL);
2713 stack_trace_ = CollectStackTrace(); 2724 stack_trace_ = CollectStackTrace();
2714 // If this step callback is part of stepping over an await statement, 2725 // If this step callback is part of stepping over an await statement,
2715 // we saved the synthetic async breakpoint in PauseBreakpoint. We report 2726 // we saved the synthetic async breakpoint in PauseBreakpoint. We report
2716 // that we are paused at that breakpoint and then delete it after continuing. 2727 // that we are paused at that breakpoint and then delete it after continuing.
Cutch 2016/09/21 23:43:45 remove_synthetic_async_breakpoint = true;
2717 SignalPausedEvent(frame, synthetic_async_breakpoint_); 2728 SignalPausedEvent(frame, synthetic_async_breakpoint_);
2718 if (synthetic_async_breakpoint_ != NULL) { 2729 if (synthetic_async_breakpoint_ != NULL) {
Cutch 2016/09/21 23:43:45 if (remove_synthetic_async_breakpoint && (syntheti
2719 RemoveBreakpoint(synthetic_async_breakpoint_->id()); 2730 RemoveBreakpoint(synthetic_async_breakpoint_->id());
2720 synthetic_async_breakpoint_ = NULL; 2731 synthetic_async_breakpoint_ = NULL;
2721 } 2732 }
2722 HandleSteppingRequest(stack_trace_); 2733 HandleSteppingRequest(stack_trace_);
2723 stack_trace_ = NULL; 2734 stack_trace_ = NULL;
2724 2735
2725 // If any error occurred while in the debug message loop, return it here. 2736 // If any error occurred while in the debug message loop, return it here.
2726 const Error& error = Error::Handle(Thread::Current()->sticky_error()); 2737 const Error& error = Error::Handle(Thread::Current()->sticky_error());
2727 Thread::Current()->clear_sticky_error(); 2738 Thread::Current()->clear_sticky_error();
2728 return error.raw(); 2739 return error.raw();
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
3326 3337
3327 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 3338 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
3328 ASSERT(bpt->next() == NULL); 3339 ASSERT(bpt->next() == NULL);
3329 bpt->set_next(code_breakpoints_); 3340 bpt->set_next(code_breakpoints_);
3330 code_breakpoints_ = bpt; 3341 code_breakpoints_ = bpt;
3331 } 3342 }
3332 3343
3333 #endif // !PRODUCT 3344 #endif // !PRODUCT
3334 3345
3335 } // namespace dart 3346 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/step_over_await_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698