| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/service_event.h" | 5 #include "vm/service_event.h" |
| 6 | 6 |
| 7 namespace dart { | 7 namespace dart { |
| 8 | 8 |
| 9 // Translate from the legacy DebugEvent to a ServiceEvent. | 9 // Translate from the legacy DebugEvent to a ServiceEvent. |
| 10 static ServiceEvent::EventKind TranslateEventKind( | 10 static ServiceEvent::EventKind TranslateEventKind( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 case kBreakpointResolved: | 82 case kBreakpointResolved: |
| 83 return "BreakpointResolved"; | 83 return "BreakpointResolved"; |
| 84 case kBreakpointRemoved: | 84 case kBreakpointRemoved: |
| 85 return "BreakpointRemoved"; | 85 return "BreakpointRemoved"; |
| 86 case kGC: | 86 case kGC: |
| 87 return "GC"; // TODO(koda): Change to GarbageCollected. | 87 return "GC"; // TODO(koda): Change to GarbageCollected. |
| 88 case kInspect: | 88 case kInspect: |
| 89 return "Inspect"; | 89 return "Inspect"; |
| 90 case kEmbedder: | 90 case kEmbedder: |
| 91 return embedder_kind(); | 91 return embedder_kind(); |
| 92 case kLogging: |
| 93 return "_Logging"; |
| 92 case kDebuggerSettingsUpdate: | 94 case kDebuggerSettingsUpdate: |
| 93 return "_DebuggerSettingsUpdate"; | 95 return "_DebuggerSettingsUpdate"; |
| 94 case kIllegal: | 96 case kIllegal: |
| 95 return "Illegal"; | 97 return "Illegal"; |
| 96 default: | 98 default: |
| 97 UNREACHABLE(); | 99 UNREACHABLE(); |
| 98 return "Unknown"; | 100 return "Unknown"; |
| 99 } | 101 } |
| 100 } | 102 } |
| 101 | 103 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 119 case kInspect: | 121 case kInspect: |
| 120 case kDebuggerSettingsUpdate: | 122 case kDebuggerSettingsUpdate: |
| 121 return Service::debug_stream.id(); | 123 return Service::debug_stream.id(); |
| 122 | 124 |
| 123 case kGC: | 125 case kGC: |
| 124 return Service::gc_stream.id(); | 126 return Service::gc_stream.id(); |
| 125 | 127 |
| 126 case kEmbedder: | 128 case kEmbedder: |
| 127 return embedder_stream_id_; | 129 return embedder_stream_id_; |
| 128 | 130 |
| 131 case kLogging: |
| 132 return Service::logging_stream.id(); |
| 133 |
| 129 default: | 134 default: |
| 130 UNREACHABLE(); | 135 UNREACHABLE(); |
| 131 return NULL; | 136 return NULL; |
| 132 } | 137 } |
| 133 } | 138 } |
| 134 | 139 |
| 135 | 140 |
| 136 void ServiceEvent::PrintJSON(JSONStream* js) const { | 141 void ServiceEvent::PrintJSON(JSONStream* js) const { |
| 137 JSONObject jsobj(js); | 142 JSONObject jsobj(js); |
| 138 jsobj.AddProperty("type", "Event"); | 143 PrintJSONHeader(&jsobj); |
| 139 jsobj.AddProperty("kind", KindAsCString()); | |
| 140 jsobj.AddProperty("isolate", isolate()); | |
| 141 if (kind() == kPauseBreakpoint) { | 144 if (kind() == kPauseBreakpoint) { |
| 142 JSONArray jsarr(&jsobj, "pauseBreakpoints"); | 145 JSONArray jsarr(&jsobj, "pauseBreakpoints"); |
| 143 // TODO(rmacnak): If we are paused at more than one breakpoint, | 146 // TODO(rmacnak): If we are paused at more than one breakpoint, |
| 144 // provide it here. | 147 // provide it here. |
| 145 if (breakpoint() != NULL) { | 148 if (breakpoint() != NULL) { |
| 146 jsarr.AddValue(breakpoint()); | 149 jsarr.AddValue(breakpoint()); |
| 147 } | 150 } |
| 148 } else { | 151 } else { |
| 149 if (breakpoint() != NULL) { | 152 if (breakpoint() != NULL) { |
| 150 jsobj.AddProperty("breakpoint", breakpoint()); | 153 jsobj.AddProperty("breakpoint", breakpoint()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 170 jsobj.AddProperty("inspectee", *(inspectee())); | 173 jsobj.AddProperty("inspectee", *(inspectee())); |
| 171 } | 174 } |
| 172 if (gc_stats() != NULL) { | 175 if (gc_stats() != NULL) { |
| 173 jsobj.AddProperty("reason", Heap::GCReasonToString(gc_stats()->reason_)); | 176 jsobj.AddProperty("reason", Heap::GCReasonToString(gc_stats()->reason_)); |
| 174 isolate()->heap()->PrintToJSONObject(Heap::kNew, &jsobj); | 177 isolate()->heap()->PrintToJSONObject(Heap::kNew, &jsobj); |
| 175 isolate()->heap()->PrintToJSONObject(Heap::kOld, &jsobj); | 178 isolate()->heap()->PrintToJSONObject(Heap::kOld, &jsobj); |
| 176 } | 179 } |
| 177 if (bytes() != NULL) { | 180 if (bytes() != NULL) { |
| 178 jsobj.AddPropertyBase64("bytes", bytes(), bytes_length()); | 181 jsobj.AddPropertyBase64("bytes", bytes(), bytes_length()); |
| 179 } | 182 } |
| 183 if (kind() == kLogging) { |
| 184 JSONObject logRecord(&jsobj, "logRecord"); |
| 185 logRecord.AddProperty64("sequenceNumber", log_record_.sequence_number); |
| 186 logRecord.AddPropertyTimeMillis("time", log_record_.timestamp); |
| 187 logRecord.AddProperty64("level", log_record_.level); |
| 188 logRecord.AddProperty("loggerName", *(log_record_.name)); |
| 189 logRecord.AddProperty("message", *(log_record_.message)); |
| 190 logRecord.AddProperty("zone", *(log_record_.zone)); |
| 191 logRecord.AddProperty("error", *(log_record_.error)); |
| 192 logRecord.AddProperty("stackTrace", *(log_record_.stack_trace)); |
| 193 } |
| 194 } |
| 195 |
| 196 |
| 197 void ServiceEvent::PrintJSONHeader(JSONObject* jsobj) const { |
| 198 ASSERT(jsobj != NULL); |
| 199 jsobj->AddProperty("type", "Event"); |
| 200 jsobj->AddProperty("kind", KindAsCString()); |
| 201 jsobj->AddProperty("isolate", isolate()); |
| 180 } | 202 } |
| 181 | 203 |
| 182 } // namespace dart | 204 } // namespace dart |
| OLD | NEW |