| 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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 ASSERT(len == len2); | 679 ASSERT(len == len2); |
| 680 stream_->buffer_.AddChar('"'); | 680 stream_->buffer_.AddChar('"'); |
| 681 stream_->AddEscapedUTF8String(p); | 681 stream_->AddEscapedUTF8String(p); |
| 682 stream_->buffer_.AddChar('"'); | 682 stream_->buffer_.AddChar('"'); |
| 683 free(p); | 683 free(p); |
| 684 } | 684 } |
| 685 | 685 |
| 686 | 686 |
| 687 void JSONObject::AddLocation(const Script& script, | 687 void JSONObject::AddLocation(const Script& script, |
| 688 intptr_t token_pos, | 688 intptr_t token_pos, |
| 689 intptr_t end_token_pos) { | 689 intptr_t end_token_pos) const { |
| 690 JSONObject location(this, "location"); | 690 JSONObject location(this, "location"); |
| 691 location.AddProperty("type", "SourceLocation"); | 691 location.AddProperty("type", "SourceLocation"); |
| 692 location.AddProperty("script", script); | 692 location.AddProperty("script", script); |
| 693 location.AddProperty("tokenPos", token_pos); | 693 location.AddProperty("tokenPos", token_pos); |
| 694 if (end_token_pos >= 0) { | 694 if (end_token_pos >= 0) { |
| 695 location.AddProperty("endTokenPos", end_token_pos); | 695 location.AddProperty("endTokenPos", end_token_pos); |
| 696 } | 696 } |
| 697 } | 697 } |
| 698 | 698 |
| 699 | 699 |
| 700 void JSONObject::AddLocation(const BreakpointLocation* bpt_loc) const { |
| 701 ASSERT(bpt_loc->IsResolved()); |
| 702 |
| 703 Isolate* isolate = Isolate::Current(); |
| 704 Library& library = Library::Handle(isolate); |
| 705 Script& script = Script::Handle(isolate); |
| 706 intptr_t token_pos; |
| 707 bpt_loc->GetCodeLocation(&library, &script, &token_pos); |
| 708 AddLocation(script, token_pos); |
| 709 } |
| 710 |
| 711 |
| 712 void JSONObject::AddUnresolvedLocation( |
| 713 const BreakpointLocation* bpt_loc) const { |
| 714 ASSERT(!bpt_loc->IsResolved()); |
| 715 |
| 716 Isolate* isolate = Isolate::Current(); |
| 717 Library& library = Library::Handle(isolate); |
| 718 Script& script = Script::Handle(isolate); |
| 719 intptr_t token_pos; |
| 720 bpt_loc->GetCodeLocation(&library, &script, &token_pos); |
| 721 |
| 722 JSONObject location(this, "location"); |
| 723 location.AddProperty("type", "UnresolvedSourceLocation"); |
| 724 if (!script.IsNull()) { |
| 725 location.AddProperty("script", script); |
| 726 } else { |
| 727 const String& scriptUri = String::Handle(isolate, bpt_loc->url()); |
| 728 location.AddPropertyStr("scriptUri", scriptUri); |
| 729 } |
| 730 if (bpt_loc->requested_line_number() >= 0) { |
| 731 // This unresolved breakpoint was specified at a particular line. |
| 732 location.AddProperty("line", bpt_loc->requested_line_number()); |
| 733 if (bpt_loc->requested_column_number() >= 0) { |
| 734 location.AddProperty("column", |
| 735 bpt_loc->requested_column_number()); |
| 736 } |
| 737 } else { |
| 738 // This unresolved breakpoint was requested at some function entry. |
| 739 location.AddProperty("tokenPos", token_pos); |
| 740 } |
| 741 } |
| 742 |
| 700 | 743 |
| 701 void JSONObject::AddPropertyF(const char* name, | 744 void JSONObject::AddPropertyF(const char* name, |
| 702 const char* format, ...) const { | 745 const char* format, ...) const { |
| 703 stream_->PrintPropertyName(name); | 746 stream_->PrintPropertyName(name); |
| 704 va_list args; | 747 va_list args; |
| 705 va_start(args, format); | 748 va_start(args, format); |
| 706 intptr_t len = OS::VSNPrint(NULL, 0, format, args); | 749 intptr_t len = OS::VSNPrint(NULL, 0, format, args); |
| 707 va_end(args); | 750 va_end(args); |
| 708 char* p = reinterpret_cast<char*>(malloc(len+1)); | 751 char* p = reinterpret_cast<char*>(malloc(len+1)); |
| 709 va_start(args, format); | 752 va_start(args, format); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 728 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); | 771 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); |
| 729 va_end(args); | 772 va_end(args); |
| 730 ASSERT(len == len2); | 773 ASSERT(len == len2); |
| 731 stream_->buffer_.AddChar('"'); | 774 stream_->buffer_.AddChar('"'); |
| 732 stream_->AddEscapedUTF8String(p); | 775 stream_->AddEscapedUTF8String(p); |
| 733 stream_->buffer_.AddChar('"'); | 776 stream_->buffer_.AddChar('"'); |
| 734 free(p); | 777 free(p); |
| 735 } | 778 } |
| 736 | 779 |
| 737 } // namespace dart | 780 } // namespace dart |
| OLD | NEW |