| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 | 6 |
| 7 #include "vm/dart_entry.h" | 7 #include "vm/dart_entry.h" |
| 8 #include "vm/debugger.h" | 8 #include "vm/debugger.h" |
| 9 #include "vm/json_stream.h" | 9 #include "vm/json_stream.h" |
| 10 #include "vm/message.h" | 10 #include "vm/message.h" |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 o.PrintJSON(this, ref); | 437 o.PrintJSON(this, ref); |
| 438 } | 438 } |
| 439 | 439 |
| 440 | 440 |
| 441 void JSONStream::PrintValue(Breakpoint* bpt) { | 441 void JSONStream::PrintValue(Breakpoint* bpt) { |
| 442 PrintCommaIfNeeded(); | 442 PrintCommaIfNeeded(); |
| 443 bpt->PrintJSON(this); | 443 bpt->PrintJSON(this); |
| 444 } | 444 } |
| 445 | 445 |
| 446 | 446 |
| 447 void JSONStream::PrintValue(TokenPosition tp) { |
| 448 PrintCommaIfNeeded(); |
| 449 PrintValue(tp.value()); |
| 450 } |
| 451 |
| 452 |
| 447 void JSONStream::PrintValue(const ServiceEvent* event) { | 453 void JSONStream::PrintValue(const ServiceEvent* event) { |
| 448 PrintCommaIfNeeded(); | 454 PrintCommaIfNeeded(); |
| 449 event->PrintJSON(this); | 455 event->PrintJSON(this); |
| 450 } | 456 } |
| 451 | 457 |
| 452 | 458 |
| 453 void JSONStream::PrintValue(Metric* metric) { | 459 void JSONStream::PrintValue(Metric* metric) { |
| 454 PrintCommaIfNeeded(); | 460 PrintCommaIfNeeded(); |
| 455 metric->PrintJSON(this); | 461 metric->PrintJSON(this); |
| 456 } | 462 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 PrintValue(event); | 560 PrintValue(event); |
| 555 } | 561 } |
| 556 | 562 |
| 557 | 563 |
| 558 void JSONStream::PrintProperty(const char* name, Breakpoint* bpt) { | 564 void JSONStream::PrintProperty(const char* name, Breakpoint* bpt) { |
| 559 PrintPropertyName(name); | 565 PrintPropertyName(name); |
| 560 PrintValue(bpt); | 566 PrintValue(bpt); |
| 561 } | 567 } |
| 562 | 568 |
| 563 | 569 |
| 570 void JSONStream::PrintProperty(const char* name, TokenPosition tp) { |
| 571 PrintPropertyName(name); |
| 572 PrintValue(tp); |
| 573 } |
| 574 |
| 575 |
| 564 void JSONStream::PrintProperty(const char* name, Metric* metric) { | 576 void JSONStream::PrintProperty(const char* name, Metric* metric) { |
| 565 PrintPropertyName(name); | 577 PrintPropertyName(name); |
| 566 PrintValue(metric); | 578 PrintValue(metric); |
| 567 } | 579 } |
| 568 | 580 |
| 569 | 581 |
| 570 void JSONStream::PrintProperty(const char* name, MessageQueue* queue) { | 582 void JSONStream::PrintProperty(const char* name, MessageQueue* queue) { |
| 571 PrintPropertyName(name); | 583 PrintPropertyName(name); |
| 572 PrintValue(queue); | 584 PrintValue(queue); |
| 573 } | 585 } |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 va_end(args); | 758 va_end(args); |
| 747 ASSERT(len == len2); | 759 ASSERT(len == len2); |
| 748 stream_->buffer_.AddChar('"'); | 760 stream_->buffer_.AddChar('"'); |
| 749 stream_->AddEscapedUTF8String(p); | 761 stream_->AddEscapedUTF8String(p); |
| 750 stream_->buffer_.AddChar('"'); | 762 stream_->buffer_.AddChar('"'); |
| 751 free(p); | 763 free(p); |
| 752 } | 764 } |
| 753 | 765 |
| 754 | 766 |
| 755 void JSONObject::AddLocation(const Script& script, | 767 void JSONObject::AddLocation(const Script& script, |
| 756 intptr_t token_pos, | 768 TokenPosition token_pos, |
| 757 intptr_t end_token_pos) const { | 769 TokenPosition end_token_pos) const { |
| 758 JSONObject location(this, "location"); | 770 JSONObject location(this, "location"); |
| 759 location.AddProperty("type", "SourceLocation"); | 771 location.AddProperty("type", "SourceLocation"); |
| 760 location.AddProperty("script", script); | 772 location.AddProperty("script", script); |
| 761 location.AddProperty("tokenPos", token_pos); | 773 location.AddProperty("tokenPos", token_pos); |
| 762 if (end_token_pos >= 0) { | 774 if (end_token_pos.IsReal()) { |
| 763 location.AddProperty("endTokenPos", end_token_pos); | 775 location.AddProperty("endTokenPos", end_token_pos); |
| 764 } | 776 } |
| 765 } | 777 } |
| 766 | 778 |
| 767 | 779 |
| 768 void JSONObject::AddLocation(const BreakpointLocation* bpt_loc) const { | 780 void JSONObject::AddLocation(const BreakpointLocation* bpt_loc) const { |
| 769 ASSERT(bpt_loc->IsResolved()); | 781 ASSERT(bpt_loc->IsResolved()); |
| 770 | 782 |
| 771 Zone* zone = Thread::Current()->zone(); | 783 Zone* zone = Thread::Current()->zone(); |
| 772 Library& library = Library::Handle(zone); | 784 Library& library = Library::Handle(zone); |
| 773 Script& script = Script::Handle(zone); | 785 Script& script = Script::Handle(zone); |
| 774 intptr_t token_pos; | 786 TokenPosition token_pos = TokenPosition::kNoSource; |
| 775 bpt_loc->GetCodeLocation(&library, &script, &token_pos); | 787 bpt_loc->GetCodeLocation(&library, &script, &token_pos); |
| 776 AddLocation(script, token_pos); | 788 AddLocation(script, token_pos); |
| 777 } | 789 } |
| 778 | 790 |
| 779 | 791 |
| 780 void JSONObject::AddUnresolvedLocation( | 792 void JSONObject::AddUnresolvedLocation( |
| 781 const BreakpointLocation* bpt_loc) const { | 793 const BreakpointLocation* bpt_loc) const { |
| 782 ASSERT(!bpt_loc->IsResolved()); | 794 ASSERT(!bpt_loc->IsResolved()); |
| 783 | 795 |
| 784 Zone* zone = Thread::Current()->zone(); | 796 Zone* zone = Thread::Current()->zone(); |
| 785 Library& library = Library::Handle(zone); | 797 Library& library = Library::Handle(zone); |
| 786 Script& script = Script::Handle(zone); | 798 Script& script = Script::Handle(zone); |
| 787 intptr_t token_pos; | 799 TokenPosition token_pos = TokenPosition::kNoSource; |
| 788 bpt_loc->GetCodeLocation(&library, &script, &token_pos); | 800 bpt_loc->GetCodeLocation(&library, &script, &token_pos); |
| 789 | 801 |
| 790 JSONObject location(this, "location"); | 802 JSONObject location(this, "location"); |
| 791 location.AddProperty("type", "UnresolvedSourceLocation"); | 803 location.AddProperty("type", "UnresolvedSourceLocation"); |
| 792 if (!script.IsNull()) { | 804 if (!script.IsNull()) { |
| 793 location.AddProperty("script", script); | 805 location.AddProperty("script", script); |
| 794 } else { | 806 } else { |
| 795 const String& scriptUri = String::Handle(zone, bpt_loc->url()); | 807 const String& scriptUri = String::Handle(zone, bpt_loc->url()); |
| 796 location.AddPropertyStr("scriptUri", scriptUri); | 808 location.AddPropertyStr("scriptUri", scriptUri); |
| 797 } | 809 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); | 851 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); |
| 840 va_end(args); | 852 va_end(args); |
| 841 ASSERT(len == len2); | 853 ASSERT(len == len2); |
| 842 stream_->buffer_.AddChar('"'); | 854 stream_->buffer_.AddChar('"'); |
| 843 stream_->AddEscapedUTF8String(p); | 855 stream_->AddEscapedUTF8String(p); |
| 844 stream_->buffer_.AddChar('"'); | 856 stream_->buffer_.AddChar('"'); |
| 845 free(p); | 857 free(p); |
| 846 } | 858 } |
| 847 | 859 |
| 848 } // namespace dart | 860 } // namespace dart |
| OLD | NEW |