Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_index_table.h" | 7 #include "vm/code_index_table.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/flags.h" | 11 #include "vm/flags.h" |
| 11 #include "vm/globals.h" | 12 #include "vm/globals.h" |
| 12 #include "vm/object.h" | 13 #include "vm/object.h" |
| 13 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 14 #include "vm/os.h" | 15 #include "vm/os.h" |
| 15 #include "vm/stack_frame.h" | 16 #include "vm/stack_frame.h" |
| 16 #include "vm/stub_code.h" | 17 #include "vm/stub_code.h" |
| 17 #include "vm/visitor.h" | 18 #include "vm/visitor.h" |
| 18 | 19 |
| 19 | 20 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 } | 401 } |
| 401 const Function& func = | 402 const Function& func = |
| 402 Function::Handle(lib.LookupFunctionInScript(script, token_index_at_line)); | 403 Function::Handle(lib.LookupFunctionInScript(script, token_index_at_line)); |
| 403 if (func.IsNull()) { | 404 if (func.IsNull()) { |
| 404 return NULL; | 405 return NULL; |
| 405 } | 406 } |
| 406 return SetBreakpoint(func, token_index_at_line); | 407 return SetBreakpoint(func, token_index_at_line); |
| 407 } | 408 } |
| 408 | 409 |
| 409 | 410 |
| 411 static RawArray* MakeNameValueList(const GrowableArray<Object*>& pairs) { | |
| 412 int pairs_len = pairs.length(); | |
| 413 ASSERT(pairs_len % 2 == 0); | |
| 414 const Array& list = Array::Handle(Array::New(pairs_len)); | |
| 415 for (int i = 0; i < pairs_len; i++) { | |
| 416 list.SetAt(i, *pairs[i]); | |
| 417 } | |
| 418 return list.raw(); | |
| 419 } | |
| 420 | |
| 421 | |
| 422 RawInstance* Debugger::GetInstanceField(const Class& cls, | |
| 423 const String& field_name, | |
| 424 const Instance& object) { | |
| 425 const Function& getter_func = | |
| 426 Function::Handle(cls.LookupGetterFunction(field_name)); | |
| 427 ASSERT(!getter_func.IsNull()); | |
| 428 GrowableArray<const Object*> noArguments; | |
| 429 const Array& noArgumentNames = Array::Handle(); | |
| 430 return DartEntry::InvokeDynamic(object, getter_func, | |
| 431 noArguments, noArgumentNames); | |
|
siva
2012/01/26 21:34:08
Until Todd implements his change of capturing all
hausner
2012/01/27 17:19:30
Good point. The compilation part is taken care of
| |
| 432 } | |
| 433 | |
| 434 | |
| 435 RawInstance* Debugger::GetStaticField(const Class& cls, | |
| 436 const String& field_name) { | |
| 437 const Function& getter_func = | |
| 438 Function::Handle(cls.LookupGetterFunction(field_name)); | |
| 439 ASSERT(!getter_func.IsNull()); | |
| 440 GrowableArray<const Object*> noArguments; | |
| 441 const Array& noArgumentNames = Array::Handle(); | |
| 442 return DartEntry::InvokeStatic(getter_func, noArguments, noArgumentNames); | |
|
siva
2012/01/26 21:34:08
Ditto comment about setjmp/longjmp.
hausner
2012/01/27 17:19:30
Done.
| |
| 443 } | |
| 444 | |
| 445 | |
| 446 RawArray* Debugger::GetInstanceFields(const Instance& obj) { | |
| 447 Class& cls = Class::Handle(obj.clazz()); | |
| 448 Array& fields = Array::Handle(); | |
| 449 Field& field = Field::Handle(); | |
| 450 GrowableArray<Object*> field_list(8); | |
| 451 // Iterate over fields in class hierarchy to count all instance fields. | |
| 452 int num_fields = 0; | |
| 453 while (!cls.IsNull()) { | |
| 454 fields = cls.fields(); | |
| 455 for (int i = 0; i < fields.Length(); i++) { | |
| 456 field ^= fields.At(i); | |
| 457 if (!field.is_static()) { | |
| 458 String& field_name = String::Handle(field.name()); | |
| 459 field_list.Add(&field_name); | |
| 460 Instance& field_value = Instance::Handle(); | |
| 461 field_value = GetInstanceField(cls, field_name, obj); | |
| 462 field_list.Add(&field_value); | |
| 463 } | |
| 464 } | |
| 465 cls = cls.SuperClass(); | |
| 466 } | |
| 467 return MakeNameValueList(field_list); | |
| 468 } | |
| 469 | |
| 470 | |
| 471 RawArray* Debugger::GetStaticFields(const Class& cls) { | |
| 472 GrowableArray<Object*> field_list(8); | |
| 473 Array& fields = Array::Handle(cls.fields()); | |
| 474 Field& field = Field::Handle(); | |
| 475 for (int i = 0; i < fields.Length(); i++) { | |
| 476 field ^= fields.At(i); | |
| 477 if (field.is_static()) { | |
| 478 String& field_name = String::Handle(field.name()); | |
| 479 Instance& field_value = Instance::Handle(GetStaticField(cls, field_name)); | |
| 480 field_list.Add(&field_name); | |
| 481 field_list.Add(&field_value); | |
| 482 } | |
| 483 } | |
| 484 return MakeNameValueList(field_list); | |
| 485 } | |
| 486 | |
| 487 | |
| 410 void Debugger::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 488 void Debugger::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
| 411 ASSERT(visitor != NULL); | 489 ASSERT(visitor != NULL); |
| 412 Breakpoint* bpt = this->breakpoints_; | 490 Breakpoint* bpt = this->breakpoints_; |
| 413 while (bpt != NULL) { | 491 while (bpt != NULL) { |
| 414 bpt->VisitObjectPointers(visitor); | 492 bpt->VisitObjectPointers(visitor); |
| 415 bpt = bpt->next(); | 493 bpt = bpt->next(); |
| 416 } | 494 } |
| 417 } | 495 } |
| 418 | 496 |
| 419 | 497 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 | 608 |
| 531 | 609 |
| 532 void Debugger::RegisterBreakpoint(Breakpoint* bpt) { | 610 void Debugger::RegisterBreakpoint(Breakpoint* bpt) { |
| 533 ASSERT(bpt->next() == NULL); | 611 ASSERT(bpt->next() == NULL); |
| 534 bpt->set_next(this->breakpoints_); | 612 bpt->set_next(this->breakpoints_); |
| 535 this->breakpoints_ = bpt; | 613 this->breakpoints_ = bpt; |
| 536 } | 614 } |
| 537 | 615 |
| 538 | 616 |
| 539 } // namespace dart | 617 } // namespace dart |
| OLD | NEW |