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

Side by Side Diff: Source/bindings/core/dart/DartScriptDebugServer.h

Issue 1532413002: Added Dartium changes onto 45.0.2454.104 (Closed) Base URL: http://src.chromium.org/blink/branches/chromium/2454
Patch Set: Created 5 years 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
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef DartScriptDebugServer_h
32 #define DartScriptDebugServer_h
33
34 #include "bindings/core/dart/DartScriptDebugListener.h"
35 #include "bindings/core/v8/PageScriptDebugServer.h"
36 #include "core/inspector/ScriptBreakpoint.h"
37
38 #include "wtf/Forward.h"
39 #include "wtf/HashSet.h"
40 #include "wtf/RefCounted.h"
41 #include <dart_api.h>
42 #include <dart_tools_api.h>
43 #include <v8.h>
44
45 namespace blink {
46
47 class DartInjectedScriptManager;
48 class Page;
49 template<typename T>
50 class HandleMap {
51 public:
52 HandleMap() : m_lastHandle(0)
53 {
54 }
55
56 int add(T value)
57 {
58 ASSERT(!m_valueToHandleMap.contains(value));
59 int handle = ++m_lastHandle;
60 m_handleToValueMap.set(handle, value);
61 m_valueToHandleMap.set(value, handle);
62 return handle;
63 }
64
65 T get(int handle)
66 {
67 return m_handleToValueMap.get(handle);
68 }
69
70 bool containsValue(T value)
71 {
72 return m_valueToHandleMap.contains(value);
73 }
74
75 int getByValue(T value)
76 {
77 ASSERT(m_valueToHandleMap.contains(value));
78 return m_valueToHandleMap.get(value);
79 }
80
81 T remove(int handle)
82 {
83 T value = m_handleToValueMap.take(handle);
84 m_valueToHandleMap.remove(value);
85 return value;
86 }
87
88 int removeByValue(T value)
89 {
90 int handle = m_valueToHandleMap.take(value);
91 m_handleToValueMap.remove(handle);
92 return handle;
93 }
94
95 void copyValues(Vector<T>& values)
96 {
97 copyKeysToVector(m_valueToHandleMap, values);
98 }
99
100 private:
101 int m_lastHandle;
102 HashMap<int, T> m_handleToValueMap;
103 HashMap<T, int> m_valueToHandleMap;
104 };
105
106 struct DartBreakpoint {
107 DartBreakpoint(intptr_t breakpointId, Dart_Isolate);
108
109 intptr_t m_breakpointId;
110 Dart_Isolate m_isolate;
111 };
112
113
114 struct DartBreakpointInfo {
115 DartBreakpointInfo(const String& scriptUrl, const ScriptBreakpoint&);
116 String m_scriptUrl;
117 ScriptBreakpoint m_scriptBreakpoint;
118 Vector<DartBreakpoint> m_breakpoints;
119 };
120
121 typedef HashMap<String, intptr_t> SetBreakpointsMap;
122
123 class DartPageDebug {
124 public:
125 DartPageDebug(Page*, int pageId);
126 ~DartPageDebug();
127
128 String setBreakpoint(const String& sourceID, const ScriptBreakpoint&, int* a ctualLineNumber, int* actualColumnNumber, bool interstatementLocation);
129
130 void registerIsolate(Dart_Isolate);
131 void unregisterIsolate(Dart_Isolate);
132
133 intptr_t setBreakpointHelper(DartBreakpointInfo*, const String& breakpointId String, Dart_Isolate, Dart_Handle& exception);
134
135 void removeBreakpoint(const String& breakpointId);
136 void removeBreakpointHelper(DartBreakpointInfo*);
137 void clearBreakpointsForIsolate(Dart_Isolate);
138 void clearBreakpoints();
139 void isolateLoaded();
140 void deferredReady();
141 void addListener(DartScriptDebugListener*);
142 void removeListener();
143 DartScriptDebugListener* listener() { return m_listener; }
144 String getScriptId(const String& url);
145 String lookupBreakpointId(intptr_t dartBreakpointId);
146
147 Vector<Dart_Isolate> isolates();
148 bool containsIsolate(Dart_Isolate isolate) { return m_isolateMap.containsVal ue(isolate); }
149 Page* page() { return m_page; }
150 private:
151 SetBreakpointsMap* getSetBreakpoints(Dart_Isolate);
152
153 void registerIsolateScripts(Dart_Isolate);
154 void dispatchDidParseSource(intptr_t libraryId, Dart_Handle scriptURL, Dart_ Isolate);
155
156 HandleMap<Dart_Isolate> m_isolateMap;
157
158 Page* m_page;
159 DartScriptDebugListener* m_listener;
160 int m_pageId;
161 HashMap<String, String> m_idToScriptUrlMap;
162 HashMap<String, String> m_scriptUrlToIdMap;
163 typedef HashMap<Dart_Isolate, SetBreakpointsMap*> SetBreakpointsForIsolateMa p;
164 SetBreakpointsForIsolateMap m_setBreakpointsForIsolate;
165
166 typedef HashMap<String, DartBreakpointInfo* > BreakpointMap;
167 BreakpointMap m_breakpoints;
168 typedef HashMap<intptr_t, String> BreakpointIdMap;
169 BreakpointIdMap m_breakpointIdMap;
170 int m_nextBreakpointId;
171 int m_nextScriptId;
172 };
173
174 class DartScriptDebugServer {
175 WTF_MAKE_NONCOPYABLE(DartScriptDebugServer);
176 public:
177 static DartScriptDebugServer& shared();
178
179 void addListener(DartScriptDebugListener*, Page*);
180 void removeListener(DartScriptDebugListener*, Page*);
181
182 void setClientMessageLoop(PageScriptDebugServer::ClientMessageLoop*);
183
184 String setBreakpoint(const String& sourceID, const ScriptBreakpoint&, int* a ctualLineNumber, int* actualColumnNumber, bool interstatementLocation);
185 void removeBreakpoint(const String& breakpointId);
186 void clearBreakpoints();
187 void setBreakpointsActivated(bool);
188
189 ScriptDebugServer::PauseOnExceptionsState pauseOnExceptionsState();
190 void setPauseOnExceptionsState(ScriptDebugServer::PauseOnExceptionsState);
191
192 void setPauseOnNextStatement(bool);
193 bool canBreakProgram();
194 void breakProgram();
195 void continueProgram();
196 void stepIntoStatement();
197 void stepOverStatement();
198 void stepOutOfFunction();
199
200 bool setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, RefPtr<TypeBuilder::Debugger::SetScriptSourceError>&, Da rt_StackTrace newCallFrames, RefPtr<JSONObject>* result);
201 ScriptCallFrame callFrameNoScopes(int index);
202
203 int frameCount();
204 Dart_StackTrace currentCallFrames();
205
206 bool isPaused();
207 bool runningNestedMessageLoop() { return m_runningNestedMessageLoop; }
208
209 void runScript(ScriptState*, const String& scriptId, ScriptValue* result, bo ol* wasThrown, String* exceptionDetailsText, int* lineNumber, int* columnNumber, RefPtrWillBeRawPtr<ScriptCallStack>* stackTrace);
210
211 static void pausedEventHandler(Dart_IsolateId, intptr_t breakpointId, const Dart_CodeLocation&);
212 static void exceptionHandler(Dart_IsolateId, Dart_Handle, Dart_StackTrace);
213 void handleException(Dart_IsolateId, Dart_Handle, Dart_StackTrace);
214
215 static void isolateEventHandler(Dart_IsolateId, Dart_IsolateEvent kind);
216 void handleInterrupted(Dart_IsolateId);
217 static void interruptAndRunAllTasks();
218 void runPendingTasks();
219
220 void registerIsolate(Dart_Isolate, Page*);
221 void unregisterIsolate(Dart_Isolate, Page*);
222 void isolateLoaded();
223 void deferredReady();
224
225 bool resolveCodeLocation(const Dart_CodeLocation&, int* line, int* column);
226
227 String getScriptId(const String& url, Dart_Isolate);
228 void clearWindowShell(Page*);
229
230 ScriptDebugServer::PauseOnExceptionsState pauseOnExceptionState() { return m _pauseOnExceptionState; }
231
232 void setInjectedScriptManager(DartInjectedScriptManager* manager) { m_inject edScriptManager = manager; }
233 DartInjectedScriptManager* injectedScriptManager() { return m_injectedScript Manager; }
234 protected:
235 explicit DartScriptDebugServer();
236 ~DartScriptDebugServer();
237
238 bool isAnyScriptPaused();
239
240 DartPageDebug* lookupPageDebugForId(const String& id);
241 DartPageDebug* lookupPageDebug(Page*);
242 DartPageDebug* lookupPageDebugForCurrentIsolate();
243 void runMessageLoopOnPause(Dart_Isolate);
244 void quitMessageLoopOnPause();
245 bool executeSkipPauseRequest(DartScriptDebugListener::SkipPauseRequest, Dart _StackTrace);
246 void handleProgramBreak(Dart_Isolate, Dart_StackTrace, intptr_t dartBreakpoi ntId, Dart_Handle exception, const Dart_CodeLocation&);
247 void handleDartDebugEvent(Dart_IsolateId, intptr_t breakpointId, Dart_Handle exception, const Dart_CodeLocation&);
248
249 ScriptCallFrame getScriptCallFrameHelper(int frameIndex);
250
251 void debugBreak();
252 void cancelDebugBreak();
253 Page* inferPage(Dart_Isolate);
254
255 Vector<Dart_Isolate> isolates();
256 Vector<DartPageDebug*> pages();
257
258 ScriptDebugServer::PauseOnExceptionsState m_pauseOnExceptionState;
259 bool m_breakpointsActivated;
260 bool m_runningNestedMessageLoop;
261 Dart_StackTrace m_executionState;
262 Dart_Isolate m_pausedIsolate;
263 Page* m_pausedPage;
264 HashSet<Dart_Isolate> m_interruptCalled;
265 HashSet<Dart_Isolate> m_interruptCancelled;
266
267 typedef HashMap<int, DartPageDebug*> DebugDataMap;
268 DebugDataMap m_pageIdToDebugDataMap;
269 typedef HashMap<Page*, int> PageToIdMap;
270 PageToIdMap m_pageToIdMap;
271
272 PageScriptDebugServer::ClientMessageLoop* m_clientMessageLoop;
273
274 DartInjectedScriptManager* m_injectedScriptManager;
275
276 int m_nextPageId;
277 };
278
279 }
280
281 #endif // DartScriptDebugServer_h
OLDNEW
« no previous file with comments | « Source/bindings/core/dart/DartScriptDebugListener.h ('k') | Source/bindings/core/dart/DartScriptDebugServer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698