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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 queue->PrintJSON(this); | 349 queue->PrintJSON(this); |
349 } | 350 } |
350 | 351 |
351 | 352 |
352 void JSONStream::PrintValue(Isolate* isolate, bool ref) { | 353 void JSONStream::PrintValue(Isolate* isolate, bool ref) { |
353 PrintCommaIfNeeded(); | 354 PrintCommaIfNeeded(); |
354 isolate->PrintJSON(this, ref); | 355 isolate->PrintJSON(this, ref); |
355 } | 356 } |
356 | 357 |
357 | 358 |
| 359 void JSONStream::PrintValue(TimelineEvent* timeline_event) { |
| 360 PrintCommaIfNeeded(); |
| 361 timeline_event->PrintJSON(this); |
| 362 } |
| 363 |
| 364 |
358 void JSONStream::PrintServiceId(const Object& o) { | 365 void JSONStream::PrintServiceId(const Object& o) { |
359 ASSERT(id_zone_ != NULL); | 366 ASSERT(id_zone_ != NULL); |
360 PrintProperty("id", id_zone_->GetServiceId(o)); | 367 PrintProperty("id", id_zone_->GetServiceId(o)); |
361 } | 368 } |
362 | 369 |
363 | 370 |
364 void JSONStream::PrintPropertyBool(const char* name, bool b) { | 371 void JSONStream::PrintPropertyBool(const char* name, bool b) { |
365 PrintPropertyName(name); | 372 PrintPropertyName(name); |
366 PrintValueBool(b); | 373 PrintValueBool(b); |
367 } | 374 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 PrintValue(queue); | 437 PrintValue(queue); |
431 } | 438 } |
432 | 439 |
433 | 440 |
434 void JSONStream::PrintProperty(const char* name, Isolate* isolate) { | 441 void JSONStream::PrintProperty(const char* name, Isolate* isolate) { |
435 PrintPropertyName(name); | 442 PrintPropertyName(name); |
436 PrintValue(isolate); | 443 PrintValue(isolate); |
437 } | 444 } |
438 | 445 |
439 | 446 |
| 447 void JSONStream::PrintProperty(const char* name, |
| 448 TimelineEvent* timeline_event) { |
| 449 PrintPropertyName(name); |
| 450 PrintValue(timeline_event); |
| 451 } |
| 452 |
| 453 |
440 void JSONStream::PrintfProperty(const char* name, const char* format, ...) { | 454 void JSONStream::PrintfProperty(const char* name, const char* format, ...) { |
441 PrintPropertyName(name); | 455 PrintPropertyName(name); |
442 va_list args; | 456 va_list args; |
443 va_start(args, format); | 457 va_start(args, format); |
444 intptr_t len = OS::VSNPrint(NULL, 0, format, args); | 458 intptr_t len = OS::VSNPrint(NULL, 0, format, args); |
445 va_end(args); | 459 va_end(args); |
446 char* p = reinterpret_cast<char*>(malloc(len+1)); | 460 char* p = reinterpret_cast<char*>(malloc(len+1)); |
447 va_start(args, format); | 461 va_start(args, format); |
448 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); | 462 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); |
449 va_end(args); | 463 va_end(args); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); | 635 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); |
622 va_end(args); | 636 va_end(args); |
623 ASSERT(len == len2); | 637 ASSERT(len == len2); |
624 stream_->buffer_.AddChar('"'); | 638 stream_->buffer_.AddChar('"'); |
625 stream_->AddEscapedUTF8String(p); | 639 stream_->AddEscapedUTF8String(p); |
626 stream_->buffer_.AddChar('"'); | 640 stream_->buffer_.AddChar('"'); |
627 free(p); | 641 free(p); |
628 } | 642 } |
629 | 643 |
630 } // namespace dart | 644 } // namespace dart |
OLD | NEW |