OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
6 | 6 |
| 7 #include "platform/inspector_protocol/String16.h" |
7 #include "platform/inspector_protocol/Values.h" | 8 #include "platform/inspector_protocol/Values.h" |
8 #include "platform/v8_inspector/IgnoreExceptionsScope.h" | 9 #include "platform/v8_inspector/IgnoreExceptionsScope.h" |
9 #include "platform/v8_inspector/InjectedScript.h" | 10 #include "platform/v8_inspector/InjectedScript.h" |
10 #include "platform/v8_inspector/InjectedScriptHost.h" | 11 #include "platform/v8_inspector/InjectedScriptHost.h" |
11 #include "platform/v8_inspector/InjectedScriptManager.h" | 12 #include "platform/v8_inspector/InjectedScriptManager.h" |
12 #include "platform/v8_inspector/JavaScriptCallFrame.h" | 13 #include "platform/v8_inspector/JavaScriptCallFrame.h" |
13 #include "platform/v8_inspector/PromiseTracker.h" | 14 #include "platform/v8_inspector/PromiseTracker.h" |
14 #include "platform/v8_inspector/RemoteObjectId.h" | 15 #include "platform/v8_inspector/RemoteObjectId.h" |
15 #include "platform/v8_inspector/V8AsyncCallTracker.h" | 16 #include "platform/v8_inspector/V8AsyncCallTracker.h" |
16 #include "platform/v8_inspector/V8JavaScriptCallFrame.h" | 17 #include "platform/v8_inspector/V8JavaScriptCallFrame.h" |
17 #include "platform/v8_inspector/V8Regex.h" | 18 #include "platform/v8_inspector/V8Regex.h" |
18 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" | 19 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" |
19 #include "platform/v8_inspector/V8StackTraceImpl.h" | 20 #include "platform/v8_inspector/V8StackTraceImpl.h" |
20 #include "platform/v8_inspector/V8StringUtil.h" | 21 #include "platform/v8_inspector/V8StringUtil.h" |
21 #include "platform/v8_inspector/public/V8ContentSearchUtil.h" | 22 #include "platform/v8_inspector/public/V8ContentSearchUtil.h" |
22 #include "platform/v8_inspector/public/V8Debugger.h" | 23 #include "platform/v8_inspector/public/V8Debugger.h" |
23 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 24 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
24 #include "wtf/text/StringBuilder.h" | |
25 #include "wtf/text/WTFString.h" | |
26 | 25 |
27 using blink::protocol::Array; | 26 using blink::protocol::Array; |
28 using blink::protocol::Maybe; | 27 using blink::protocol::Maybe; |
29 using blink::protocol::Debugger::AsyncOperation; | 28 using blink::protocol::Debugger::AsyncOperation; |
30 using blink::protocol::Debugger::BreakpointId; | 29 using blink::protocol::Debugger::BreakpointId; |
31 using blink::protocol::Debugger::CallFrame; | 30 using blink::protocol::Debugger::CallFrame; |
32 using blink::protocol::Debugger::CollectionEntry; | 31 using blink::protocol::Debugger::CollectionEntry; |
33 using blink::protocol::Runtime::ExceptionDetails; | 32 using blink::protocol::Runtime::ExceptionDetails; |
34 using blink::protocol::Debugger::FunctionDetails; | 33 using blink::protocol::Debugger::FunctionDetails; |
35 using blink::protocol::Debugger::GeneratorObjectDetails; | 34 using blink::protocol::Debugger::GeneratorObjectDetails; |
(...skipping 20 matching lines...) Expand all Loading... |
56 static const char skipAllPauses[] = "skipAllPauses"; | 55 static const char skipAllPauses[] = "skipAllPauses"; |
57 | 56 |
58 } // namespace DebuggerAgentState; | 57 } // namespace DebuggerAgentState; |
59 | 58 |
60 static const int maxSkipStepFrameCount = 128; | 59 static const int maxSkipStepFrameCount = 128; |
61 | 60 |
62 const char V8DebuggerAgent::backtraceObjectGroup[] = "backtrace"; | 61 const char V8DebuggerAgent::backtraceObjectGroup[] = "backtrace"; |
63 | 62 |
64 const int V8DebuggerAgent::unknownAsyncOperationId = 0; | 63 const int V8DebuggerAgent::unknownAsyncOperationId = 0; |
65 | 64 |
66 static String breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) | 65 static String16 breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) |
67 { | 66 { |
68 switch (source) { | 67 switch (source) { |
69 case V8DebuggerAgentImpl::UserBreakpointSource: | 68 case V8DebuggerAgentImpl::UserBreakpointSource: |
70 break; | 69 break; |
71 case V8DebuggerAgentImpl::DebugCommandBreakpointSource: | 70 case V8DebuggerAgentImpl::DebugCommandBreakpointSource: |
72 return ":debug"; | 71 return ":debug"; |
73 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource: | 72 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource: |
74 return ":monitor"; | 73 return ":monitor"; |
75 } | 74 } |
76 return String(); | 75 return String16(); |
77 } | 76 } |
78 | 77 |
79 static String generateBreakpointId(const String& scriptId, int lineNumber, int c
olumnNumber, V8DebuggerAgentImpl::BreakpointSource source) | 78 static String16 generateBreakpointId(const String16& scriptId, int lineNumber, i
nt columnNumber, V8DebuggerAgentImpl::BreakpointSource source) |
80 { | 79 { |
81 return scriptId + ':' + String::number(lineNumber) + ':' + String::number(co
lumnNumber) + breakpointIdSuffix(source); | 80 return scriptId + ":" + String16::number(lineNumber) + ":" + String16::numbe
r(columnNumber) + breakpointIdSuffix(source); |
82 } | 81 } |
83 | 82 |
84 static bool positionComparator(const std::pair<int, int>& a, const std::pair<int
, int>& b) | 83 static bool positionComparator(const std::pair<int, int>& a, const std::pair<int
, int>& b) |
85 { | 84 { |
86 if (a.first != b.first) | 85 if (a.first != b.first) |
87 return a.first < b.first; | 86 return a.first < b.first; |
88 return a.second < b.second; | 87 return a.second < b.second; |
89 } | 88 } |
90 | 89 |
91 static const LChar hexDigits[17] = "0123456789ABCDEF"; | 90 static const LChar hexDigits[17] = "0123456789ABCDEF"; |
92 | 91 |
93 static void appendUnsignedAsHex(unsigned number, String& destination) | 92 static void appendUnsignedAsHex(unsigned number, String16Builder* destination) |
94 { | 93 { |
95 for (size_t i = 0; i < 8; ++i) { | 94 for (size_t i = 0; i < 8; ++i) { |
96 destination.append(hexDigits[number & 0xF]); | 95 destination->append(hexDigits[number & 0xF]); |
97 number >>= 4; | 96 number >>= 4; |
98 } | 97 } |
99 } | 98 } |
100 | 99 |
101 // Hash algorithm for substrings is described in "Über die Komplexität der Multi
plikation in | 100 // Hash algorithm for substrings is described in "Über die Komplexität der Multi
plikation in |
102 // eingeschränkten Branchingprogrammmodellen" by Woelfe. | 101 // eingeschränkten Branchingprogrammmodellen" by Woelfe. |
103 // http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECT
ION00832000000000000000 | 102 // http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECT
ION00832000000000000000 |
104 static String calculateHash(const String& str) | 103 static String16 calculateHash(const String16& str) |
105 { | 104 { |
106 static uint64_t prime[] = { 0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35,
0x81ABE279 }; | 105 static uint64_t prime[] = { 0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35,
0x81ABE279 }; |
107 static uint64_t random[] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476,
0xC3D2E1F0 }; | 106 static uint64_t random[] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476,
0xC3D2E1F0 }; |
108 static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA1
1D, 0x8F462907 }; | 107 static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA1
1D, 0x8F462907 }; |
109 | 108 |
110 uint64_t hashes[] = { 0, 0, 0, 0, 0 }; | 109 uint64_t hashes[] = { 0, 0, 0, 0, 0 }; |
111 uint64_t zi[] = { 1, 1, 1, 1, 1 }; | 110 uint64_t zi[] = { 1, 1, 1, 1, 1 }; |
112 | 111 |
113 const size_t hashesSize = WTF_ARRAY_LENGTH(hashes); | 112 const size_t hashesSize = WTF_ARRAY_LENGTH(hashes); |
114 | 113 |
(...skipping 18 matching lines...) Expand all Loading... |
133 } | 132 } |
134 uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; | 133 uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; |
135 hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; | 134 hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; |
136 zi[current] = (zi[current] * random[current]) % prime[current]; | 135 zi[current] = (zi[current] * random[current]) % prime[current]; |
137 current = current == hashesSize - 1 ? 0 : current + 1; | 136 current = current == hashesSize - 1 ? 0 : current + 1; |
138 } | 137 } |
139 | 138 |
140 for (size_t i = 0; i < hashesSize; ++i) | 139 for (size_t i = 0; i < hashesSize; ++i) |
141 hashes[i] = (hashes[i] + zi[i] * (prime[i] - 1)) % prime[i]; | 140 hashes[i] = (hashes[i] + zi[i] * (prime[i] - 1)) % prime[i]; |
142 | 141 |
143 String hash; | 142 String16Builder hash; |
144 for (size_t i = 0; i < hashesSize; ++i) | 143 for (size_t i = 0; i < hashesSize; ++i) |
145 appendUnsignedAsHex(hashes[i], hash); | 144 appendUnsignedAsHex(hashes[i], &hash); |
146 return hash; | 145 return hash.toString(); |
147 } | 146 } |
148 | 147 |
149 PassOwnPtr<V8DebuggerAgent> V8DebuggerAgent::create(V8RuntimeAgent* runtimeAgent
, int contextGroupId) | 148 PassOwnPtr<V8DebuggerAgent> V8DebuggerAgent::create(V8RuntimeAgent* runtimeAgent
, int contextGroupId) |
150 { | 149 { |
151 V8RuntimeAgentImpl* runtimeAgentImpl = static_cast<V8RuntimeAgentImpl*>(runt
imeAgent); | 150 V8RuntimeAgentImpl* runtimeAgentImpl = static_cast<V8RuntimeAgentImpl*>(runt
imeAgent); |
152 return adoptPtr(new V8DebuggerAgentImpl(runtimeAgentImpl->injectedScriptMana
ger(), runtimeAgentImpl->debugger(), contextGroupId)); | 151 return adoptPtr(new V8DebuggerAgentImpl(runtimeAgentImpl->injectedScriptMana
ger(), runtimeAgentImpl->debugger(), contextGroupId)); |
153 } | 152 } |
154 | 153 |
155 V8DebuggerAgentImpl::V8DebuggerAgentImpl(InjectedScriptManager* injectedScriptMa
nager, V8DebuggerImpl* debugger, int contextGroupId) | 154 V8DebuggerAgentImpl::V8DebuggerAgentImpl(InjectedScriptManager* injectedScriptMa
nager, V8DebuggerImpl* debugger, int contextGroupId) |
156 : m_injectedScriptManager(injectedScriptManager) | 155 : m_injectedScriptManager(injectedScriptManager) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 m_state->setBoolean(DebuggerAgentState::promiseTrackerCaptureStacks, false); | 236 m_state->setBoolean(DebuggerAgentState::promiseTrackerCaptureStacks, false); |
238 | 237 |
239 debugger().removeAgent(m_contextGroupId); | 238 debugger().removeAgent(m_contextGroupId); |
240 m_pausedContext.Reset(); | 239 m_pausedContext.Reset(); |
241 m_currentCallStack.Reset(); | 240 m_currentCallStack.Reset(); |
242 m_scripts.clear(); | 241 m_scripts.clear(); |
243 m_blackboxedPositions.clear(); | 242 m_blackboxedPositions.clear(); |
244 m_breakpointIdToDebuggerBreakpointIds.clear(); | 243 m_breakpointIdToDebuggerBreakpointIds.clear(); |
245 internalSetAsyncCallStackDepth(0); | 244 internalSetAsyncCallStackDepth(0); |
246 m_promiseTracker->setEnabled(false, false); | 245 m_promiseTracker->setEnabled(false, false); |
247 m_continueToLocationBreakpointId = String(); | 246 m_continueToLocationBreakpointId = String16(); |
248 clearBreakDetails(); | 247 clearBreakDetails(); |
249 m_scheduledDebuggerStep = NoStep; | 248 m_scheduledDebuggerStep = NoStep; |
250 m_skipNextDebuggerStepOut = false; | 249 m_skipNextDebuggerStepOut = false; |
251 m_javaScriptPauseScheduled = false; | 250 m_javaScriptPauseScheduled = false; |
252 m_steppingFromFramework = false; | 251 m_steppingFromFramework = false; |
253 m_pausingOnNativeEvent = false; | 252 m_pausingOnNativeEvent = false; |
254 m_skippedStepFrameCount = 0; | 253 m_skippedStepFrameCount = 0; |
255 m_recursionLevelForStepFrame = 0; | 254 m_recursionLevelForStepFrame = 0; |
256 m_asyncOperationNotifications.clear(); | 255 m_asyncOperationNotifications.clear(); |
257 clearStepIntoAsync(); | 256 clearStepIntoAsync(); |
(...skipping 23 matching lines...) Expand all Loading... |
281 disable(&error); | 280 disable(&error); |
282 ASSERT(m_frontend); | 281 ASSERT(m_frontend); |
283 m_frontend = nullptr; | 282 m_frontend = nullptr; |
284 } | 283 } |
285 | 284 |
286 void V8DebuggerAgentImpl::restore() | 285 void V8DebuggerAgentImpl::restore() |
287 { | 286 { |
288 ASSERT(!m_enabled); | 287 ASSERT(!m_enabled); |
289 m_frontend->globalObjectCleared(); | 288 m_frontend->globalObjectCleared(); |
290 enable(); | 289 enable(); |
291 String error; | 290 ErrorString error; |
292 | 291 |
293 int pauseState = V8DebuggerImpl::DontPauseOnExceptions; | 292 int pauseState = V8DebuggerImpl::DontPauseOnExceptions; |
294 m_state->getNumber(DebuggerAgentState::pauseOnExceptionsState, &pauseState); | 293 m_state->getNumber(DebuggerAgentState::pauseOnExceptionsState, &pauseState); |
295 setPauseOnExceptionsImpl(&error, pauseState); | 294 setPauseOnExceptionsImpl(&error, pauseState); |
296 | 295 |
297 m_skipAllPauses = m_state->booleanProperty(DebuggerAgentState::skipAllPauses
, false); | 296 m_skipAllPauses = m_state->booleanProperty(DebuggerAgentState::skipAllPauses
, false); |
298 | 297 |
299 int asyncCallStackDepth = 0; | 298 int asyncCallStackDepth = 0; |
300 m_state->getNumber(DebuggerAgentState::asyncCallStackDepth, &asyncCallStackD
epth); | 299 m_state->getNumber(DebuggerAgentState::asyncCallStackDepth, &asyncCallStackD
epth); |
301 internalSetAsyncCallStackDepth(asyncCallStackDepth); | 300 internalSetAsyncCallStackDepth(asyncCallStackDepth); |
(...skipping 12 matching lines...) Expand all Loading... |
314 { | 313 { |
315 m_skipAllPauses = skipped; | 314 m_skipAllPauses = skipped; |
316 m_state->setBoolean(DebuggerAgentState::skipAllPauses, m_skipAllPauses); | 315 m_state->setBoolean(DebuggerAgentState::skipAllPauses, m_skipAllPauses); |
317 } | 316 } |
318 | 317 |
319 bool V8DebuggerAgentImpl::isPaused() | 318 bool V8DebuggerAgentImpl::isPaused() |
320 { | 319 { |
321 return debugger().isPaused(); | 320 return debugger().isPaused(); |
322 } | 321 } |
323 | 322 |
324 static PassOwnPtr<protocol::DictionaryValue> buildObjectForBreakpointCookie(cons
t String& url, int lineNumber, int columnNumber, const String& condition, bool i
sRegex) | 323 static PassOwnPtr<protocol::DictionaryValue> buildObjectForBreakpointCookie(cons
t String16& url, int lineNumber, int columnNumber, const String16& condition, bo
ol isRegex) |
325 { | 324 { |
326 OwnPtr<protocol::DictionaryValue> breakpointObject = protocol::DictionaryVal
ue::create(); | 325 OwnPtr<protocol::DictionaryValue> breakpointObject = protocol::DictionaryVal
ue::create(); |
327 breakpointObject->setString(DebuggerAgentState::url, url); | 326 breakpointObject->setString(DebuggerAgentState::url, url); |
328 breakpointObject->setNumber(DebuggerAgentState::lineNumber, lineNumber); | 327 breakpointObject->setNumber(DebuggerAgentState::lineNumber, lineNumber); |
329 breakpointObject->setNumber(DebuggerAgentState::columnNumber, columnNumber); | 328 breakpointObject->setNumber(DebuggerAgentState::columnNumber, columnNumber); |
330 breakpointObject->setString(DebuggerAgentState::condition, condition); | 329 breakpointObject->setString(DebuggerAgentState::condition, condition); |
331 breakpointObject->setBoolean(DebuggerAgentState::isRegex, isRegex); | 330 breakpointObject->setBoolean(DebuggerAgentState::isRegex, isRegex); |
332 return breakpointObject.release(); | 331 return breakpointObject.release(); |
333 } | 332 } |
334 | 333 |
335 static bool matches(V8DebuggerImpl* debugger, const String& url, const String& p
attern, bool isRegex) | 334 static bool matches(V8DebuggerImpl* debugger, const String16& url, const String1
6& pattern, bool isRegex) |
336 { | 335 { |
337 if (isRegex) { | 336 if (isRegex) { |
338 V8Regex regex(debugger, pattern, TextCaseSensitive); | 337 V8Regex regex(debugger, pattern, true); |
339 return regex.match(url) != -1; | 338 return regex.match(url) != -1; |
340 } | 339 } |
341 return url == pattern; | 340 return url == pattern; |
342 } | 341 } |
343 | 342 |
344 void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString, | 343 void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString, |
345 int lineNumber, | 344 int lineNumber, |
346 const Maybe<String>& optionalURL, | 345 const Maybe<String16>& optionalURL, |
347 const Maybe<String>& optionalURLRegex, | 346 const Maybe<String16>& optionalURLRegex, |
348 const Maybe<int>& optionalColumnNumber, | 347 const Maybe<int>& optionalColumnNumber, |
349 const Maybe<String>& optionalCondition, | 348 const Maybe<String16>& optionalCondition, |
350 BreakpointId* outBreakpointId, | 349 String16* outBreakpointId, |
351 OwnPtr<protocol::Array<protocol::Debugger::Location>>* locations) | 350 OwnPtr<protocol::Array<protocol::Debugger::Location>>* locations) |
352 { | 351 { |
353 *locations = Array<protocol::Debugger::Location>::create(); | 352 *locations = Array<protocol::Debugger::Location>::create(); |
354 if (optionalURL.isJust() == optionalURLRegex.isJust()) { | 353 if (optionalURL.isJust() == optionalURLRegex.isJust()) { |
355 *errorString = "Either url or urlRegex must be specified."; | 354 *errorString = "Either url or urlRegex must be specified."; |
356 return; | 355 return; |
357 } | 356 } |
358 | 357 |
359 String url = optionalURL.isJust() ? optionalURL.fromJust() : optionalURLRege
x.fromJust(); | 358 String16 url = optionalURL.isJust() ? optionalURL.fromJust() : optionalURLRe
gex.fromJust(); |
360 int columnNumber = 0; | 359 int columnNumber = 0; |
361 if (optionalColumnNumber.isJust()) { | 360 if (optionalColumnNumber.isJust()) { |
362 columnNumber = optionalColumnNumber.fromJust(); | 361 columnNumber = optionalColumnNumber.fromJust(); |
363 if (columnNumber < 0) { | 362 if (columnNumber < 0) { |
364 *errorString = "Incorrect column number"; | 363 *errorString = "Incorrect column number"; |
365 return; | 364 return; |
366 } | 365 } |
367 } | 366 } |
368 String condition = optionalCondition.fromMaybe(""); | 367 String16 condition = optionalCondition.fromMaybe(""); |
369 bool isRegex = optionalURLRegex.isJust(); | 368 bool isRegex = optionalURLRegex.isJust(); |
370 | 369 |
371 String breakpointId = (isRegex ? "/" + url + "/" : url) + ':' + String::numb
er(lineNumber) + ':' + String::number(columnNumber); | 370 String16 breakpointId = (isRegex ? "/" + url + "/" : url) + ":" + String16::
number(lineNumber) + ":" + String16::number(columnNumber); |
372 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg
entState::javaScriptBreakpoints); | 371 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg
entState::javaScriptBreakpoints); |
373 if (!breakpointsCookie) { | 372 if (!breakpointsCookie) { |
374 OwnPtr<protocol::DictionaryValue> newValue = protocol::DictionaryValue::
create(); | 373 OwnPtr<protocol::DictionaryValue> newValue = protocol::DictionaryValue::
create(); |
375 breakpointsCookie = newValue.get(); | 374 breakpointsCookie = newValue.get(); |
376 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, newValue.r
elease()); | 375 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, newValue.r
elease()); |
377 } | 376 } |
378 if (breakpointsCookie->get(breakpointId)) { | 377 if (breakpointsCookie->get(breakpointId)) { |
379 *errorString = "Breakpoint at specified location already exists."; | 378 *errorString = "Breakpoint at specified location already exists."; |
380 return; | 379 return; |
381 } | 380 } |
382 | 381 |
383 breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(ur
l, lineNumber, columnNumber, condition, isRegex)); | 382 breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(ur
l, lineNumber, columnNumber, condition, isRegex)); |
384 | 383 |
385 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); | 384 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); |
386 for (auto& script : m_scripts) { | 385 for (auto& script : m_scripts) { |
387 if (!matches(m_debugger, script.second->sourceURL(), url, isRegex)) | 386 if (!matches(m_debugger, script.second->sourceURL(), url, isRegex)) |
388 continue; | 387 continue; |
389 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(breakp
ointId, script.first, breakpoint, UserBreakpointSource); | 388 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(breakp
ointId, script.first, breakpoint, UserBreakpointSource); |
390 if (location) | 389 if (location) |
391 (*locations)->addItem(location.release()); | 390 (*locations)->addItem(location.release()); |
392 } | 391 } |
393 | 392 |
394 *outBreakpointId = breakpointId; | 393 *outBreakpointId = breakpointId; |
395 } | 394 } |
396 | 395 |
397 static bool parseLocation(ErrorString* errorString, PassOwnPtr<protocol::Debugge
r::Location> location, String* scriptId, int* lineNumber, int* columnNumber) | 396 static bool parseLocation(ErrorString* errorString, PassOwnPtr<protocol::Debugge
r::Location> location, String16* scriptId, int* lineNumber, int* columnNumber) |
398 { | 397 { |
399 *scriptId = location->getScriptId(); | 398 *scriptId = location->getScriptId(); |
400 *lineNumber = location->getLineNumber(); | 399 *lineNumber = location->getLineNumber(); |
401 *columnNumber = location->getColumnNumber(0); | 400 *columnNumber = location->getColumnNumber(0); |
402 return true; | 401 return true; |
403 } | 402 } |
404 | 403 |
405 void V8DebuggerAgentImpl::setBreakpoint(ErrorString* errorString, | 404 void V8DebuggerAgentImpl::setBreakpoint(ErrorString* errorString, |
406 PassOwnPtr<protocol::Debugger::Location> location, | 405 PassOwnPtr<protocol::Debugger::Location> location, |
407 const Maybe<String>& optionalCondition, | 406 const Maybe<String16>& optionalCondition, |
408 BreakpointId* outBreakpointId, | 407 String16* outBreakpointId, |
409 OwnPtr<protocol::Debugger::Location>* actualLocation) | 408 OwnPtr<protocol::Debugger::Location>* actualLocation) |
410 { | 409 { |
411 String scriptId; | 410 String16 scriptId; |
412 int lineNumber; | 411 int lineNumber; |
413 int columnNumber; | 412 int columnNumber; |
414 | 413 |
415 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) | 414 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) |
416 return; | 415 return; |
417 | 416 |
418 String condition = optionalCondition.fromMaybe(""); | 417 String16 condition = optionalCondition.fromMaybe(""); |
419 | 418 |
420 String breakpointId = generateBreakpointId(scriptId, lineNumber, columnNumbe
r, UserBreakpointSource); | 419 String16 breakpointId = generateBreakpointId(scriptId, lineNumber, columnNum
ber, UserBreakpointSource); |
421 if (m_breakpointIdToDebuggerBreakpointIds.contains(breakpointId)) { | 420 if (m_breakpointIdToDebuggerBreakpointIds.contains(breakpointId)) { |
422 *errorString = "Breakpoint at specified location already exists."; | 421 *errorString = "Breakpoint at specified location already exists."; |
423 return; | 422 return; |
424 } | 423 } |
425 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); | 424 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); |
426 *actualLocation = resolveBreakpoint(breakpointId, scriptId, breakpoint, User
BreakpointSource); | 425 *actualLocation = resolveBreakpoint(breakpointId, scriptId, breakpoint, User
BreakpointSource); |
427 if (*actualLocation) | 426 if (*actualLocation) |
428 *outBreakpointId = breakpointId; | 427 *outBreakpointId = breakpointId; |
429 else | 428 else |
430 *errorString = "Could not resolve breakpoint"; | 429 *errorString = "Could not resolve breakpoint"; |
431 } | 430 } |
432 | 431 |
433 void V8DebuggerAgentImpl::removeBreakpoint(ErrorString* errorString, const Strin
g& breakpointId) | 432 void V8DebuggerAgentImpl::removeBreakpoint(ErrorString* errorString, const Strin
g16& breakpointId) |
434 { | 433 { |
435 if (!checkEnabled(errorString)) | 434 if (!checkEnabled(errorString)) |
436 return; | 435 return; |
437 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg
entState::javaScriptBreakpoints); | 436 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg
entState::javaScriptBreakpoints); |
438 if (breakpointsCookie) | 437 if (breakpointsCookie) |
439 breakpointsCookie->remove(breakpointId); | 438 breakpointsCookie->remove(breakpointId); |
440 removeBreakpoint(breakpointId); | 439 removeBreakpoint(breakpointId); |
441 } | 440 } |
442 | 441 |
443 void V8DebuggerAgentImpl::removeBreakpoint(const String& breakpointId) | 442 void V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) |
444 { | 443 { |
445 ASSERT(enabled()); | 444 ASSERT(enabled()); |
446 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat
or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); | 445 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat
or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); |
447 if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.e
nd()) | 446 if (debuggerBreakpointIdsIterator == m_breakpointIdToDebuggerBreakpointIds.e
nd()) |
448 return; | 447 return; |
449 protocol::Vector<String>* ids = debuggerBreakpointIdsIterator->second; | 448 protocol::Vector<String16>* ids = debuggerBreakpointIdsIterator->second; |
450 for (size_t i = 0; i < ids->size(); ++i) { | 449 for (size_t i = 0; i < ids->size(); ++i) { |
451 const String& debuggerBreakpointId = ids->at(i); | 450 const String16& debuggerBreakpointId = ids->at(i); |
452 | 451 |
453 debugger().removeBreakpoint(debuggerBreakpointId); | 452 debugger().removeBreakpoint(debuggerBreakpointId); |
454 m_serverBreakpoints.remove(debuggerBreakpointId); | 453 m_serverBreakpoints.remove(debuggerBreakpointId); |
455 } | 454 } |
456 m_breakpointIdToDebuggerBreakpointIds.remove(breakpointId); | 455 m_breakpointIdToDebuggerBreakpointIds.remove(breakpointId); |
457 } | 456 } |
458 | 457 |
459 void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, | 458 void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, |
460 PassOwnPtr<protocol::Debugger::Location> location, | 459 PassOwnPtr<protocol::Debugger::Location> location, |
461 const protocol::Maybe<bool>& interstateLocationOpt) | 460 const protocol::Maybe<bool>& interstateLocationOpt) |
462 { | 461 { |
463 if (!checkEnabled(errorString)) | 462 if (!checkEnabled(errorString)) |
464 return; | 463 return; |
465 if (!m_continueToLocationBreakpointId.isEmpty()) { | 464 if (!m_continueToLocationBreakpointId.isEmpty()) { |
466 debugger().removeBreakpoint(m_continueToLocationBreakpointId); | 465 debugger().removeBreakpoint(m_continueToLocationBreakpointId); |
467 m_continueToLocationBreakpointId = ""; | 466 m_continueToLocationBreakpointId = ""; |
468 } | 467 } |
469 | 468 |
470 String scriptId; | 469 String16 scriptId; |
471 int lineNumber; | 470 int lineNumber; |
472 int columnNumber; | 471 int columnNumber; |
473 | 472 |
474 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) | 473 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) |
475 return; | 474 return; |
476 | 475 |
477 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); | 476 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); |
478 m_continueToLocationBreakpointId = debugger().setBreakpoint(scriptId, breakp
oint, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false)); | 477 m_continueToLocationBreakpointId = debugger().setBreakpoint(scriptId, breakp
oint, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false)); |
479 resume(errorString); | 478 resume(errorString); |
480 } | 479 } |
481 | 480 |
482 void V8DebuggerAgentImpl::getStepInPositions(ErrorString* errorString, const Str
ing& callFrameId, Maybe<Array<protocol::Debugger::Location>>* positions) | 481 void V8DebuggerAgentImpl::getStepInPositions(ErrorString* errorString, const Str
ing16& callFrameId, Maybe<Array<protocol::Debugger::Location>>* positions) |
483 { | 482 { |
484 if (!isPaused() || m_currentCallStack.IsEmpty()) { | 483 if (!isPaused() || m_currentCallStack.IsEmpty()) { |
485 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 484 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
486 return; | 485 return; |
487 } | 486 } |
488 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId); | 487 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId); |
489 if (!remoteId) { | 488 if (!remoteId) { |
490 *errorString = "Invalid call frame id"; | 489 *errorString = "Invalid call frame id"; |
491 return; | 490 return; |
492 } | 491 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 bool V8DebuggerAgentImpl::isTopCallFrameBlackboxed() | 525 bool V8DebuggerAgentImpl::isTopCallFrameBlackboxed() |
527 { | 526 { |
528 ASSERT(enabled()); | 527 ASSERT(enabled()); |
529 return isCallFrameWithUnknownScriptOrBlackboxed(debugger().callFrameNoScopes
(0).get()); | 528 return isCallFrameWithUnknownScriptOrBlackboxed(debugger().callFrameNoScopes
(0).get()); |
530 } | 529 } |
531 | 530 |
532 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCal
lFrame* frame) | 531 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCal
lFrame* frame) |
533 { | 532 { |
534 if (!frame) | 533 if (!frame) |
535 return true; | 534 return true; |
536 ScriptsMap::iterator it = m_scripts.find(String::number(frame->sourceID())); | 535 ScriptsMap::iterator it = m_scripts.find(String16::number(frame->sourceID())
); |
537 if (it == m_scripts.end()) { | 536 if (it == m_scripts.end()) { |
538 // Unknown scripts are blackboxed. | 537 // Unknown scripts are blackboxed. |
539 return true; | 538 return true; |
540 } | 539 } |
541 auto itBlackboxedPositions = m_blackboxedPositions.find(String::number(frame
->sourceID())); | 540 auto itBlackboxedPositions = m_blackboxedPositions.find(String16::number(fra
me->sourceID())); |
542 if (itBlackboxedPositions == m_blackboxedPositions.end()) | 541 if (itBlackboxedPositions == m_blackboxedPositions.end()) |
543 return false; | 542 return false; |
544 | 543 |
545 protocol::Vector<std::pair<int, int>>* ranges = itBlackboxedPositions->secon
d; | 544 protocol::Vector<std::pair<int, int>>* ranges = itBlackboxedPositions->secon
d; |
546 auto itRange = std::lower_bound(ranges->begin(), ranges->end(), std::make_pa
ir(frame->line(), frame->column()), positionComparator); | 545 auto itRange = std::lower_bound(ranges->begin(), ranges->end(), std::make_pa
ir(frame->line(), frame->column()), positionComparator); |
547 // Ranges array contains positions in script where blackbox state is changed
. | 546 // Ranges array contains positions in script where blackbox state is changed
. |
548 // [(0,0) ... ranges[0]) isn't blackboxed, [ranges[0] ... ranges[1]) is blac
kboxed... | 547 // [(0,0) ... ranges[0]) isn't blackboxed, [ranges[0] ... ranges[1]) is blac
kboxed... |
549 return std::distance(ranges->begin(), itRange) % 2; | 548 return std::distance(ranges->begin(), itRange) % 2; |
550 } | 549 } |
551 | 550 |
(...skipping 23 matching lines...) Expand all Loading... |
575 if (m_skippedStepFrameCount >= maxSkipStepFrameCount) | 574 if (m_skippedStepFrameCount >= maxSkipStepFrameCount) |
576 return RequestStepOut; | 575 return RequestStepOut; |
577 | 576 |
578 if (!m_skippedStepFrameCount) | 577 if (!m_skippedStepFrameCount) |
579 m_recursionLevelForStepFrame = 1; | 578 m_recursionLevelForStepFrame = 1; |
580 | 579 |
581 ++m_skippedStepFrameCount; | 580 ++m_skippedStepFrameCount; |
582 return RequestStepFrame; | 581 return RequestStepFrame; |
583 } | 582 } |
584 | 583 |
585 PassOwnPtr<protocol::Debugger::Location> V8DebuggerAgentImpl::resolveBreakpoint(
const String& breakpointId, const String& scriptId, const ScriptBreakpoint& brea
kpoint, BreakpointSource source) | 584 PassOwnPtr<protocol::Debugger::Location> V8DebuggerAgentImpl::resolveBreakpoint(
const String16& breakpointId, const String16& scriptId, const ScriptBreakpoint&
breakpoint, BreakpointSource source) |
586 { | 585 { |
587 ASSERT(enabled()); | 586 ASSERT(enabled()); |
588 // FIXME: remove these checks once crbug.com/520702 is resolved. | 587 // FIXME: remove these checks once crbug.com/520702 is resolved. |
589 RELEASE_ASSERT(!breakpointId.isEmpty()); | 588 RELEASE_ASSERT(!breakpointId.isEmpty()); |
590 RELEASE_ASSERT(!scriptId.isEmpty()); | 589 RELEASE_ASSERT(!scriptId.isEmpty()); |
591 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); | 590 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); |
592 if (scriptIterator == m_scripts.end()) | 591 if (scriptIterator == m_scripts.end()) |
593 return nullptr; | 592 return nullptr; |
594 V8DebuggerScript* script = scriptIterator->second; | 593 V8DebuggerScript* script = scriptIterator->second; |
595 if (breakpoint.lineNumber < script->startLine() || script->endLine() < break
point.lineNumber) | 594 if (breakpoint.lineNumber < script->startLine() || script->endLine() < break
point.lineNumber) |
596 return nullptr; | 595 return nullptr; |
597 | 596 |
598 int actualLineNumber; | 597 int actualLineNumber; |
599 int actualColumnNumber; | 598 int actualColumnNumber; |
600 String debuggerBreakpointId = debugger().setBreakpoint(scriptId, breakpoint,
&actualLineNumber, &actualColumnNumber, false); | 599 String16 debuggerBreakpointId = debugger().setBreakpoint(scriptId, breakpoin
t, &actualLineNumber, &actualColumnNumber, false); |
601 if (debuggerBreakpointId.isEmpty()) | 600 if (debuggerBreakpointId.isEmpty()) |
602 return nullptr; | 601 return nullptr; |
603 | 602 |
604 m_serverBreakpoints.set(debuggerBreakpointId, std::make_pair(breakpointId, s
ource)); | 603 m_serverBreakpoints.set(debuggerBreakpointId, std::make_pair(breakpointId, s
ource)); |
605 RELEASE_ASSERT(!breakpointId.isEmpty()); | 604 RELEASE_ASSERT(!breakpointId.isEmpty()); |
606 if (!m_breakpointIdToDebuggerBreakpointIds.contains(breakpointId)) | 605 if (!m_breakpointIdToDebuggerBreakpointIds.contains(breakpointId)) |
607 m_breakpointIdToDebuggerBreakpointIds.set(breakpointId, protocol::Vector
<String>()); | 606 m_breakpointIdToDebuggerBreakpointIds.set(breakpointId, protocol::Vector
<String16>()); |
608 | 607 |
609 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat
or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); | 608 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat
or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); |
610 debuggerBreakpointIdsIterator->second->append(debuggerBreakpointId); | 609 debuggerBreakpointIdsIterator->second->append(debuggerBreakpointId); |
611 | 610 |
612 OwnPtr<protocol::Debugger::Location> location = protocol::Debugger::Location
::create() | 611 OwnPtr<protocol::Debugger::Location> location = protocol::Debugger::Location
::create() |
613 .setScriptId(scriptId) | 612 .setScriptId(scriptId) |
614 .setLineNumber(actualLineNumber) | 613 .setLineNumber(actualLineNumber) |
615 .setColumnNumber(actualColumnNumber).build(); | 614 .setColumnNumber(actualColumnNumber).build(); |
616 return location.release(); | 615 return location.release(); |
617 } | 616 } |
618 | 617 |
619 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String& scri
ptId, const String& query, | 618 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc
riptId, const String16& query, |
620 const Maybe<bool>& optionalCaseSensitive, | 619 const Maybe<bool>& optionalCaseSensitive, |
621 const Maybe<bool>& optionalIsRegex, | 620 const Maybe<bool>& optionalIsRegex, |
622 OwnPtr<Array<protocol::Debugger::SearchMatch>>* results) | 621 OwnPtr<Array<protocol::Debugger::SearchMatch>>* results) |
623 { | 622 { |
624 ScriptsMap::iterator it = m_scripts.find(scriptId); | 623 ScriptsMap::iterator it = m_scripts.find(scriptId); |
625 if (it != m_scripts.end()) | 624 if (it != m_scripts.end()) |
626 *results = V8ContentSearchUtil::searchInTextByLines(m_debugger, it->seco
nd->source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fro
mMaybe(false)); | 625 *results = V8ContentSearchUtil::searchInTextByLines(m_debugger, it->seco
nd->source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fro
mMaybe(false)); |
627 else | 626 else |
628 *error = "No script for id: " + scriptId; | 627 *error = String16("No script for id: " + scriptId); |
629 } | 628 } |
630 | 629 |
631 void V8DebuggerAgentImpl::setScriptSource(ErrorString* error, | 630 void V8DebuggerAgentImpl::setScriptSource(ErrorString* error, |
632 const String& scriptId, | 631 const String16& scriptId, |
633 const String& newContent, | 632 const String16& newContent, |
634 const Maybe<bool>& preview, | 633 const Maybe<bool>& preview, |
635 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, | 634 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, |
636 Maybe<bool>* stackChanged, | 635 Maybe<bool>* stackChanged, |
637 Maybe<StackTrace>* asyncStackTrace, | 636 Maybe<StackTrace>* asyncStackTrace, |
638 Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError) | 637 Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError) |
639 { | 638 { |
640 if (!checkEnabled(error)) | 639 if (!checkEnabled(error)) |
641 return; | 640 return; |
642 if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(fals
e), error, optOutCompileError, &m_currentCallStack, stackChanged)) | 641 if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(fals
e), error, optOutCompileError, &m_currentCallStack, stackChanged)) |
643 return; | 642 return; |
644 | 643 |
645 *newCallFrames = currentCallFrames(); | 644 *newCallFrames = currentCallFrames(); |
646 *asyncStackTrace = currentAsyncStackTrace(); | 645 *asyncStackTrace = currentAsyncStackTrace(); |
647 | 646 |
648 ScriptsMap::iterator it = m_scripts.find(scriptId); | 647 ScriptsMap::iterator it = m_scripts.find(scriptId); |
649 if (it == m_scripts.end()) | 648 if (it == m_scripts.end()) |
650 return; | 649 return; |
651 it->second->setSource(newContent); | 650 it->second->setSource(newContent); |
652 } | 651 } |
653 | 652 |
654 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, | 653 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, |
655 const String& callFrameId, | 654 const String16& callFrameId, |
656 OwnPtr<Array<CallFrame>>* newCallFrames, | 655 OwnPtr<Array<CallFrame>>* newCallFrames, |
657 Maybe<StackTrace>* asyncStackTrace) | 656 Maybe<StackTrace>* asyncStackTrace) |
658 { | 657 { |
659 if (!isPaused() || m_currentCallStack.IsEmpty()) { | 658 if (!isPaused() || m_currentCallStack.IsEmpty()) { |
660 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 659 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
661 return; | 660 return; |
662 } | 661 } |
663 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId); | 662 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId); |
664 if (!remoteId) { | 663 if (!remoteId) { |
665 *errorString = "Invalid call frame id"; | 664 *errorString = "Invalid call frame id"; |
666 return; | 665 return; |
667 } | 666 } |
668 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); | 667 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); |
669 if (!injectedScript) { | 668 if (!injectedScript) { |
670 *errorString = "Inspected frame has gone"; | 669 *errorString = "Inspected frame has gone"; |
671 return; | 670 return; |
672 } | 671 } |
673 | 672 |
674 v8::HandleScope scope(m_isolate); | 673 v8::HandleScope scope(m_isolate); |
675 v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate); | 674 v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate); |
676 injectedScript->restartFrame(errorString, callStack, callFrameId); | 675 injectedScript->restartFrame(errorString, callStack, callFrameId); |
677 m_currentCallStack.Reset(m_isolate, debugger().currentCallFrames()); | 676 m_currentCallStack.Reset(m_isolate, debugger().currentCallFrames()); |
678 *newCallFrames = currentCallFrames(); | 677 *newCallFrames = currentCallFrames(); |
679 *asyncStackTrace = currentAsyncStackTrace(); | 678 *asyncStackTrace = currentAsyncStackTrace(); |
680 } | 679 } |
681 | 680 |
682 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String& scri
ptId, String* scriptSource) | 681 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc
riptId, String16* scriptSource) |
683 { | 682 { |
684 if (!checkEnabled(error)) | 683 if (!checkEnabled(error)) |
685 return; | 684 return; |
686 ScriptsMap::iterator it = m_scripts.find(scriptId); | 685 ScriptsMap::iterator it = m_scripts.find(scriptId); |
687 if (it == m_scripts.end()) { | 686 if (it == m_scripts.end()) { |
688 *error = "No script for id: " + scriptId; | 687 *error = "No script for id: " + scriptId; |
689 return; | 688 return; |
690 } | 689 } |
691 *scriptSource = it->second->source(); | 690 *scriptSource = it->second->source(); |
692 } | 691 } |
693 | 692 |
694 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str
ing& functionId, OwnPtr<FunctionDetails>* details) | 693 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str
ing16& functionId, OwnPtr<FunctionDetails>* details) |
695 { | 694 { |
696 if (!checkEnabled(errorString)) | 695 if (!checkEnabled(errorString)) |
697 return; | 696 return; |
698 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionId); | 697 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionId); |
699 if (!remoteId) { | 698 if (!remoteId) { |
700 *errorString = "Invalid object id"; | 699 *errorString = "Invalid object id"; |
701 return; | 700 return; |
702 } | 701 } |
703 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); | 702 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); |
704 if (!injectedScript) { | 703 if (!injectedScript) { |
705 *errorString = "Function object id is obsolete"; | 704 *errorString = "Function object id is obsolete"; |
706 return; | 705 return; |
707 } | 706 } |
708 injectedScript->getFunctionDetails(errorString, functionId, details); | 707 injectedScript->getFunctionDetails(errorString, functionId, details); |
709 } | 708 } |
710 | 709 |
711 void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, co
nst String& objectId, OwnPtr<GeneratorObjectDetails>* details) | 710 void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, co
nst String16& objectId, OwnPtr<GeneratorObjectDetails>* details) |
712 { | 711 { |
713 if (!checkEnabled(errorString)) | 712 if (!checkEnabled(errorString)) |
714 return; | 713 return; |
715 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId); | 714 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId); |
716 if (!remoteId) { | 715 if (!remoteId) { |
717 *errorString = "Invalid object id"; | 716 *errorString = "Invalid object id"; |
718 return; | 717 return; |
719 } | 718 } |
720 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); | 719 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); |
721 if (!injectedScript) { | 720 if (!injectedScript) { |
722 *errorString = "Inspected frame has gone"; | 721 *errorString = "Inspected frame has gone"; |
723 return; | 722 return; |
724 } | 723 } |
725 injectedScript->getGeneratorObjectDetails(errorString, objectId, details); | 724 injectedScript->getGeneratorObjectDetails(errorString, objectId, details); |
726 } | 725 } |
727 | 726 |
728 void V8DebuggerAgentImpl::getCollectionEntries(ErrorString* errorString, const S
tring& objectId, OwnPtr<protocol::Array<CollectionEntry>>* entries) | 727 void V8DebuggerAgentImpl::getCollectionEntries(ErrorString* errorString, const S
tring16& objectId, OwnPtr<protocol::Array<CollectionEntry>>* entries) |
729 { | 728 { |
730 if (!checkEnabled(errorString)) | 729 if (!checkEnabled(errorString)) |
731 return; | 730 return; |
732 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId); | 731 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(objectId); |
733 if (!remoteId) { | 732 if (!remoteId) { |
734 *errorString = "Invalid object id"; | 733 *errorString = "Invalid object id"; |
735 return; | 734 return; |
736 } | 735 } |
737 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); | 736 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript
(remoteId.get()); |
738 if (!injectedScript) { | 737 if (!injectedScript) { |
739 *errorString = "Inspected frame has gone"; | 738 *errorString = "Inspected frame has gone"; |
740 return; | 739 return; |
741 } | 740 } |
742 injectedScript->getCollectionEntries(errorString, objectId, entries); | 741 injectedScript->getCollectionEntries(errorString, objectId, entries); |
743 } | 742 } |
744 | 743 |
745 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String& breakReason
, PassOwnPtr<protocol::DictionaryValue> data) | 744 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReas
on, PassOwnPtr<protocol::DictionaryValue> data) |
746 { | 745 { |
747 ASSERT(enabled()); | 746 ASSERT(enabled()); |
748 if (m_scheduledDebuggerStep == StepInto || m_javaScriptPauseScheduled || isP
aused()) | 747 if (m_scheduledDebuggerStep == StepInto || m_javaScriptPauseScheduled || isP
aused()) |
749 return; | 748 return; |
750 m_breakReason = breakReason; | 749 m_breakReason = breakReason; |
751 m_breakAuxData = data; | 750 m_breakAuxData = data; |
752 m_pausingOnNativeEvent = true; | 751 m_pausingOnNativeEvent = true; |
753 m_skipNextDebuggerStepOut = false; | 752 m_skipNextDebuggerStepOut = false; |
754 debugger().setPauseOnNextStatement(true); | 753 debugger().setPauseOnNextStatement(true); |
755 } | 754 } |
(...skipping 17 matching lines...) Expand all Loading... |
773 clearBreakDetails(); | 772 clearBreakDetails(); |
774 m_pausingOnNativeEvent = false; | 773 m_pausingOnNativeEvent = false; |
775 debugger().setPauseOnNextStatement(false); | 774 debugger().setPauseOnNextStatement(false); |
776 } | 775 } |
777 | 776 |
778 bool V8DebuggerAgentImpl::v8AsyncTaskEventsEnabled() const | 777 bool V8DebuggerAgentImpl::v8AsyncTaskEventsEnabled() const |
779 { | 778 { |
780 return trackingAsyncCalls(); | 779 return trackingAsyncCalls(); |
781 } | 780 } |
782 | 781 |
783 void V8DebuggerAgentImpl::didReceiveV8AsyncTaskEvent(v8::Local<v8::Context> cont
ext, const String& eventType, const String& eventName, int id) | 782 void V8DebuggerAgentImpl::didReceiveV8AsyncTaskEvent(v8::Local<v8::Context> cont
ext, const String16& eventType, const String16& eventName, int id) |
784 { | 783 { |
785 ASSERT(trackingAsyncCalls()); | 784 ASSERT(trackingAsyncCalls()); |
786 m_v8AsyncCallTracker->didReceiveV8AsyncTaskEvent(context, eventType, eventNa
me, id); | 785 m_v8AsyncCallTracker->didReceiveV8AsyncTaskEvent(context, eventType, eventNa
me, id); |
787 } | 786 } |
788 | 787 |
789 bool V8DebuggerAgentImpl::v8PromiseEventsEnabled() const | 788 bool V8DebuggerAgentImpl::v8PromiseEventsEnabled() const |
790 { | 789 { |
791 return m_promiseTracker->isEnabled(); | 790 return m_promiseTracker->isEnabled(); |
792 } | 791 } |
793 | 792 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 return; | 865 return; |
867 if (!trackingAsyncCalls()) { | 866 if (!trackingAsyncCalls()) { |
868 *errorString = "Can only perform operation if async call stacks are enab
led."; | 867 *errorString = "Can only perform operation if async call stacks are enab
led."; |
869 return; | 868 return; |
870 } | 869 } |
871 clearStepIntoAsync(); | 870 clearStepIntoAsync(); |
872 m_startingStepIntoAsync = true; | 871 m_startingStepIntoAsync = true; |
873 stepInto(errorString); | 872 stepInto(errorString); |
874 } | 873 } |
875 | 874 |
876 void V8DebuggerAgentImpl::setPauseOnExceptions(ErrorString* errorString, const S
tring& stringPauseState) | 875 void V8DebuggerAgentImpl::setPauseOnExceptions(ErrorString* errorString, const S
tring16& stringPauseState) |
877 { | 876 { |
878 if (!checkEnabled(errorString)) | 877 if (!checkEnabled(errorString)) |
879 return; | 878 return; |
880 V8DebuggerImpl::PauseOnExceptionsState pauseState; | 879 V8DebuggerImpl::PauseOnExceptionsState pauseState; |
881 if (stringPauseState == "none") { | 880 if (stringPauseState == "none") { |
882 pauseState = V8DebuggerImpl::DontPauseOnExceptions; | 881 pauseState = V8DebuggerImpl::DontPauseOnExceptions; |
883 } else if (stringPauseState == "all") { | 882 } else if (stringPauseState == "all") { |
884 pauseState = V8DebuggerImpl::PauseOnAllExceptions; | 883 pauseState = V8DebuggerImpl::PauseOnAllExceptions; |
885 } else if (stringPauseState == "uncaught") { | 884 } else if (stringPauseState == "uncaught") { |
886 pauseState = V8DebuggerImpl::PauseOnUncaughtExceptions; | 885 pauseState = V8DebuggerImpl::PauseOnUncaughtExceptions; |
887 } else { | 886 } else { |
888 *errorString = "Unknown pause on exceptions mode: " + stringPauseState; | 887 *errorString = "Unknown pause on exceptions mode: " + stringPauseState; |
889 return; | 888 return; |
890 } | 889 } |
891 setPauseOnExceptionsImpl(errorString, pauseState); | 890 setPauseOnExceptionsImpl(errorString, pauseState); |
892 } | 891 } |
893 | 892 |
894 void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(ErrorString* errorString, int
pauseState) | 893 void V8DebuggerAgentImpl::setPauseOnExceptionsImpl(ErrorString* errorString, int
pauseState) |
895 { | 894 { |
896 debugger().setPauseOnExceptionsState(static_cast<V8DebuggerImpl::PauseOnExce
ptionsState>(pauseState)); | 895 debugger().setPauseOnExceptionsState(static_cast<V8DebuggerImpl::PauseOnExce
ptionsState>(pauseState)); |
897 if (debugger().getPauseOnExceptionsState() != pauseState) | 896 if (debugger().getPauseOnExceptionsState() != pauseState) |
898 *errorString = "Internal error. Could not change pause on exceptions sta
te"; | 897 *errorString = "Internal error. Could not change pause on exceptions sta
te"; |
899 else | 898 else |
900 m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, pauseStat
e); | 899 m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, pauseStat
e); |
901 } | 900 } |
902 | 901 |
903 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, | 902 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, |
904 const String& callFrameId, | 903 const String16& callFrameId, |
905 const String& expression, | 904 const String16& expression, |
906 const Maybe<String>& objectGroup, | 905 const Maybe<String16>& objectGroup, |
907 const Maybe<bool>& includeCommandLineAPI, | 906 const Maybe<bool>& includeCommandLineAPI, |
908 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole, | 907 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole, |
909 const Maybe<bool>& returnByValue, | 908 const Maybe<bool>& returnByValue, |
910 const Maybe<bool>& generatePreview, | 909 const Maybe<bool>& generatePreview, |
911 OwnPtr<RemoteObject>* result, | 910 OwnPtr<RemoteObject>* result, |
912 Maybe<bool>* wasThrown, | 911 Maybe<bool>* wasThrown, |
913 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) | 912 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) |
914 { | 913 { |
915 if (!isPaused() || m_currentCallStack.IsEmpty()) { | 914 if (!isPaused() || m_currentCallStack.IsEmpty()) { |
916 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 915 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
(...skipping 12 matching lines...) Expand all Loading... |
929 | 928 |
930 v8::HandleScope scope(m_isolate); | 929 v8::HandleScope scope(m_isolate); |
931 v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate); | 930 v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate); |
932 | 931 |
933 IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteCon
sole.fromMaybe(false) ? m_debugger : nullptr); | 932 IgnoreExceptionsScope ignoreExceptionsScope(doNotPauseOnExceptionsAndMuteCon
sole.fromMaybe(false) ? m_debugger : nullptr); |
934 injectedScript->evaluateOnCallFrame(errorString, callStack, callFrameId, exp
ression, objectGroup.fromMaybe(""), includeCommandLineAPI.fromMaybe(false), retu
rnByValue.fromMaybe(false), generatePreview.fromMaybe(false), result, wasThrown,
exceptionDetails); | 933 injectedScript->evaluateOnCallFrame(errorString, callStack, callFrameId, exp
ression, objectGroup.fromMaybe(""), includeCommandLineAPI.fromMaybe(false), retu
rnByValue.fromMaybe(false), generatePreview.fromMaybe(false), result, wasThrown,
exceptionDetails); |
935 } | 934 } |
936 | 935 |
937 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, | 936 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, |
938 int scopeNumber, | 937 int scopeNumber, |
939 const String& variableName, | 938 const String16& variableName, |
940 PassOwnPtr<protocol::Runtime::CallArgument> newValue, | 939 PassOwnPtr<protocol::Runtime::CallArgument> newValue, |
941 const Maybe<String>& callFrameId, | 940 const Maybe<String16>& callFrameId, |
942 const Maybe<String>& functionObjectId) | 941 const Maybe<String16>& functionObjectId) |
943 { | 942 { |
944 if (!checkEnabled(errorString)) | 943 if (!checkEnabled(errorString)) |
945 return; | 944 return; |
946 InjectedScript* injectedScript = nullptr; | 945 InjectedScript* injectedScript = nullptr; |
947 if (callFrameId.isJust()) { | 946 if (callFrameId.isJust()) { |
948 if (!isPaused() || m_currentCallStack.IsEmpty()) { | 947 if (!isPaused() || m_currentCallStack.IsEmpty()) { |
949 *errorString = "Attempt to access callframe when debugger is not on
pause"; | 948 *errorString = "Attempt to access callframe when debugger is not on
pause"; |
950 return; | 949 return; |
951 } | 950 } |
952 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameI
d.fromJust()); | 951 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameI
d.fromJust()); |
(...skipping 14 matching lines...) Expand all Loading... |
967 } | 966 } |
968 injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.ge
t()); | 967 injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.ge
t()); |
969 if (!injectedScript) { | 968 if (!injectedScript) { |
970 *errorString = "Function object id cannot be resolved"; | 969 *errorString = "Function object id cannot be resolved"; |
971 return; | 970 return; |
972 } | 971 } |
973 } else { | 972 } else { |
974 *errorString = "Either call frame or function object must be specified"; | 973 *errorString = "Either call frame or function object must be specified"; |
975 return; | 974 return; |
976 } | 975 } |
977 String newValueString = protocol::toValue(newValue.get())->toJSONString(); | 976 String16 newValueString = protocol::toValue(newValue.get())->toJSONString(); |
978 v8::HandleScope scope(m_isolate); | 977 v8::HandleScope scope(m_isolate); |
979 v8::Local<v8::Object> currentCallStack = m_currentCallStack.Get(m_isolate); | 978 v8::Local<v8::Object> currentCallStack = m_currentCallStack.Get(m_isolate); |
980 injectedScript->setVariableValue(errorString, currentCallStack, callFrameId,
functionObjectId, scopeNumber, variableName, newValueString); | 979 injectedScript->setVariableValue(errorString, currentCallStack, callFrameId,
functionObjectId, scopeNumber, variableName, newValueString); |
981 } | 980 } |
982 | 981 |
983 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d
epth) | 982 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d
epth) |
984 { | 983 { |
985 if (!checkEnabled(errorString)) | 984 if (!checkEnabled(errorString)) |
986 return; | 985 return; |
987 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth); | 986 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth); |
(...skipping 11 matching lines...) Expand all Loading... |
999 } | 998 } |
1000 | 999 |
1001 void V8DebuggerAgentImpl::disablePromiseTracker(ErrorString* errorString) | 1000 void V8DebuggerAgentImpl::disablePromiseTracker(ErrorString* errorString) |
1002 { | 1001 { |
1003 if (!checkEnabled(errorString)) | 1002 if (!checkEnabled(errorString)) |
1004 return; | 1003 return; |
1005 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, false); | 1004 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, false); |
1006 m_promiseTracker->setEnabled(false, false); | 1005 m_promiseTracker->setEnabled(false, false); |
1007 } | 1006 } |
1008 | 1007 |
1009 void V8DebuggerAgentImpl::getPromiseById(ErrorString* errorString, int promiseId
, const Maybe<String>& objectGroup, OwnPtr<RemoteObject>* promise) | 1008 void V8DebuggerAgentImpl::getPromiseById(ErrorString* errorString, int promiseId
, const Maybe<String16>& objectGroup, OwnPtr<RemoteObject>* promise) |
1010 { | 1009 { |
1011 if (!checkEnabled(errorString)) | 1010 if (!checkEnabled(errorString)) |
1012 return; | 1011 return; |
1013 if (!m_promiseTracker->isEnabled()) { | 1012 if (!m_promiseTracker->isEnabled()) { |
1014 *errorString = "Promise tracking is disabled"; | 1013 *errorString = "Promise tracking is disabled"; |
1015 return; | 1014 return; |
1016 } | 1015 } |
1017 v8::HandleScope handles(m_isolate); | 1016 v8::HandleScope handles(m_isolate); |
1018 v8::Local<v8::Object> value = m_promiseTracker->promiseById(promiseId); | 1017 v8::Local<v8::Object> value = m_promiseTracker->promiseById(promiseId); |
1019 if (value.IsEmpty()) { | 1018 if (value.IsEmpty()) { |
1020 *errorString = "Promise with specified ID not found."; | 1019 *errorString = "Promise with specified ID not found."; |
1021 return; | 1020 return; |
1022 } | 1021 } |
1023 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(
value->CreationContext()); | 1022 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor(
value->CreationContext()); |
1024 *promise = injectedScript->wrapObject(value, objectGroup.fromMaybe("")); | 1023 *promise = injectedScript->wrapObject(value, objectGroup.fromMaybe("")); |
1025 } | 1024 } |
1026 | 1025 |
1027 void V8DebuggerAgentImpl::didUpdatePromise(const String& eventType, PassOwnPtr<p
rotocol::Debugger::PromiseDetails> promise) | 1026 void V8DebuggerAgentImpl::didUpdatePromise(const String16& eventType, PassOwnPtr
<protocol::Debugger::PromiseDetails> promise) |
1028 { | 1027 { |
1029 if (m_frontend) | 1028 if (m_frontend) |
1030 m_frontend->promiseUpdated(eventType, promise); | 1029 m_frontend->promiseUpdated(eventType, promise); |
1031 } | 1030 } |
1032 | 1031 |
1033 int V8DebuggerAgentImpl::traceAsyncOperationStarting(const String& description) | 1032 int V8DebuggerAgentImpl::traceAsyncOperationStarting(const String16& description
) |
1034 { | 1033 { |
1035 v8::HandleScope scope(m_isolate); | 1034 v8::HandleScope scope(m_isolate); |
1036 OwnPtr<V8StackTraceImpl> chain = V8StackTraceImpl::capture(this, V8StackTrac
e::maxCallStackSizeToCapture, description); | 1035 OwnPtr<V8StackTraceImpl> chain = V8StackTraceImpl::capture(this, V8StackTrac
e::maxCallStackSizeToCapture, description); |
1037 | 1036 |
1038 do { | 1037 do { |
1039 ++m_lastAsyncOperationId; | 1038 ++m_lastAsyncOperationId; |
1040 if (m_lastAsyncOperationId <= 0) | 1039 if (m_lastAsyncOperationId <= 0) |
1041 m_lastAsyncOperationId = 1; | 1040 m_lastAsyncOperationId = 1; |
1042 } while (m_asyncOperations.contains(m_lastAsyncOperationId)); | 1041 } while (m_asyncOperations.contains(m_lastAsyncOperationId)); |
1043 | 1042 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 *errorString = "Can only perform operation while tracking async call sta
cks."; | 1210 *errorString = "Can only perform operation while tracking async call sta
cks."; |
1212 return; | 1211 return; |
1213 } | 1212 } |
1214 if (operationId <= 0) { | 1213 if (operationId <= 0) { |
1215 *errorString = "Wrong async operation id."; | 1214 *errorString = "Wrong async operation id."; |
1216 return; | 1215 return; |
1217 } | 1216 } |
1218 m_asyncOperationBreakpoints.remove(operationId); | 1217 m_asyncOperationBreakpoints.remove(operationId); |
1219 } | 1218 } |
1220 | 1219 |
1221 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String&
scriptId, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> inPosi
tions) | 1220 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16
& scriptId, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> inPo
sitions) |
1222 { | 1221 { |
1223 if (!m_scripts.contains(scriptId)) { | 1222 if (!m_scripts.contains(scriptId)) { |
1224 *error = "No script with passed id."; | 1223 *error = "No script with passed id."; |
1225 return; | 1224 return; |
1226 } | 1225 } |
1227 | 1226 |
1228 if (!inPositions->length()) { | 1227 if (!inPositions->length()) { |
1229 m_blackboxedPositions.remove(scriptId); | 1228 m_blackboxedPositions.remove(scriptId); |
1230 return; | 1229 return; |
1231 } | 1230 } |
(...skipping 24 matching lines...) Expand all Loading... |
1256 m_blackboxedPositions.set(scriptId, positions); | 1255 m_blackboxedPositions.set(scriptId, positions); |
1257 } | 1256 } |
1258 | 1257 |
1259 void V8DebuggerAgentImpl::willExecuteScript(int scriptId) | 1258 void V8DebuggerAgentImpl::willExecuteScript(int scriptId) |
1260 { | 1259 { |
1261 changeJavaScriptRecursionLevel(+1); | 1260 changeJavaScriptRecursionLevel(+1); |
1262 // Fast return. | 1261 // Fast return. |
1263 if (m_scheduledDebuggerStep != StepInto) | 1262 if (m_scheduledDebuggerStep != StepInto) |
1264 return; | 1263 return; |
1265 // Skip unknown scripts (e.g. InjectedScript). | 1264 // Skip unknown scripts (e.g. InjectedScript). |
1266 if (!m_scripts.contains(String::number(scriptId))) | 1265 if (!m_scripts.contains(String16::number(scriptId))) |
1267 return; | 1266 return; |
1268 schedulePauseOnNextStatementIfSteppingInto(); | 1267 schedulePauseOnNextStatementIfSteppingInto(); |
1269 } | 1268 } |
1270 | 1269 |
1271 void V8DebuggerAgentImpl::didExecuteScript() | 1270 void V8DebuggerAgentImpl::didExecuteScript() |
1272 { | 1271 { |
1273 changeJavaScriptRecursionLevel(-1); | 1272 changeJavaScriptRecursionLevel(-1); |
1274 } | 1273 } |
1275 | 1274 |
1276 void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) | 1275 void V8DebuggerAgentImpl::changeJavaScriptRecursionLevel(int step) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 else if (!script.sourceMappingURL().isEmpty()) | 1353 else if (!script.sourceMappingURL().isEmpty()) |
1355 V8ContentSearchUtil::findSourceMapURL(script.source(), false, &isDepreca
tedSourceMappingURL); | 1354 V8ContentSearchUtil::findSourceMapURL(script.source(), false, &isDepreca
tedSourceMappingURL); |
1356 | 1355 |
1357 script.setHash(calculateHash(script.source())); | 1356 script.setHash(calculateHash(script.source())); |
1358 | 1357 |
1359 int executionContextId = script.executionContextId(); | 1358 int executionContextId = script.executionContextId(); |
1360 bool isContentScript = script.isContentScript(); | 1359 bool isContentScript = script.isContentScript(); |
1361 bool isInternalScript = script.isInternalScript(); | 1360 bool isInternalScript = script.isInternalScript(); |
1362 bool isLiveEdit = script.isLiveEdit(); | 1361 bool isLiveEdit = script.isLiveEdit(); |
1363 bool hasSourceURL = script.hasSourceURL(); | 1362 bool hasSourceURL = script.hasSourceURL(); |
1364 String scriptURL = script.sourceURL(); | 1363 String16 scriptURL = script.sourceURL(); |
1365 String sourceMapURL = script.sourceMappingURL(); | 1364 String16 sourceMapURL = script.sourceMappingURL(); |
1366 bool deprecatedCommentWasUsed = isDeprecatedSourceURL || isDeprecatedSourceM
appingURL; | 1365 bool deprecatedCommentWasUsed = isDeprecatedSourceURL || isDeprecatedSourceM
appingURL; |
1367 | 1366 |
1368 const Maybe<String>& sourceMapURLParam = sourceMapURL; | 1367 const Maybe<String16>& sourceMapURLParam = sourceMapURL; |
1369 const bool* isContentScriptParam = isContentScript ? &isContentScript : null
ptr; | 1368 const bool* isContentScriptParam = isContentScript ? &isContentScript : null
ptr; |
1370 const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : n
ullptr; | 1369 const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : n
ullptr; |
1371 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; | 1370 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; |
1372 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; | 1371 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; |
1373 const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &depr
ecatedCommentWasUsed : nullptr; | 1372 const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &depr
ecatedCommentWasUsed : nullptr; |
1374 if (parsedScript.success) | 1373 if (parsedScript.success) |
1375 m_frontend->scriptParsed(parsedScript.scriptId, scriptURL, script.startL
ine(), script.startColumn(), script.endLine(), script.endColumn(), executionCont
extId, script.hash(), isContentScriptParam, isInternalScriptParam, isLiveEditPar
am, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); | 1374 m_frontend->scriptParsed(parsedScript.scriptId, scriptURL, script.startL
ine(), script.startColumn(), script.endLine(), script.endColumn(), executionCont
extId, script.hash(), isContentScriptParam, isInternalScriptParam, isLiveEditPar
am, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); |
1376 else | 1375 else |
1377 m_frontend->scriptFailedToParse(parsedScript.scriptId, scriptURL, script
.startLine(), script.startColumn(), script.endLine(), script.endColumn(), execut
ionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, source
MapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); | 1376 m_frontend->scriptFailedToParse(parsedScript.scriptId, scriptURL, script
.startLine(), script.startColumn(), script.endLine(), script.endColumn(), execut
ionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, source
MapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); |
1378 | 1377 |
1379 m_scripts.set(parsedScript.scriptId, script); | 1378 m_scripts.set(parsedScript.scriptId, script); |
1380 | 1379 |
1381 if (scriptURL.isEmpty() || !parsedScript.success) | 1380 if (scriptURL.isEmpty() || !parsedScript.success) |
1382 return; | 1381 return; |
1383 | 1382 |
1384 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg
entState::javaScriptBreakpoints); | 1383 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg
entState::javaScriptBreakpoints); |
1385 if (!breakpointsCookie) | 1384 if (!breakpointsCookie) |
1386 return; | 1385 return; |
1387 | 1386 |
1388 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { | 1387 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { |
1389 auto cookie = breakpointsCookie->at(i); | 1388 auto cookie = breakpointsCookie->at(i); |
1390 protocol::DictionaryValue* breakpointObject = protocol::DictionaryValue:
:cast(cookie.second); | 1389 protocol::DictionaryValue* breakpointObject = protocol::DictionaryValue:
:cast(cookie.second); |
1391 bool isRegex; | 1390 bool isRegex; |
1392 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); | 1391 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); |
1393 String url; | 1392 String16 url; |
1394 breakpointObject->getString(DebuggerAgentState::url, &url); | 1393 breakpointObject->getString(DebuggerAgentState::url, &url); |
1395 if (!matches(m_debugger, scriptURL, url, isRegex)) | 1394 if (!matches(m_debugger, scriptURL, url, isRegex)) |
1396 continue; | 1395 continue; |
1397 ScriptBreakpoint breakpoint; | 1396 ScriptBreakpoint breakpoint; |
1398 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint.
lineNumber); | 1397 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint.
lineNumber); |
1399 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin
t.columnNumber); | 1398 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin
t.columnNumber); |
1400 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c
ondition); | 1399 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c
ondition); |
1401 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(cookie
.first, parsedScript.scriptId, breakpoint, UserBreakpointSource); | 1400 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(cookie
.first, parsedScript.scriptId, breakpoint, UserBreakpointSource); |
1402 if (location) | 1401 if (location) |
1403 m_frontend->breakpointResolved(cookie.first, location.release()); | 1402 m_frontend->breakpointResolved(cookie.first, location.release()); |
1404 } | 1403 } |
1405 } | 1404 } |
1406 | 1405 |
1407 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8
::Context> context, v8::Local<v8::Object> callFrames, v8::Local<v8::Value> excep
tion, const protocol::Vector<String>& hitBreakpoints, bool isPromiseRejection) | 1406 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8
::Context> context, v8::Local<v8::Object> callFrames, v8::Local<v8::Value> excep
tion, const protocol::Vector<String16>& hitBreakpoints, bool isPromiseRejection) |
1408 { | 1407 { |
1409 V8DebuggerAgentImpl::SkipPauseRequest result; | 1408 V8DebuggerAgentImpl::SkipPauseRequest result; |
1410 if (m_skipAllPauses) | 1409 if (m_skipAllPauses) |
1411 result = RequestContinue; | 1410 result = RequestContinue; |
1412 else if (!hitBreakpoints.isEmpty()) | 1411 else if (!hitBreakpoints.isEmpty()) |
1413 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i
n frameworks. | 1412 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i
n frameworks. |
1414 else if (!exception.IsEmpty()) | 1413 else if (!exception.IsEmpty()) |
1415 result = shouldSkipExceptionPause(); | 1414 result = shouldSkipExceptionPause(); |
1416 else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled ||
m_pausingOnNativeEvent) | 1415 else if (m_scheduledDebuggerStep != NoStep || m_javaScriptPauseScheduled ||
m_pausingOnNativeEvent) |
1417 result = shouldSkipStepPause(); | 1416 result = shouldSkipStepPause(); |
(...skipping 20 matching lines...) Expand all Loading... |
1438 auto obj = injectedScript->wrapObject(exception, V8DebuggerAgentImpl
::backtraceObjectGroup); | 1437 auto obj = injectedScript->wrapObject(exception, V8DebuggerAgentImpl
::backtraceObjectGroup); |
1439 m_breakAuxData = obj ? obj->serialize() : nullptr; | 1438 m_breakAuxData = obj ? obj->serialize() : nullptr; |
1440 // m_breakAuxData might be null after this. | 1439 // m_breakAuxData might be null after this. |
1441 } | 1440 } |
1442 } else if (m_pausingOnAsyncOperation) { | 1441 } else if (m_pausingOnAsyncOperation) { |
1443 m_breakReason = protocol::Debugger::Paused::ReasonEnum::AsyncOperation; | 1442 m_breakReason = protocol::Debugger::Paused::ReasonEnum::AsyncOperation; |
1444 m_breakAuxData = protocol::DictionaryValue::create(); | 1443 m_breakAuxData = protocol::DictionaryValue::create(); |
1445 m_breakAuxData->setNumber("operationId", m_currentAsyncOperationId); | 1444 m_breakAuxData->setNumber("operationId", m_currentAsyncOperationId); |
1446 } | 1445 } |
1447 | 1446 |
1448 OwnPtr<Array<String>> hitBreakpointIds = Array<String>::create(); | 1447 OwnPtr<Array<String16>> hitBreakpointIds = Array<String16>::create(); |
1449 | 1448 |
1450 for (const auto& point : hitBreakpoints) { | 1449 for (const auto& point : hitBreakpoints) { |
1451 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter
ator = m_serverBreakpoints.find(point); | 1450 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter
ator = m_serverBreakpoints.find(point); |
1452 if (breakpointIterator != m_serverBreakpoints.end()) { | 1451 if (breakpointIterator != m_serverBreakpoints.end()) { |
1453 const String& localId = breakpointIterator->second->first; | 1452 const String16& localId = breakpointIterator->second->first; |
1454 hitBreakpointIds->addItem(localId); | 1453 hitBreakpointIds->addItem(localId); |
1455 | 1454 |
1456 BreakpointSource source = breakpointIterator->second->second; | 1455 BreakpointSource source = breakpointIterator->second->second; |
1457 if (m_breakReason == protocol::Debugger::Paused::ReasonEnum::Other &
& source == DebugCommandBreakpointSource) | 1456 if (m_breakReason == protocol::Debugger::Paused::ReasonEnum::Other &
& source == DebugCommandBreakpointSource) |
1458 m_breakReason = protocol::Debugger::Paused::ReasonEnum::DebugCom
mand; | 1457 m_breakReason = protocol::Debugger::Paused::ReasonEnum::DebugCom
mand; |
1459 } | 1458 } |
1460 } | 1459 } |
1461 | 1460 |
1462 if (!m_asyncOperationNotifications.isEmpty()) | 1461 if (!m_asyncOperationNotifications.isEmpty()) |
1463 flushAsyncOperationEvents(nullptr); | 1462 flushAsyncOperationEvents(nullptr); |
(...skipping 20 matching lines...) Expand all Loading... |
1484 m_currentCallStack.Reset(); | 1483 m_currentCallStack.Reset(); |
1485 clearBreakDetails(); | 1484 clearBreakDetails(); |
1486 m_frontend->resumed(); | 1485 m_frontend->resumed(); |
1487 } | 1486 } |
1488 | 1487 |
1489 bool V8DebuggerAgentImpl::canBreakProgram() | 1488 bool V8DebuggerAgentImpl::canBreakProgram() |
1490 { | 1489 { |
1491 return debugger().canBreakProgram(); | 1490 return debugger().canBreakProgram(); |
1492 } | 1491 } |
1493 | 1492 |
1494 void V8DebuggerAgentImpl::breakProgram(const String& breakReason, PassOwnPtr<pro
tocol::DictionaryValue> data) | 1493 void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, PassOwnPtr<p
rotocol::DictionaryValue> data) |
1495 { | 1494 { |
1496 ASSERT(enabled()); | 1495 ASSERT(enabled()); |
1497 if (m_skipAllPauses || !m_pausedContext.IsEmpty() || isCallStackEmptyOrBlack
boxed()) | 1496 if (m_skipAllPauses || !m_pausedContext.IsEmpty() || isCallStackEmptyOrBlack
boxed()) |
1498 return; | 1497 return; |
1499 m_breakReason = breakReason; | 1498 m_breakReason = breakReason; |
1500 m_breakAuxData = data; | 1499 m_breakAuxData = data; |
1501 m_scheduledDebuggerStep = NoStep; | 1500 m_scheduledDebuggerStep = NoStep; |
1502 m_steppingFromFramework = false; | 1501 m_steppingFromFramework = false; |
1503 m_pausingOnNativeEvent = false; | 1502 m_pausingOnNativeEvent = false; |
1504 clearStepIntoAsync(); | 1503 clearStepIntoAsync(); |
1505 debugger().breakProgram(); | 1504 debugger().breakProgram(); |
1506 } | 1505 } |
1507 | 1506 |
1508 void V8DebuggerAgentImpl::breakProgramOnException(const String& breakReason, Pas
sOwnPtr<protocol::DictionaryValue> data) | 1507 void V8DebuggerAgentImpl::breakProgramOnException(const String16& breakReason, P
assOwnPtr<protocol::DictionaryValue> data) |
1509 { | 1508 { |
1510 if (m_debugger->getPauseOnExceptionsState() == V8DebuggerImpl::DontPauseOnEx
ceptions) | 1509 if (m_debugger->getPauseOnExceptionsState() == V8DebuggerImpl::DontPauseOnEx
ceptions) |
1511 return; | 1510 return; |
1512 breakProgram(breakReason, data); | 1511 breakProgram(breakReason, data); |
1513 } | 1512 } |
1514 | 1513 |
1515 void V8DebuggerAgentImpl::clearStepIntoAsync() | 1514 void V8DebuggerAgentImpl::clearStepIntoAsync() |
1516 { | 1515 { |
1517 m_startingStepIntoAsync = false; | 1516 m_startingStepIntoAsync = false; |
1518 m_pausingOnAsyncOperation = false; | 1517 m_pausingOnAsyncOperation = false; |
1519 m_pausingAsyncOperations.clear(); | 1518 m_pausingAsyncOperations.clear(); |
1520 } | 1519 } |
1521 | 1520 |
1522 bool V8DebuggerAgentImpl::assertPaused(ErrorString* errorString) | 1521 bool V8DebuggerAgentImpl::assertPaused(ErrorString* errorString) |
1523 { | 1522 { |
1524 if (m_pausedContext.IsEmpty()) { | 1523 if (m_pausedContext.IsEmpty()) { |
1525 *errorString = "Can only perform operation while paused."; | 1524 *errorString = "Can only perform operation while paused."; |
1526 return false; | 1525 return false; |
1527 } | 1526 } |
1528 return true; | 1527 return true; |
1529 } | 1528 } |
1530 | 1529 |
1531 void V8DebuggerAgentImpl::clearBreakDetails() | 1530 void V8DebuggerAgentImpl::clearBreakDetails() |
1532 { | 1531 { |
1533 m_breakReason = protocol::Debugger::Paused::ReasonEnum::Other; | 1532 m_breakReason = protocol::Debugger::Paused::ReasonEnum::Other; |
1534 m_breakAuxData = nullptr; | 1533 m_breakAuxData = nullptr; |
1535 } | 1534 } |
1536 | 1535 |
1537 void V8DebuggerAgentImpl::setBreakpointAt(const String& scriptId, int lineNumber
, int columnNumber, BreakpointSource source, const String& condition) | 1536 void V8DebuggerAgentImpl::setBreakpointAt(const String16& scriptId, int lineNumb
er, int columnNumber, BreakpointSource source, const String16& condition) |
1538 { | 1537 { |
1539 String breakpointId = generateBreakpointId(scriptId, lineNumber, columnNumbe
r, source); | 1538 String16 breakpointId = generateBreakpointId(scriptId, lineNumber, columnNum
ber, source); |
1540 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); | 1539 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); |
1541 resolveBreakpoint(breakpointId, scriptId, breakpoint, source); | 1540 resolveBreakpoint(breakpointId, scriptId, breakpoint, source); |
1542 } | 1541 } |
1543 | 1542 |
1544 void V8DebuggerAgentImpl::removeBreakpointAt(const String& scriptId, int lineNum
ber, int columnNumber, BreakpointSource source) | 1543 void V8DebuggerAgentImpl::removeBreakpointAt(const String16& scriptId, int lineN
umber, int columnNumber, BreakpointSource source) |
1545 { | 1544 { |
1546 removeBreakpoint(generateBreakpointId(scriptId, lineNumber, columnNumber, so
urce)); | 1545 removeBreakpoint(generateBreakpointId(scriptId, lineNumber, columnNumber, so
urce)); |
1547 } | 1546 } |
1548 | 1547 |
1549 void V8DebuggerAgentImpl::reset() | 1548 void V8DebuggerAgentImpl::reset() |
1550 { | 1549 { |
1551 m_scheduledDebuggerStep = NoStep; | 1550 m_scheduledDebuggerStep = NoStep; |
1552 m_scripts.clear(); | 1551 m_scripts.clear(); |
1553 m_blackboxedPositions.clear(); | 1552 m_blackboxedPositions.clear(); |
1554 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1553 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1555 resetAsyncCallTracker(); | 1554 resetAsyncCallTracker(); |
1556 m_promiseTracker->clear(); | 1555 m_promiseTracker->clear(); |
1557 if (m_frontend) | 1556 if (m_frontend) |
1558 m_frontend->globalObjectCleared(); | 1557 m_frontend->globalObjectCleared(); |
1559 } | 1558 } |
1560 | 1559 |
1561 } // namespace blink | 1560 } // namespace blink |
OLD | NEW |