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 #ifndef VM_SERVICE_EVENT_H_ | 5 #ifndef VM_SERVICE_EVENT_H_ |
6 #define VM_SERVICE_EVENT_H_ | 6 #define VM_SERVICE_EVENT_H_ |
7 | 7 |
8 #include "vm/debugger.h" | 8 #include "vm/debugger.h" |
9 | 9 |
10 class DebuggerEvent; | 10 class DebuggerEvent; |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 class ServiceEvent { | 14 class ServiceEvent { |
15 public: | 15 public: |
16 enum EventType { | 16 enum EventKind { |
17 kIsolateStart, // New isolate has started | 17 kIsolateStart, // New isolate has started |
18 kIsolateExit, // Isolate has exited | 18 kIsolateExit, // Isolate has exited |
19 kIsolateUpdate, // Isolate identity information has changed | 19 kIsolateUpdate, // Isolate identity information has changed |
20 | 20 |
21 kPauseStart, // --pause-isolates-on-start | 21 kPauseStart, // --pause-isolates-on-start |
22 kPauseExit, // --pause-isolates-on-exit | 22 kPauseExit, // --pause-isolates-on-exit |
23 kPauseBreakpoint, | 23 kPauseBreakpoint, |
24 kPauseInterrupted, | 24 kPauseInterrupted, |
25 kPauseException, | 25 kPauseException, |
26 kResume, | 26 kResume, |
27 kBreakpointAdded, | 27 kBreakpointAdded, |
28 kBreakpointResolved, | 28 kBreakpointResolved, |
29 kBreakpointRemoved, | 29 kBreakpointRemoved, |
30 kInspect, | 30 kInspect, |
31 kDebuggerSettingsUpdate, | 31 kDebuggerSettingsUpdate, |
32 | 32 |
33 kGC, | 33 kGC, |
34 | 34 |
| 35 kEmbedder, |
| 36 |
35 kIllegal, | 37 kIllegal, |
36 }; | 38 }; |
37 | 39 |
38 ServiceEvent(Isolate* isolate, EventType event_type) | 40 ServiceEvent(Isolate* isolate, EventKind event_kind) |
39 : isolate_(isolate), | 41 : isolate_(isolate), |
40 type_(event_type), | 42 kind_(event_kind), |
| 43 embedder_kind_(NULL), |
| 44 embedder_stream_id_(NULL), |
41 breakpoint_(NULL), | 45 breakpoint_(NULL), |
42 top_frame_(NULL), | 46 top_frame_(NULL), |
43 exception_(NULL), | 47 exception_(NULL), |
44 inspectee_(NULL), | 48 inspectee_(NULL), |
45 gc_stats_(NULL) {} | 49 gc_stats_(NULL), |
| 50 bytes_(NULL), |
| 51 bytes_length_(0) {} |
46 | 52 |
47 explicit ServiceEvent(const DebuggerEvent* debugger_event); | 53 explicit ServiceEvent(const DebuggerEvent* debugger_event); |
48 | 54 |
49 Isolate* isolate() const { return isolate_; } | 55 Isolate* isolate() const { return isolate_; } |
50 | 56 |
51 EventType type() const { return type_; } | 57 EventKind kind() const { return kind_; } |
| 58 |
| 59 const char* embedder_kind() const { return embedder_kind_; } |
| 60 |
| 61 const char* KindAsCString() const; |
| 62 |
| 63 void set_embedder_kind(const char* embedder_kind) { |
| 64 embedder_kind_ = embedder_kind; |
| 65 } |
52 | 66 |
53 const char* stream_id() const; | 67 const char* stream_id() const; |
54 | 68 |
| 69 void set_embedder_stream_id(const char* stream_id) { |
| 70 embedder_stream_id_ = stream_id; |
| 71 } |
| 72 |
55 Breakpoint* breakpoint() const { | 73 Breakpoint* breakpoint() const { |
56 return breakpoint_; | 74 return breakpoint_; |
57 } | 75 } |
58 void set_breakpoint(Breakpoint* bpt) { | 76 void set_breakpoint(Breakpoint* bpt) { |
59 ASSERT(type() == kPauseBreakpoint || | 77 ASSERT(kind() == kPauseBreakpoint || |
60 type() == kBreakpointAdded || | 78 kind() == kBreakpointAdded || |
61 type() == kBreakpointResolved || | 79 kind() == kBreakpointResolved || |
62 type() == kBreakpointRemoved); | 80 kind() == kBreakpointRemoved); |
63 breakpoint_ = bpt; | 81 breakpoint_ = bpt; |
64 } | 82 } |
65 | 83 |
66 ActivationFrame* top_frame() const { | 84 ActivationFrame* top_frame() const { |
67 return top_frame_; | 85 return top_frame_; |
68 } | 86 } |
69 void set_top_frame(ActivationFrame* frame) { | 87 void set_top_frame(ActivationFrame* frame) { |
70 ASSERT(type() == kPauseBreakpoint || | 88 ASSERT(kind() == kPauseBreakpoint || |
71 type() == kPauseInterrupted || | 89 kind() == kPauseInterrupted || |
72 type() == kPauseException || | 90 kind() == kPauseException || |
73 type() == kResume); | 91 kind() == kResume); |
74 top_frame_ = frame; | 92 top_frame_ = frame; |
75 } | 93 } |
76 | 94 |
77 const Object* exception() const { | 95 const Object* exception() const { |
78 return exception_; | 96 return exception_; |
79 } | 97 } |
80 void set_exception(const Object* exception) { | 98 void set_exception(const Object* exception) { |
81 ASSERT(type_ == kPauseException); | 99 ASSERT(kind_ == kPauseException); |
82 exception_ = exception; | 100 exception_ = exception; |
83 } | 101 } |
84 | 102 |
85 const Object* inspectee() const { | 103 const Object* inspectee() const { |
86 return inspectee_; | 104 return inspectee_; |
87 } | 105 } |
88 void set_inspectee(const Object* inspectee) { | 106 void set_inspectee(const Object* inspectee) { |
89 ASSERT(type_ == kInspect); | 107 ASSERT(kind_ == kInspect); |
90 inspectee_ = inspectee; | 108 inspectee_ = inspectee; |
91 } | 109 } |
92 | 110 |
93 const Heap::GCStats* gc_stats() const { | 111 const Heap::GCStats* gc_stats() const { |
94 return gc_stats_; | 112 return gc_stats_; |
95 } | 113 } |
96 | 114 |
97 void set_gc_stats(const Heap::GCStats* gc_stats) { | 115 void set_gc_stats(const Heap::GCStats* gc_stats) { |
98 gc_stats_ = gc_stats; | 116 gc_stats_ = gc_stats; |
99 } | 117 } |
100 | 118 |
| 119 const uint8_t* bytes() const { |
| 120 return bytes_; |
| 121 } |
| 122 |
| 123 intptr_t bytes_length() const { |
| 124 return bytes_length_; |
| 125 } |
| 126 |
| 127 void set_bytes(const uint8_t* bytes, intptr_t bytes_length) { |
| 128 bytes_ = bytes; |
| 129 bytes_length_ = bytes_length; |
| 130 } |
| 131 |
101 void PrintJSON(JSONStream* js) const; | 132 void PrintJSON(JSONStream* js) const; |
102 | 133 |
103 static const char* EventTypeToCString(EventType type); | |
104 | |
105 private: | 134 private: |
106 Isolate* isolate_; | 135 Isolate* isolate_; |
107 EventType type_; | 136 EventKind kind_; |
| 137 const char* embedder_kind_; |
| 138 const char* embedder_stream_id_; |
108 Breakpoint* breakpoint_; | 139 Breakpoint* breakpoint_; |
109 ActivationFrame* top_frame_; | 140 ActivationFrame* top_frame_; |
110 const Object* exception_; | 141 const Object* exception_; |
111 const Object* inspectee_; | 142 const Object* inspectee_; |
112 const Heap::GCStats* gc_stats_; | 143 const Heap::GCStats* gc_stats_; |
| 144 const uint8_t* bytes_; |
| 145 intptr_t bytes_length_; |
113 }; | 146 }; |
114 | 147 |
115 } // namespace dart | 148 } // namespace dart |
116 | 149 |
117 #endif // VM_SERVICE_EVENT_H_ | 150 #endif // VM_SERVICE_EVENT_H_ |
OLD | NEW |