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

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

Issue 1232193003: Provide stdout and stderr output in the Observatory debugger. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: before commit Created 5 years, 5 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
« no previous file with comments | « runtime/vm/service_event.h ('k') | runtime/vm/service_isolate.cc » ('j') | 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) 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::EventKind TranslateEventKind(
11 DebuggerEvent::EventType type) { 11 DebuggerEvent::EventType kind) {
12 switch (type) { 12 switch (kind) {
13 case DebuggerEvent::kIsolateCreated: 13 case DebuggerEvent::kIsolateCreated:
14 return ServiceEvent::kIsolateStart; 14 return ServiceEvent::kIsolateStart;
15 15
16 case DebuggerEvent::kIsolateShutdown: 16 case DebuggerEvent::kIsolateShutdown:
17 return ServiceEvent::kIsolateExit; 17 return ServiceEvent::kIsolateExit;
18 18
19 case DebuggerEvent::kBreakpointReached: 19 case DebuggerEvent::kBreakpointReached:
20 return ServiceEvent::kPauseBreakpoint; 20 return ServiceEvent::kPauseBreakpoint;
21 21
22 case DebuggerEvent::kIsolateInterrupted: 22 case DebuggerEvent::kIsolateInterrupted:
23 return ServiceEvent::kPauseInterrupted; 23 return ServiceEvent::kPauseInterrupted;
24 24
25 case DebuggerEvent::kExceptionThrown: 25 case DebuggerEvent::kExceptionThrown:
26 return ServiceEvent::kPauseException; 26 return ServiceEvent::kPauseException;
27
28 default: 27 default:
29 UNREACHABLE(); 28 UNREACHABLE();
30 return ServiceEvent::kIllegal; 29 return ServiceEvent::kIllegal;
31 } 30 }
32 } 31 }
33 32
34 ServiceEvent::ServiceEvent(const DebuggerEvent* debugger_event) 33 ServiceEvent::ServiceEvent(const DebuggerEvent* debugger_event)
35 : isolate_(debugger_event->isolate()), 34 : isolate_(debugger_event->isolate()),
36 type_(TranslateEventType(debugger_event->type())), 35 kind_(TranslateEventKind(debugger_event->type())),
37 breakpoint_(NULL), 36 breakpoint_(NULL),
38 top_frame_(NULL), 37 top_frame_(NULL),
39 exception_(NULL), 38 exception_(NULL),
40 inspectee_(NULL), 39 inspectee_(NULL),
41 gc_stats_(NULL) { 40 gc_stats_(NULL),
41 bytes_(NULL),
42 bytes_length_(0) {
42 DebuggerEvent::EventType type = debugger_event->type(); 43 DebuggerEvent::EventType type = debugger_event->type();
43 if (type == DebuggerEvent::kBreakpointReached) { 44 if (type == DebuggerEvent::kBreakpointReached) {
44 set_breakpoint(debugger_event->breakpoint()); 45 set_breakpoint(debugger_event->breakpoint());
45 } 46 }
46 if (type == DebuggerEvent::kExceptionThrown) { 47 if (type == DebuggerEvent::kExceptionThrown) {
47 set_exception(debugger_event->exception()); 48 set_exception(debugger_event->exception());
48 } 49 }
49 if (type == DebuggerEvent::kBreakpointReached || 50 if (type == DebuggerEvent::kBreakpointReached ||
50 type == DebuggerEvent::kIsolateInterrupted || 51 type == DebuggerEvent::kIsolateInterrupted ||
51 type == DebuggerEvent::kExceptionThrown) { 52 type == DebuggerEvent::kExceptionThrown) {
52 set_top_frame(debugger_event->top_frame()); 53 set_top_frame(debugger_event->top_frame());
53 } 54 }
54 } 55 }
55 56
56 57
57 const char* ServiceEvent::EventTypeToCString(EventType type) { 58 const char* ServiceEvent::KindAsCString() const {
58 switch (type) { 59 switch (kind()) {
59 case kIsolateStart: 60 case kIsolateStart:
60 return "IsolateStart"; 61 return "IsolateStart";
61 case kIsolateExit: 62 case kIsolateExit:
62 return "IsolateExit"; 63 return "IsolateExit";
63 case kIsolateUpdate: 64 case kIsolateUpdate:
64 return "IsolateUpdate"; 65 return "IsolateUpdate";
65 case kPauseStart: 66 case kPauseStart:
66 return "PauseStart"; 67 return "PauseStart";
67 case kPauseExit: 68 case kPauseExit:
68 return "PauseExit"; 69 return "PauseExit";
69 case kPauseBreakpoint: 70 case kPauseBreakpoint:
70 return "PauseBreakpoint"; 71 return "PauseBreakpoint";
71 case kPauseInterrupted: 72 case kPauseInterrupted:
72 return "PauseInterrupted"; 73 return "PauseInterrupted";
73 case kPauseException: 74 case kPauseException:
74 return "PauseException"; 75 return "PauseException";
75 case kResume: 76 case kResume:
76 return "Resume"; 77 return "Resume";
77 case kBreakpointAdded: 78 case kBreakpointAdded:
78 return "BreakpointAdded"; 79 return "BreakpointAdded";
79 case kBreakpointResolved: 80 case kBreakpointResolved:
80 return "BreakpointResolved"; 81 return "BreakpointResolved";
81 case kBreakpointRemoved: 82 case kBreakpointRemoved:
82 return "BreakpointRemoved"; 83 return "BreakpointRemoved";
83 case kGC: 84 case kGC:
84 return "GC"; // TODO(koda): Change to GarbageCollected. 85 return "GC"; // TODO(koda): Change to GarbageCollected.
85 case kInspect: 86 case kInspect:
86 return "Inspect"; 87 return "Inspect";
88 case kEmbedder:
89 return embedder_kind();
87 case kDebuggerSettingsUpdate: 90 case kDebuggerSettingsUpdate:
88 return "_DebuggerSettingsUpdate"; 91 return "_DebuggerSettingsUpdate";
89 case kIllegal: 92 case kIllegal:
90 return "Illegal"; 93 return "Illegal";
91 default: 94 default:
92 UNREACHABLE(); 95 UNREACHABLE();
93 return "Unknown"; 96 return "Unknown";
94 } 97 }
95 } 98 }
96 99
97 100
98 const char* ServiceEvent::stream_id() const { 101 const char* ServiceEvent::stream_id() const {
99 switch (type()) { 102 switch (kind()) {
100 case kIsolateStart: 103 case kIsolateStart:
101 case kIsolateExit: 104 case kIsolateExit:
102 case kIsolateUpdate: 105 case kIsolateUpdate:
103 return "Isolate"; 106 return Service::isolate_stream.id();
104 107
105 case kPauseStart: 108 case kPauseStart:
106 case kPauseExit: 109 case kPauseExit:
107 case kPauseBreakpoint: 110 case kPauseBreakpoint:
108 case kPauseInterrupted: 111 case kPauseInterrupted:
109 case kPauseException: 112 case kPauseException:
110 case kResume: 113 case kResume:
111 case kBreakpointAdded: 114 case kBreakpointAdded:
112 case kBreakpointResolved: 115 case kBreakpointResolved:
113 case kBreakpointRemoved: 116 case kBreakpointRemoved:
114 case kInspect: 117 case kInspect:
115 case kDebuggerSettingsUpdate: 118 case kDebuggerSettingsUpdate:
116 return "Debug"; 119 return Service::debug_stream.id();
117 120
118 case kGC: 121 case kGC:
119 return "GC"; 122 return Service::gc_stream.id();
123
124 case kEmbedder:
125 return embedder_stream_id_;
120 126
121 default: 127 default:
122 UNREACHABLE(); 128 UNREACHABLE();
123 return NULL; 129 return NULL;
124 } 130 }
125 } 131 }
126 132
127 133
128 void ServiceEvent::PrintJSON(JSONStream* js) const { 134 void ServiceEvent::PrintJSON(JSONStream* js) const {
129 JSONObject jsobj(js); 135 JSONObject jsobj(js);
130 jsobj.AddProperty("type", "Event"); 136 jsobj.AddProperty("type", "Event");
131 jsobj.AddProperty("kind", EventTypeToCString(type())); 137 jsobj.AddProperty("kind", KindAsCString());
132 jsobj.AddProperty("isolate", isolate()); 138 jsobj.AddProperty("isolate", isolate());
133 if (type() == kPauseBreakpoint) { 139 if (kind() == kPauseBreakpoint) {
134 JSONArray jsarr(&jsobj, "pauseBreakpoints"); 140 JSONArray jsarr(&jsobj, "pauseBreakpoints");
135 // TODO(rmacnak): If we are paused at more than one breakpoint, 141 // TODO(rmacnak): If we are paused at more than one breakpoint,
136 // provide it here. 142 // provide it here.
137 if (breakpoint() != NULL) { 143 if (breakpoint() != NULL) {
138 jsarr.AddValue(breakpoint()); 144 jsarr.AddValue(breakpoint());
139 } 145 }
140 } else { 146 } else {
141 if (breakpoint() != NULL) { 147 if (breakpoint() != NULL) {
142 jsobj.AddProperty("breakpoint", breakpoint()); 148 jsobj.AddProperty("breakpoint", breakpoint());
143 } 149 }
144 } 150 }
145 if (type() == kDebuggerSettingsUpdate) { 151 if (kind() == kDebuggerSettingsUpdate) {
146 JSONObject jssettings(&jsobj, "_debuggerSettings"); 152 JSONObject jssettings(&jsobj, "_debuggerSettings");
147 isolate()->debugger()->PrintSettingsToJSONObject(&jssettings); 153 isolate()->debugger()->PrintSettingsToJSONObject(&jssettings);
148 } 154 }
149 if (top_frame() != NULL) { 155 if (top_frame() != NULL) {
150 JSONObject jsFrame(&jsobj, "topFrame"); 156 JSONObject jsFrame(&jsobj, "topFrame");
151 top_frame()->PrintToJSONObject(&jsFrame); 157 top_frame()->PrintToJSONObject(&jsFrame);
152 intptr_t index = 0; // Avoid ambiguity in call to AddProperty. 158 intptr_t index = 0; // Avoid ambiguity in call to AddProperty.
153 jsFrame.AddProperty("index", index); 159 jsFrame.AddProperty("index", index);
154 } 160 }
155 if (exception() != NULL) { 161 if (exception() != NULL) {
156 jsobj.AddProperty("exception", *(exception())); 162 jsobj.AddProperty("exception", *(exception()));
157 } 163 }
158 if (inspectee() != NULL) { 164 if (inspectee() != NULL) {
159 jsobj.AddProperty("inspectee", *(inspectee())); 165 jsobj.AddProperty("inspectee", *(inspectee()));
160 } 166 }
161 if (gc_stats() != NULL) { 167 if (gc_stats() != NULL) {
162 jsobj.AddProperty("reason", Heap::GCReasonToString(gc_stats()->reason_)); 168 jsobj.AddProperty("reason", Heap::GCReasonToString(gc_stats()->reason_));
163 isolate()->heap()->PrintToJSONObject(Heap::kNew, &jsobj); 169 isolate()->heap()->PrintToJSONObject(Heap::kNew, &jsobj);
164 isolate()->heap()->PrintToJSONObject(Heap::kOld, &jsobj); 170 isolate()->heap()->PrintToJSONObject(Heap::kOld, &jsobj);
165 } 171 }
172 if (bytes() != NULL) {
173 jsobj.AddPropertyBase64("bytes", bytes(), bytes_length());
174 }
166 } 175 }
167 176
168 } // namespace dart 177 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service_event.h ('k') | runtime/vm/service_isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698