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" |
11 #include "vm/metrics.h" | 11 #include "vm/metrics.h" |
12 #include "vm/object.h" | 12 #include "vm/object.h" |
13 #include "vm/service_event.h" | 13 #include "vm/service_event.h" |
14 #include "vm/service.h" | 14 #include "vm/service.h" |
| 15 #include "vm/timeline.h" |
15 #include "vm/unicode.h" | 16 #include "vm/unicode.h" |
16 | 17 |
17 | 18 |
18 namespace dart { | 19 namespace dart { |
19 | 20 |
20 DECLARE_FLAG(bool, trace_service); | 21 DECLARE_FLAG(bool, trace_service); |
21 | 22 |
22 JSONStream::JSONStream(intptr_t buf_size) | 23 JSONStream::JSONStream(intptr_t buf_size) |
23 : open_objects_(0), | 24 : open_objects_(0), |
24 buffer_(buf_size), | 25 buffer_(buf_size), |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 queue->PrintJSON(this); | 385 queue->PrintJSON(this); |
385 } | 386 } |
386 | 387 |
387 | 388 |
388 void JSONStream::PrintValue(Isolate* isolate, bool ref) { | 389 void JSONStream::PrintValue(Isolate* isolate, bool ref) { |
389 PrintCommaIfNeeded(); | 390 PrintCommaIfNeeded(); |
390 isolate->PrintJSON(this, ref); | 391 isolate->PrintJSON(this, ref); |
391 } | 392 } |
392 | 393 |
393 | 394 |
| 395 void JSONStream::PrintValue(TimelineEvent* timeline_event) { |
| 396 PrintCommaIfNeeded(); |
| 397 timeline_event->PrintJSON(this); |
| 398 } |
| 399 |
| 400 |
394 void JSONStream::PrintServiceId(const Object& o) { | 401 void JSONStream::PrintServiceId(const Object& o) { |
395 ASSERT(id_zone_ != NULL); | 402 ASSERT(id_zone_ != NULL); |
396 PrintProperty("id", id_zone_->GetServiceId(o)); | 403 PrintProperty("id", id_zone_->GetServiceId(o)); |
397 } | 404 } |
398 | 405 |
399 | 406 |
400 void JSONStream::PrintPropertyBool(const char* name, bool b) { | 407 void JSONStream::PrintPropertyBool(const char* name, bool b) { |
401 PrintPropertyName(name); | 408 PrintPropertyName(name); |
402 PrintValueBool(b); | 409 PrintValueBool(b); |
403 } | 410 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 PrintValue(queue); | 481 PrintValue(queue); |
475 } | 482 } |
476 | 483 |
477 | 484 |
478 void JSONStream::PrintProperty(const char* name, Isolate* isolate) { | 485 void JSONStream::PrintProperty(const char* name, Isolate* isolate) { |
479 PrintPropertyName(name); | 486 PrintPropertyName(name); |
480 PrintValue(isolate); | 487 PrintValue(isolate); |
481 } | 488 } |
482 | 489 |
483 | 490 |
| 491 void JSONStream::PrintProperty(const char* name, |
| 492 TimelineEvent* timeline_event) { |
| 493 PrintPropertyName(name); |
| 494 PrintValue(timeline_event); |
| 495 } |
| 496 |
| 497 |
484 void JSONStream::PrintfProperty(const char* name, const char* format, ...) { | 498 void JSONStream::PrintfProperty(const char* name, const char* format, ...) { |
485 PrintPropertyName(name); | 499 PrintPropertyName(name); |
486 va_list args; | 500 va_list args; |
487 va_start(args, format); | 501 va_start(args, format); |
488 intptr_t len = OS::VSNPrint(NULL, 0, format, args); | 502 intptr_t len = OS::VSNPrint(NULL, 0, format, args); |
489 va_end(args); | 503 va_end(args); |
490 char* p = reinterpret_cast<char*>(malloc(len+1)); | 504 char* p = reinterpret_cast<char*>(malloc(len+1)); |
491 va_start(args, format); | 505 va_start(args, format); |
492 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); | 506 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); |
493 va_end(args); | 507 va_end(args); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); | 679 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); |
666 va_end(args); | 680 va_end(args); |
667 ASSERT(len == len2); | 681 ASSERT(len == len2); |
668 stream_->buffer_.AddChar('"'); | 682 stream_->buffer_.AddChar('"'); |
669 stream_->AddEscapedUTF8String(p); | 683 stream_->AddEscapedUTF8String(p); |
670 stream_->buffer_.AddChar('"'); | 684 stream_->buffer_.AddChar('"'); |
671 free(p); | 685 free(p); |
672 } | 686 } |
673 | 687 |
674 } // namespace dart | 688 } // namespace dart |
OLD | NEW |