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

Unified Diff: runtime/vm/service_event.cc

Issue 979823003: Major rework of vm service events. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/service_event.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service_event.cc
diff --git a/runtime/vm/service_event.cc b/runtime/vm/service_event.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9f7c63da614b33a48570369aea68c2d3c929b09f
--- /dev/null
+++ b/runtime/vm/service_event.cc
@@ -0,0 +1,103 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "vm/service_event.h"
+
+namespace dart {
+
+// Translate from the legacy DebugEvent to a ServiceEvent.
+static ServiceEvent::EventType TranslateEventType(
+ DebuggerEvent::EventType type) {
+ switch (type) {
+ case DebuggerEvent::kIsolateCreated:
+ return ServiceEvent::kIsolateStart;
+
+ case DebuggerEvent::kIsolateShutdown:
+ return ServiceEvent::kIsolateExit;
+
+ case DebuggerEvent::kBreakpointReached:
+ return ServiceEvent::kPauseBreakpoint;
+
+ case DebuggerEvent::kIsolateInterrupted:
+ return ServiceEvent::kPauseInterrupted;
+
+ case DebuggerEvent::kExceptionThrown:
+ return ServiceEvent::kPauseException;
+
+ default:
+ UNREACHABLE();
+ return ServiceEvent::kIllegal;
+ }
+}
+
+ServiceEvent::ServiceEvent(const DebuggerEvent* debugger_event)
+ : isolate_(debugger_event->isolate()),
+ type_(TranslateEventType(debugger_event->type())),
+ breakpoint_(NULL),
+ top_frame_(NULL),
+ exception_(NULL) {
+ DebuggerEvent::EventType type = debugger_event->type();
+ if (type == DebuggerEvent::kBreakpointReached) {
+ set_breakpoint(debugger_event->breakpoint());
+ }
+ if (type == DebuggerEvent::kExceptionThrown) {
+ set_exception(debugger_event->exception());
+ }
+ if (type == DebuggerEvent::kBreakpointReached ||
+ type == DebuggerEvent::kIsolateInterrupted ||
+ type == DebuggerEvent::kExceptionThrown) {
+ set_top_frame(debugger_event->top_frame());
+ }
+}
+
+
+const char* ServiceEvent::EventTypeToCString(EventType type) {
+ switch (type) {
+ case kIsolateStart:
+ return "IsolateStart";
+ case kIsolateExit:
+ return "IsolateExit";
+ case kPauseStart:
+ return "PauseStart";
+ case kPauseExit:
+ return "PauseExit";
+ case kPauseBreakpoint:
+ return "PauseBreakpoint";
+ case kPauseInterrupted:
+ return "PauseInterrupted";
+ case kPauseException:
+ return "PauseException";
+ case kResume:
+ return "Resume";
+ case kBreakpointAdded:
+ return "BreakpointAdded";
+ case kBreakpointResolved:
+ return "BreakpointResolved";
+ case kBreakpointRemoved:
+ return "BreakpointRemoved";
+ default:
+ UNREACHABLE();
+ return "Unknown";
+ }
+}
+
+
+void ServiceEvent::PrintJSON(JSONStream* js) const {
+ JSONObject jsobj(js);
+ jsobj.AddProperty("type", "ServiceEvent");
+ jsobj.AddProperty("eventType", EventTypeToCString(type()));
+ jsobj.AddProperty("isolate", isolate());
+ if (breakpoint() != NULL) {
+ jsobj.AddProperty("breakpoint", breakpoint());
+ }
+ if (top_frame() != NULL) {
+ JSONObject jsFrame(&jsobj, "topFrame");
+ top_frame()->PrintToJSONObject(&jsFrame);
+ }
+ if (exception() != NULL) {
+ jsobj.AddProperty("exception", *(exception()));
+ }
+}
+
+} // namespace dart
« no previous file with comments | « runtime/vm/service_event.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698