OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 * A client object passed to the v8 debugger whose ownership will be taken by | 85 * A client object passed to the v8 debugger whose ownership will be taken by |
86 * it. v8 is always responsible for deleting the object. | 86 * it. v8 is always responsible for deleting the object. |
87 */ | 87 */ |
88 class ClientData { | 88 class ClientData { |
89 public: | 89 public: |
90 virtual ~ClientData() {} | 90 virtual ~ClientData() {} |
91 }; | 91 }; |
92 | 92 |
93 | 93 |
94 /** | 94 /** |
| 95 * A message object passed to the debug message handler. |
| 96 */ |
| 97 class Message { |
| 98 public: |
| 99 /** |
| 100 * Check type of message. |
| 101 */ |
| 102 virtual bool IsEvent() const = 0; |
| 103 virtual bool IsResponse() const = 0; |
| 104 virtual DebugEvent GetEvent() const = 0; |
| 105 |
| 106 /** |
| 107 * Indicate whether this is a response to a continue command which will |
| 108 * start the VM running after this is processed. |
| 109 */ |
| 110 virtual bool WillStartRunning() const = 0; |
| 111 |
| 112 /** |
| 113 * Access to execution state and event data. Don't store these cross |
| 114 * callbacks as their content becomes invalid. These objects are from the |
| 115 * debugger event that started the debug message loop. |
| 116 */ |
| 117 virtual Handle<Object> GetExecutionState() const = 0; |
| 118 virtual Handle<Object> GetEventData() const = 0; |
| 119 |
| 120 /** |
| 121 * Get the debugger protocol JSON. |
| 122 */ |
| 123 virtual Handle<String> GetJSON() const = 0; |
| 124 |
| 125 /** |
| 126 * Get the context active when the debug event happened. Note this is not |
| 127 * the current active context as the JavaScript part of the debugger is |
| 128 * running in it's own context which is entered at this point. |
| 129 */ |
| 130 virtual Handle<Context> GetEventContext() const = 0; |
| 131 |
| 132 /** |
| 133 * Client data passed with the corresponding request if any. This is the |
| 134 * client_data data value passed into Debug::SendCommand along with the |
| 135 * request that led to the message or NULL if the message is an event. The |
| 136 * debugger takes ownership of the data and will delete it even if there is |
| 137 * no message handler. |
| 138 */ |
| 139 virtual ClientData* GetClientData() const = 0; |
| 140 }; |
| 141 |
| 142 |
| 143 /** |
95 * Debug event callback function. | 144 * Debug event callback function. |
96 * | 145 * |
97 * \param event the type of the debug event that triggered the callback | 146 * \param event the type of the debug event that triggered the callback |
98 * (enum DebugEvent) | 147 * (enum DebugEvent) |
99 * \param exec_state execution state (JavaScript object) | 148 * \param exec_state execution state (JavaScript object) |
100 * \param event_data event specific data (JavaScript object) | 149 * \param event_data event specific data (JavaScript object) |
101 * \param data value passed by the user to SetDebugEventListener | 150 * \param data value passed by the user to SetDebugEventListener |
102 */ | 151 */ |
103 typedef void (*EventCallback)(DebugEvent event, | 152 typedef void (*EventCallback)(DebugEvent event, |
104 Handle<Object> exec_state, | 153 Handle<Object> exec_state, |
105 Handle<Object> event_data, | 154 Handle<Object> event_data, |
106 Handle<Value> data); | 155 Handle<Value> data); |
107 | 156 |
108 | 157 |
109 /** | 158 /** |
110 * Debug message callback function. | 159 * Debug message callback function. |
111 * | 160 * |
112 * \param message the debug message | 161 * \param message the debug message handler message object |
113 * \param length length of the message | 162 * \param length length of the message |
114 * \param data the data value passed when registering the message handler | 163 * \param data the data value passed when registering the message handler |
115 * \param client_data the data value passed into Debug::SendCommand along | 164 |
116 * with the request that led to the message or NULL if the message is an | |
117 * asynchronous event. The debugger takes ownership of the data and will | |
118 * delete it before dying even if there is no message handler. | |
119 * A MessageHandler does not take posession of the message string, | 165 * A MessageHandler does not take posession of the message string, |
120 * and must not rely on the data persisting after the handler returns. | 166 * and must not rely on the data persisting after the handler returns. |
121 */ | 167 */ |
122 typedef void (*MessageHandler)(const uint16_t* message, int length, | 168 typedef void (*MessageHandler)(const Message& message); |
123 ClientData* client_data); | |
124 | 169 |
125 /** | 170 /** |
126 * Debug host dispatch callback function. | 171 * Debug host dispatch callback function. |
127 */ | 172 */ |
128 typedef void (*HostDispatchHandler)(); | 173 typedef void (*HostDispatchHandler)(); |
129 | 174 |
130 // Set a C debug event listener. | 175 // Set a C debug event listener. |
131 static bool SetDebugEventListener(EventCallback that, | 176 static bool SetDebugEventListener(EventCallback that, |
132 Handle<Value> data = Handle<Value>()); | 177 Handle<Value> data = Handle<Value>()); |
133 | 178 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 }; | 224 }; |
180 | 225 |
181 | 226 |
182 } // namespace v8 | 227 } // namespace v8 |
183 | 228 |
184 | 229 |
185 #undef EXPORT | 230 #undef EXPORT |
186 | 231 |
187 | 232 |
188 #endif // V8_DEBUG_H_ | 233 #endif // V8_DEBUG_H_ |
OLD | NEW |