| OLD | NEW |
| 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 "vm/code_generator.h" | 7 #include "vm/code_generator.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 bp_handler_(NULL), | 470 bp_handler_(NULL), |
| 471 event_handler_(NULL), | 471 event_handler_(NULL), |
| 472 next_id_(1), | 472 next_id_(1), |
| 473 stack_trace_(NULL), | 473 stack_trace_(NULL), |
| 474 obj_cache_(NULL), | 474 obj_cache_(NULL), |
| 475 src_breakpoints_(NULL), | 475 src_breakpoints_(NULL), |
| 476 code_breakpoints_(NULL), | 476 code_breakpoints_(NULL), |
| 477 resume_action_(kContinue), | 477 resume_action_(kContinue), |
| 478 last_bpt_line_(-1), | 478 last_bpt_line_(-1), |
| 479 ignore_breakpoints_(false), | 479 ignore_breakpoints_(false), |
| 480 pause_on_exception_(false), | 480 exc_pause_info_(kNoPauseOnExceptions) { |
| 481 pause_on_unhandled_exception_(false) { | |
| 482 } | 481 } |
| 483 | 482 |
| 484 | 483 |
| 485 Debugger::~Debugger() { | 484 Debugger::~Debugger() { |
| 486 ASSERT(src_breakpoints_ == NULL); | 485 ASSERT(src_breakpoints_ == NULL); |
| 487 ASSERT(code_breakpoints_ == NULL); | 486 ASSERT(code_breakpoints_ == NULL); |
| 488 ASSERT(stack_trace_ == NULL); | 487 ASSERT(stack_trace_ == NULL); |
| 489 ASSERT(obj_cache_ == NULL); | 488 ASSERT(obj_cache_ == NULL); |
| 490 } | 489 } |
| 491 | 490 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 ASSERT(frame->IsDartFrame()); | 616 ASSERT(frame->IsDartFrame()); |
| 618 ActivationFrame* activation = | 617 ActivationFrame* activation = |
| 619 new ActivationFrame(frame->pc(), frame->fp(), frame->sp()); | 618 new ActivationFrame(frame->pc(), frame->fp(), frame->sp()); |
| 620 stack_trace->AddActivation(activation); | 619 stack_trace->AddActivation(activation); |
| 621 frame = iterator.NextFrame(); | 620 frame = iterator.NextFrame(); |
| 622 } | 621 } |
| 623 return stack_trace; | 622 return stack_trace; |
| 624 } | 623 } |
| 625 | 624 |
| 626 | 625 |
| 627 // TODO(hausner): Determine whether the exception is handled or not, and | 626 void Debugger::SetExceptionPauseInfo(Dart_ExceptionPauseInfo pause_info) { |
| 628 // check with the settings the user specified to determine whether the | 627 exc_pause_info_ = pause_info; |
| 629 // debugger should pause or not. | |
| 630 // For now, we just pause on TypeError and AssertionError exceptions. | |
| 631 bool Debugger::ShouldPauseOnException(DebuggerStackTrace* stack_trace, | |
| 632 const Object& exc) { | |
| 633 const Class& exc_class = Class::Handle(exc.clazz()); | |
| 634 const String& class_name = String::Handle(exc_class.Name()); | |
| 635 // TODO(hausner): Note the poor man's type test. Replace with check for | |
| 636 // actual class object or class id. | |
| 637 return class_name.Equals("TypeError") || class_name.Equals("AssertionError"); | |
| 638 } | 628 } |
| 639 | 629 |
| 640 | 630 |
| 631 // TODO(hausner): Determine whether the exception is handled or not. |
| 632 bool Debugger::ShouldPauseOnException(DebuggerStackTrace* stack_trace, |
| 633 const Object& exc) { |
| 634 if (exc_pause_info_ == kNoPauseOnExceptions) { |
| 635 return false; |
| 636 } |
| 637 if ((exc_pause_info_ & kPauseOnAllExceptions) != 0) { |
| 638 return true; |
| 639 } |
| 640 // Assume TypeError and AssertionError exceptions are unhandled. |
| 641 const Class& exc_class = Class::Handle(exc.clazz()); |
| 642 const String& class_name = String::Handle(exc_class.Name()); |
| 643 // TODO(hausner): Note the poor man's type test. This code will go |
| 644 // away when we have a way to determine whether an exception is unhandled. |
| 645 if (class_name.Equals("TypeError")) { |
| 646 return true; |
| 647 } |
| 648 if (class_name.Equals("AssertionError")) { |
| 649 return true; |
| 650 } |
| 651 return false; |
| 652 } |
| 653 |
| 654 |
| 641 void Debugger::SignalExceptionThrown(const Object& exc) { | 655 void Debugger::SignalExceptionThrown(const Object& exc) { |
| 642 if (ignore_breakpoints_) { | 656 if (ignore_breakpoints_) { |
| 643 return; | 657 return; |
| 644 } | 658 } |
| 645 DebuggerStackTrace* stack_trace = CollectStackTrace(); | 659 DebuggerStackTrace* stack_trace = CollectStackTrace(); |
| 646 if (!ShouldPauseOnException(stack_trace, exc)) { | 660 if (!ShouldPauseOnException(stack_trace, exc)) { |
| 647 return; | 661 return; |
| 648 } | 662 } |
| 649 // No single-stepping possible after this pause event. | 663 // No single-stepping possible after this pause event. |
| 650 last_bpt_line_ = -1; | 664 last_bpt_line_ = -1; |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 } | 1335 } |
| 1322 | 1336 |
| 1323 | 1337 |
| 1324 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 1338 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 1325 ASSERT(bpt->next() == NULL); | 1339 ASSERT(bpt->next() == NULL); |
| 1326 bpt->set_next(code_breakpoints_); | 1340 bpt->set_next(code_breakpoints_); |
| 1327 code_breakpoints_ = bpt; | 1341 code_breakpoints_ = bpt; |
| 1328 } | 1342 } |
| 1329 | 1343 |
| 1330 } // namespace dart | 1344 } // namespace dart |
| OLD | NEW |