Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(788)

Side by Side Diff: runtime/vm/trace_buffer.cc

Issue 227423005: Add TraceBuffer log to all Functions (plus small tweaks to function-view) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« runtime/vm/object.cc ('K') | « runtime/vm/trace_buffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "vm/json_stream.h" 5 #include "vm/json_stream.h"
6 #include "vm/os.h" 6 #include "vm/os.h"
7 #include "vm/trace_buffer.h" 7 #include "vm/trace_buffer.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 va_end(args); 76 va_end(args);
77 char* p = reinterpret_cast<char*>(malloc(len+1)); 77 char* p = reinterpret_cast<char*>(malloc(len+1));
78 va_start(args, format); 78 va_start(args, format);
79 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); 79 intptr_t len2 = OS::VSNPrint(p, len+1, format, args);
80 va_end(args); 80 va_end(args);
81 ASSERT(len == len2); 81 ASSERT(len == len2);
82 AppendTrace(micros, p); 82 AppendTrace(micros, p);
83 } 83 }
84 84
85 85
86 void TraceBuffer::PrintToJSONStream(JSONStream* stream) const { 86 void TraceBuffer::PrintToJSONObject(JSONObject* json_trace_buffer) const {
87 JSONObject json_trace_buffer(stream); 87 json_trace_buffer->AddProperty("type", "TraceBuffer");
88 json_trace_buffer.AddProperty("type", "TraceBuffer"); 88 json_trace_buffer->AddProperty("id", "");
89 // TODO(johnmccutchan): Send cursor position in response. 89 // TODO(johnmccutchan): Send cursor position in response.
90 JSONArray json_trace_buffer_array(&json_trace_buffer, "members"); 90 JSONArray json_trace_buffer_array(json_trace_buffer, "members");
91 // Scan forward until we find the first entry which isn't empty. 91 // Scan forward until we find the first entry which isn't empty.
92 // TODO(johnmccutchan): Accept cursor start position as input. 92 // TODO(johnmccutchan): Accept cursor start position as input.
93 intptr_t start = -1; 93 intptr_t start = -1;
94 for (intptr_t i = 0; i < ring_capacity_; i++) { 94 for (intptr_t i = 0; i < ring_capacity_; i++) {
95 intptr_t index = RingIndex(i + ring_cursor_); 95 intptr_t index = RingIndex(i + ring_cursor_);
96 if (!ring_[index].empty()) { 96 if (!ring_[index].empty()) {
97 start = index; 97 start = index;
98 break; 98 break;
99 } 99 }
100 } 100 }
101 // No messages in trace buffer. 101 // No messages in trace buffer.
102 if (start == -1) { 102 if (start == -1) {
103 return; 103 return;
104 } 104 }
105 for (intptr_t i = 0; i < ring_capacity_; i++) { 105 for (intptr_t i = 0; i < ring_capacity_; i++) {
106 intptr_t index = RingIndex(start + i); 106 intptr_t index = RingIndex(start + i);
107 const TraceBufferEntry& entry = ring_[index]; 107 const TraceBufferEntry& entry = ring_[index];
108 if (entry.empty()) { 108 if (entry.empty()) {
109 // Empty entry, stop. 109 // Empty entry, stop.
110 break; 110 break;
111 } 111 }
112 JSONObject trace_entry(&json_trace_buffer_array); 112 JSONObject trace_entry(&json_trace_buffer_array);
113 trace_entry.AddProperty("type", "TraceBufferEntry"); 113 trace_entry.AddProperty("type", "TraceBufferEntry");
114 double seconds = static_cast<double>(entry.micros) / 114 trace_entry.AddProperty("id", "");
115 static_cast<double>(kMicrosecondsPerSecond); 115 intptr_t millis =
116 trace_entry.AddProperty("time", seconds); 116 static_cast<intptr_t>(entry.micros / kMicrosecondsPerMillisecond);
117 trace_entry.AddProperty("time", millis);
117 trace_entry.AddProperty("message", entry.message); 118 trace_entry.AddProperty("message", entry.message);
118 } 119 }
119 } 120 }
120 121
122
123 void TraceBuffer::PrintToJSONStream(JSONStream* stream) const {
124 JSONObject json_trace_buffer(stream);
125 PrintToJSONObject(&json_trace_buffer);
126 }
127
121 } // namespace dart 128 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/trace_buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698