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::EventType TranslateEventType( | 10 static ServiceEvent::EventType TranslateEventType( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 case kBreakpointAdded: | 77 case kBreakpointAdded: |
78 return "BreakpointAdded"; | 78 return "BreakpointAdded"; |
79 case kBreakpointResolved: | 79 case kBreakpointResolved: |
80 return "BreakpointResolved"; | 80 return "BreakpointResolved"; |
81 case kBreakpointRemoved: | 81 case kBreakpointRemoved: |
82 return "BreakpointRemoved"; | 82 return "BreakpointRemoved"; |
83 case kGC: | 83 case kGC: |
84 return "GC"; // TODO(koda): Change to GarbageCollected. | 84 return "GC"; // TODO(koda): Change to GarbageCollected. |
85 case kInspect: | 85 case kInspect: |
86 return "Inspect"; | 86 return "Inspect"; |
87 case kIllegal: | |
88 return "Illegal"; | |
89 default: | 87 default: |
90 UNREACHABLE(); | 88 UNREACHABLE(); |
91 return "Unknown"; | 89 return "Unknown"; |
92 } | 90 } |
93 } | 91 } |
94 | 92 |
95 | 93 |
96 const char* ServiceEvent::stream_id() const { | |
97 switch (type()) { | |
98 case kIsolateStart: | |
99 case kIsolateExit: | |
100 case kIsolateUpdate: | |
101 return "Isolate"; | |
102 | |
103 case kPauseStart: | |
104 case kPauseExit: | |
105 case kPauseBreakpoint: | |
106 case kPauseInterrupted: | |
107 case kPauseException: | |
108 case kResume: | |
109 case kBreakpointAdded: | |
110 case kBreakpointResolved: | |
111 case kBreakpointRemoved: | |
112 case kInspect: | |
113 return "Debug"; | |
114 | |
115 case kGC: | |
116 return "GC"; | |
117 | |
118 default: | |
119 UNREACHABLE(); | |
120 return NULL; | |
121 } | |
122 } | |
123 | |
124 | |
125 void ServiceEvent::PrintJSON(JSONStream* js) const { | 94 void ServiceEvent::PrintJSON(JSONStream* js) const { |
126 JSONObject jsobj(js); | 95 JSONObject jsobj(js); |
127 jsobj.AddProperty("type", "ServiceEvent"); | 96 jsobj.AddProperty("type", "ServiceEvent"); |
128 jsobj.AddProperty("eventType", EventTypeToCString(type())); | 97 jsobj.AddProperty("eventType", EventTypeToCString(type())); |
129 jsobj.AddProperty("isolate", isolate()); | 98 jsobj.AddProperty("isolate", isolate()); |
130 if (breakpoint() != NULL) { | 99 if (breakpoint() != NULL) { |
131 jsobj.AddProperty("breakpoint", breakpoint()); | 100 jsobj.AddProperty("breakpoint", breakpoint()); |
132 } | 101 } |
133 if (top_frame() != NULL) { | 102 if (top_frame() != NULL) { |
134 JSONObject jsFrame(&jsobj, "topFrame"); | 103 JSONObject jsFrame(&jsobj, "topFrame"); |
135 top_frame()->PrintToJSONObject(&jsFrame); | 104 top_frame()->PrintToJSONObject(&jsFrame); |
136 } | 105 } |
137 if (exception() != NULL) { | 106 if (exception() != NULL) { |
138 jsobj.AddProperty("exception", *(exception())); | 107 jsobj.AddProperty("exception", *(exception())); |
139 } | 108 } |
140 if (inspectee() != NULL) { | 109 if (inspectee() != NULL) { |
141 jsobj.AddProperty("inspectee", *(inspectee())); | 110 jsobj.AddProperty("inspectee", *(inspectee())); |
142 } | 111 } |
143 if (gc_stats() != NULL) { | 112 if (gc_stats() != NULL) { |
144 jsobj.AddProperty("reason", Heap::GCReasonToString(gc_stats()->reason_)); | 113 jsobj.AddProperty("reason", Heap::GCReasonToString(gc_stats()->reason_)); |
145 isolate()->heap()->PrintToJSONObject(Heap::kNew, &jsobj); | 114 isolate()->heap()->PrintToJSONObject(Heap::kNew, &jsobj); |
146 isolate()->heap()->PrintToJSONObject(Heap::kOld, &jsobj); | 115 isolate()->heap()->PrintToJSONObject(Heap::kOld, &jsobj); |
147 } | 116 } |
148 } | 117 } |
149 | 118 |
150 } // namespace dart | 119 } // namespace dart |
OLD | NEW |