| 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/Values.h" | 7 #include "platform/inspector_protocol/Values.h" |
| 8 #include "platform/v8_inspector/AsyncCallChain.h" | 8 #include "platform/v8_inspector/AsyncCallChain.h" |
| 9 #include "platform/v8_inspector/IgnoreExceptionsScope.h" | 9 #include "platform/v8_inspector/IgnoreExceptionsScope.h" |
| 10 #include "platform/v8_inspector/InjectedScript.h" | 10 #include "platform/v8_inspector/InjectedScript.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 using blink::protocol::Runtime::RemoteObject; | 42 using blink::protocol::Runtime::RemoteObject; |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 namespace DebuggerAgentState { | 46 namespace DebuggerAgentState { |
| 47 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; | 47 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; |
| 48 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; | 48 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; |
| 49 static const char asyncCallStackDepth[] = "asyncCallStackDepth"; | 49 static const char asyncCallStackDepth[] = "asyncCallStackDepth"; |
| 50 static const char promiseTrackerEnabled[] = "promiseTrackerEnabled"; | 50 static const char promiseTrackerEnabled[] = "promiseTrackerEnabled"; |
| 51 static const char promiseTrackerCaptureStacks[] = "promiseTrackerCaptureStacks"; | 51 static const char promiseTrackerCaptureStacks[] = "promiseTrackerCaptureStacks"; |
| 52 static const char blackboxPatterns[] = "blackboxPatterns"; |
| 53 static const char blackboxHashes[] = "blackboxHashes"; |
| 52 | 54 |
| 53 // Breakpoint properties. | 55 // Breakpoint properties. |
| 54 static const char url[] = "url"; | 56 static const char url[] = "url"; |
| 55 static const char isRegex[] = "isRegex"; | 57 static const char isRegex[] = "isRegex"; |
| 56 static const char lineNumber[] = "lineNumber"; | 58 static const char lineNumber[] = "lineNumber"; |
| 57 static const char columnNumber[] = "columnNumber"; | 59 static const char columnNumber[] = "columnNumber"; |
| 58 static const char condition[] = "condition"; | 60 static const char condition[] = "condition"; |
| 59 static const char skipAllPauses[] = "skipAllPauses"; | 61 static const char skipAllPauses[] = "skipAllPauses"; |
| 60 | 62 |
| 63 // Blackbox hash object properties. |
| 64 static const char hashValue[] = "hashValue"; |
| 65 static const char hashPositions[] = "hashPositions"; |
| 66 |
| 61 } // namespace DebuggerAgentState; | 67 } // namespace DebuggerAgentState; |
| 62 | 68 |
| 63 static const int maxSkipStepFrameCount = 128; | 69 static const int maxSkipStepFrameCount = 128; |
| 64 | 70 |
| 65 const char V8DebuggerAgent::backtraceObjectGroup[] = "backtrace"; | 71 const char V8DebuggerAgent::backtraceObjectGroup[] = "backtrace"; |
| 66 | 72 |
| 67 const int V8DebuggerAgent::unknownAsyncOperationId = 0; | 73 const int V8DebuggerAgent::unknownAsyncOperationId = 0; |
| 68 | 74 |
| 69 static String breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) | 75 static String breakpointIdSuffix(V8DebuggerAgentImpl::BreakpointSource source) |
| 70 { | 76 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 return V8JavaScriptCallFrame::unwrap(context, value); | 112 return V8JavaScriptCallFrame::unwrap(context, value); |
| 107 } | 113 } |
| 108 | 114 |
| 109 static bool positionComparator(const std::pair<int, int>& a, const std::pair<int
, int>& b) | 115 static bool positionComparator(const std::pair<int, int>& a, const std::pair<int
, int>& b) |
| 110 { | 116 { |
| 111 if (a.first != b.first) | 117 if (a.first != b.first) |
| 112 return a.first < b.first; | 118 return a.first < b.first; |
| 113 return a.second < b.second; | 119 return a.second < b.second; |
| 114 } | 120 } |
| 115 | 121 |
| 122 static bool parseBlackboxPositions(ErrorString* error, protocol::Array<protocol:
:Debugger::ScriptPosition>* inPositions, Vector<std::pair<int, int>>* outPositio
ns) |
| 123 { |
| 124 if (!inPositions) { |
| 125 Vector<std::pair<int, int>> blackboxed(1); |
| 126 outPositions->swap(blackboxed); |
| 127 return true; |
| 128 } |
| 129 Vector<std::pair<int, int>> positions(inPositions->length()); |
| 130 for (size_t i = 0; i < positions.size(); ++i) { |
| 131 protocol::Debugger::ScriptPosition* position = inPositions->get(i); |
| 132 if (position->getLine() < 0) { |
| 133 if (error) |
| 134 *error = "Position missing 'line' or 'line' < 0."; |
| 135 return false; |
| 136 } |
| 137 if (position->getColumn() < 0) { |
| 138 if (error) |
| 139 *error = "Position missing 'column' or 'column' < 0."; |
| 140 return false; |
| 141 } |
| 142 positions[i] = std::make_pair(position->getLine(), position->getColumn()
); |
| 143 } |
| 144 |
| 145 for (size_t i = 1; i < positions.size(); ++i) { |
| 146 if (positions[i - 1].first < positions[i].first) |
| 147 continue; |
| 148 if (positions[i - 1].first == positions[i].first && positions[i - 1].sec
ond < positions[i].second) |
| 149 continue; |
| 150 if (error) |
| 151 *error = "Input positions array is not sorted or contains duplicate
values."; |
| 152 return false; |
| 153 } |
| 154 |
| 155 outPositions->swap(positions); |
| 156 return true; |
| 157 } |
| 158 |
| 116 // Hash algorithm for substrings is described in "Über die Komplexität der Multi
plikation in | 159 // Hash algorithm for substrings is described in "Über die Komplexität der Multi
plikation in |
| 117 // eingeschränkten Branchingprogrammmodellen" by Woelfe. | 160 // eingeschränkten Branchingprogrammmodellen" by Woelfe. |
| 118 // http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECT
ION00832000000000000000 | 161 // http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECT
ION00832000000000000000 |
| 119 static String calculateHash(const String& str) | 162 static String calculateHash(const String& str) |
| 120 { | 163 { |
| 121 static uint64_t prime[] = { 0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35,
0x81ABE279 }; | 164 static uint64_t prime[] = { 0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35,
0x81ABE279 }; |
| 122 static uint64_t random[] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476,
0xC3D2E1F0 }; | 165 static uint64_t random[] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476,
0xC3D2E1F0 }; |
| 123 static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA1
1D, 0x8F462907 }; | 166 static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA1
1D, 0x8F462907 }; |
| 124 | 167 |
| 125 uint64_t hashes[] = { 0, 0, 0, 0, 0 }; | 168 uint64_t hashes[] = { 0, 0, 0, 0, 0 }; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::Dict
ionaryValue::create()); | 291 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::Dict
ionaryValue::create()); |
| 249 m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImp
l::DontPauseOnExceptions); | 292 m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImp
l::DontPauseOnExceptions); |
| 250 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, 0); | 293 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, 0); |
| 251 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, false); | 294 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, false); |
| 252 m_state->setBoolean(DebuggerAgentState::promiseTrackerCaptureStacks, false); | 295 m_state->setBoolean(DebuggerAgentState::promiseTrackerCaptureStacks, false); |
| 253 | 296 |
| 254 debugger().removeAgent(m_contextGroupId); | 297 debugger().removeAgent(m_contextGroupId); |
| 255 m_pausedContext.Reset(); | 298 m_pausedContext.Reset(); |
| 256 m_currentCallStack.Reset(); | 299 m_currentCallStack.Reset(); |
| 257 m_scripts.clear(); | 300 m_scripts.clear(); |
| 258 m_blackboxedPositions.clear(); | 301 m_loadedScriptHashes.clear(); |
| 302 |
| 303 m_hashToBlackboxPositions.clear(); |
| 304 m_blackboxPattern = String(); |
| 305 |
| 259 m_breakpointIdToDebuggerBreakpointIds.clear(); | 306 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 260 internalSetAsyncCallStackDepth(0); | 307 internalSetAsyncCallStackDepth(0); |
| 261 m_promiseTracker->setEnabled(false, false); | 308 m_promiseTracker->setEnabled(false, false); |
| 262 m_continueToLocationBreakpointId = String(); | 309 m_continueToLocationBreakpointId = String(); |
| 263 clearBreakDetails(); | 310 clearBreakDetails(); |
| 264 m_scheduledDebuggerStep = NoStep; | 311 m_scheduledDebuggerStep = NoStep; |
| 265 m_skipNextDebuggerStepOut = false; | 312 m_skipNextDebuggerStepOut = false; |
| 266 m_javaScriptPauseScheduled = false; | 313 m_javaScriptPauseScheduled = false; |
| 267 m_steppingFromFramework = false; | 314 m_steppingFromFramework = false; |
| 268 m_pausingOnNativeEvent = false; | 315 m_pausingOnNativeEvent = false; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 m_state->getNumber(DebuggerAgentState::pauseOnExceptionsState, &pauseState); | 356 m_state->getNumber(DebuggerAgentState::pauseOnExceptionsState, &pauseState); |
| 310 setPauseOnExceptionsImpl(&error, pauseState); | 357 setPauseOnExceptionsImpl(&error, pauseState); |
| 311 | 358 |
| 312 m_skipAllPauses = m_state->booleanProperty(DebuggerAgentState::skipAllPauses
, false); | 359 m_skipAllPauses = m_state->booleanProperty(DebuggerAgentState::skipAllPauses
, false); |
| 313 | 360 |
| 314 int asyncCallStackDepth = 0; | 361 int asyncCallStackDepth = 0; |
| 315 m_state->getNumber(DebuggerAgentState::asyncCallStackDepth, &asyncCallStackD
epth); | 362 m_state->getNumber(DebuggerAgentState::asyncCallStackDepth, &asyncCallStackD
epth); |
| 316 internalSetAsyncCallStackDepth(asyncCallStackDepth); | 363 internalSetAsyncCallStackDepth(asyncCallStackDepth); |
| 317 | 364 |
| 318 m_promiseTracker->setEnabled(m_state->booleanProperty(DebuggerAgentState::pr
omiseTrackerEnabled, false), m_state->booleanProperty(DebuggerAgentState::promis
eTrackerCaptureStacks, false)); | 365 m_promiseTracker->setEnabled(m_state->booleanProperty(DebuggerAgentState::pr
omiseTrackerEnabled, false), m_state->booleanProperty(DebuggerAgentState::promis
eTrackerCaptureStacks, false)); |
| 366 |
| 367 restoreBlackboxState(); |
| 368 } |
| 369 |
| 370 void V8DebuggerAgentImpl::restoreBlackboxState() |
| 371 { |
| 372 String error; |
| 373 protocol::ErrorSupport errors; |
| 374 |
| 375 protocol::ListValue* savedPatterns = m_state->getArray(DebuggerAgentState::b
lackboxPatterns); |
| 376 if (savedPatterns) { |
| 377 OwnPtr<protocol::Array<protocol::Debugger::BlackboxPattern>> patterns =
protocol::Array<protocol::Debugger::BlackboxPattern>::parse(savedPatterns, &erro
rs); |
| 378 ASSERT(!errors.hasErrors()); |
| 379 setBlackboxPatterns(&error, patterns.release()); |
| 380 ASSERT(!error.length()); |
| 381 } |
| 382 |
| 383 protocol::ListValue* savedHashes = m_state->getArray(DebuggerAgentState::bla
ckboxHashes); |
| 384 if (!savedHashes) |
| 385 return; |
| 386 for (size_t i = 0; i < savedHashes->length(); ++i) { |
| 387 protocol::DictionaryValue* savedHash = protocol::DictionaryValue::cast(s
avedHashes->get(i)); |
| 388 |
| 389 String hash; |
| 390 OwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> positions; |
| 391 |
| 392 bool hadError = savedHash->getString(DebuggerAgentState::hashValue, &has
h); |
| 393 ASSERT_UNUSED(hadError, !hadError); |
| 394 positions = protocol::Array<protocol::Debugger::ScriptPosition>::parse(s
avedHash->getArray(DebuggerAgentState::hashPositions), &errors); |
| 395 ASSERT(!errors.hasErrors()); |
| 396 setBlackboxRanges(&error, hash, positions.release()); |
| 397 ASSERT(!error.length()); |
| 398 } |
| 319 } | 399 } |
| 320 | 400 |
| 321 void V8DebuggerAgentImpl::setBreakpointsActive(ErrorString* errorString, bool ac
tive) | 401 void V8DebuggerAgentImpl::setBreakpointsActive(ErrorString* errorString, bool ac
tive) |
| 322 { | 402 { |
| 323 if (!checkEnabled(errorString)) | 403 if (!checkEnabled(errorString)) |
| 324 return; | 404 return; |
| 325 debugger().setBreakpointsActivated(active); | 405 debugger().setBreakpointsActivated(active); |
| 326 } | 406 } |
| 327 | 407 |
| 328 void V8DebuggerAgentImpl::setSkipAllPauses(ErrorString*, bool skipped) | 408 void V8DebuggerAgentImpl::setSkipAllPauses(ErrorString*, bool skipped) |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 { | 621 { |
| 542 ASSERT(enabled()); | 622 ASSERT(enabled()); |
| 543 return isCallFrameWithUnknownScriptOrBlackboxed(debugger().callFrameNoScopes
(0)); | 623 return isCallFrameWithUnknownScriptOrBlackboxed(debugger().callFrameNoScopes
(0)); |
| 544 } | 624 } |
| 545 | 625 |
| 546 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(PassRefPtr<Ja
vaScriptCallFrame> pFrame) | 626 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(PassRefPtr<Ja
vaScriptCallFrame> pFrame) |
| 547 { | 627 { |
| 548 RefPtr<JavaScriptCallFrame> frame = pFrame; | 628 RefPtr<JavaScriptCallFrame> frame = pFrame; |
| 549 if (!frame) | 629 if (!frame) |
| 550 return true; | 630 return true; |
| 551 ScriptsMap::iterator it = m_scripts.find(String::number(frame->sourceID())); | 631 String scriptId = String::number(frame->sourceID()); |
| 632 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 552 if (it == m_scripts.end()) { | 633 if (it == m_scripts.end()) { |
| 553 // Unknown scripts are blackboxed. | 634 // Unknown scripts are blackboxed. |
| 554 return true; | 635 return true; |
| 555 } | 636 } |
| 556 auto itBlackboxedPositions = m_blackboxedPositions.find(String::number(frame
->sourceID())); | 637 |
| 557 if (itBlackboxedPositions == m_blackboxedPositions.end()) | 638 Vector<std::pair<int, int>> emptyPositions; |
| 639 const Vector<std::pair<int, int>>* ranges = nullptr; |
| 640 |
| 641 V8DebuggerScript& script = it->value; |
| 642 auto itBlackboxHash = m_hashToBlackboxPositions.find(script.hash()); |
| 643 if (itBlackboxHash != m_hashToBlackboxPositions.end()) { |
| 644 ranges = &itBlackboxHash->value; |
| 645 } else { |
| 646 if (!m_blackboxPattern.isEmpty() && matches(m_debugger, script.sourceURL
(), m_blackboxPattern, true)) { |
| 647 Vector<std::pair<int, int>> positions(1); |
| 648 positions[0].first = 0; |
| 649 positions[0].second = 0; |
| 650 m_hashToBlackboxPositions.set(script.hash(), positions); |
| 651 return true; |
| 652 } |
| 558 return false; | 653 return false; |
| 654 } |
| 559 | 655 |
| 560 const Vector<std::pair<int, int>>& ranges = itBlackboxedPositions->value; | 656 auto itRange = std::lower_bound(ranges->begin(), ranges->end(), std::make_pa
ir(frame->line(), frame->column()), positionComparator); |
| 561 auto itRange = std::lower_bound(ranges.begin(), ranges.end(), std::make_pair
(frame->line(), frame->column()), positionComparator); | |
| 562 // Ranges array contains positions in script where blackbox state is changed
. | 657 // Ranges array contains positions in script where blackbox state is changed
. |
| 563 // [(0,0) ... ranges[0]) isn't blackboxed, [ranges[0] ... ranges[1]) is blac
kboxed... | 658 // [(0,0) ... ranges[0]) isn't blackboxed, [ranges[0] ... ranges[1]) is blac
kboxed... |
| 564 return std::distance(ranges.begin(), itRange) % 2; | 659 return std::distance(ranges->begin(), itRange) % 2; |
| 565 } | 660 } |
| 566 | 661 |
| 567 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::shouldSkipExceptionPa
use() | 662 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::shouldSkipExceptionPa
use() |
| 568 { | 663 { |
| 569 if (m_steppingFromFramework) | 664 if (m_steppingFromFramework) |
| 570 return RequestNoSkip; | 665 return RequestNoSkip; |
| 571 if (isTopCallFrameBlackboxed()) | 666 if (isTopCallFrameBlackboxed()) |
| 572 return RequestContinue; | 667 return RequestContinue; |
| 573 return RequestNoSkip; | 668 return RequestNoSkip; |
| 574 } | 669 } |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 *errorString = "Can only perform operation while tracking async call sta
cks."; | 1367 *errorString = "Can only perform operation while tracking async call sta
cks."; |
| 1273 return; | 1368 return; |
| 1274 } | 1369 } |
| 1275 if (operationId <= 0) { | 1370 if (operationId <= 0) { |
| 1276 *errorString = "Wrong async operation id."; | 1371 *errorString = "Wrong async operation id."; |
| 1277 return; | 1372 return; |
| 1278 } | 1373 } |
| 1279 m_asyncOperationBreakpoints.remove(operationId); | 1374 m_asyncOperationBreakpoints.remove(operationId); |
| 1280 } | 1375 } |
| 1281 | 1376 |
| 1282 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String&
scriptId, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> inPosi
tions) | 1377 void V8DebuggerAgentImpl::setBlackboxRanges(ErrorString* error, const String& ha
sh, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> inPositions) |
| 1283 { | 1378 { |
| 1284 ScriptsMap::iterator it = m_scripts.find(scriptId); | 1379 if (!m_loadedScriptHashes.contains(hash)) { |
| 1285 if (it == m_scripts.end()) { | 1380 *error = "No script with passed hash."; |
| 1286 *error = "No script with passed id."; | |
| 1287 return; | 1381 return; |
| 1288 } | 1382 } |
| 1289 | 1383 |
| 1290 if (!inPositions->length()) { | 1384 if (!inPositions->length()) { |
| 1291 m_blackboxedPositions.remove(scriptId); | 1385 m_hashToBlackboxPositions.remove(hash); |
| 1292 return; | 1386 return; |
| 1293 } | 1387 } |
| 1294 | 1388 |
| 1295 Vector<std::pair<int, int>> positions(inPositions->length()); | 1389 Vector<std::pair<int, int>> positions; |
| 1296 for (size_t i = 0; i < positions.size(); ++i) { | 1390 if (parseBlackboxPositions(error, inPositions.get(), &positions)) |
| 1297 protocol::Debugger::ScriptPosition* position = inPositions->get(i); | 1391 m_hashToBlackboxPositions.set(hash, positions); |
| 1298 if (position->getLine() < 0) { | 1392 |
| 1299 *error = "Position missing 'line' or 'line' < 0."; | 1393 if (!m_state->getArray(DebuggerAgentState::blackboxHashes)) |
| 1394 m_state->setArray(DebuggerAgentState::blackboxHashes, protocol::ListValu
e::create()); |
| 1395 protocol::ListValue* hashes = m_state->getArray(DebuggerAgentState::blackbox
Hashes); |
| 1396 OwnPtr<protocol::DictionaryValue> value = protocol::DictionaryValue::create(
); |
| 1397 value->setString(DebuggerAgentState::hashValue, hash); |
| 1398 value->setArray(DebuggerAgentState::hashPositions, inPositions->serialize())
; |
| 1399 hashes->pushValue(value.release()); |
| 1400 } |
| 1401 |
| 1402 void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* error, PassOwnPtr<pro
tocol::Array<protocol::Debugger::BlackboxPattern>> patterns) |
| 1403 { |
| 1404 HashSet<String> hashes; |
| 1405 String blackboxPattern; |
| 1406 |
| 1407 for (size_t i = 0; i < patterns->length(); ++i) { |
| 1408 protocol::Debugger::BlackboxPattern* pattern = patterns->get(i); |
| 1409 String type = pattern->getType(); |
| 1410 if (type == protocol::Debugger::BlackboxPatternTypeEnum::RegExp) { |
| 1411 blackboxPattern = blackboxPattern.isEmpty() ? pattern->getValue() :
(blackboxPattern + "|" + pattern->getValue()); |
| 1412 } else if (type== protocol::Debugger::BlackboxPatternTypeEnum::Hash) { |
| 1413 hashes.add(pattern->getValue()); |
| 1414 } else { |
| 1415 *error = "Unknown blackbox pattern type."; |
| 1300 return; | 1416 return; |
| 1301 } | 1417 } |
| 1302 if (position->getColumn() < 0) { | |
| 1303 *error = "Position missing 'column' or 'column' < 0."; | |
| 1304 return; | |
| 1305 } | |
| 1306 positions[i] = std::make_pair(position->getLine(), position->getColumn()
); | |
| 1307 } | 1418 } |
| 1308 | 1419 |
| 1309 for (size_t i = 1; i < positions.size(); ++i) { | 1420 m_state->setArray(DebuggerAgentState::blackboxPatterns, patterns->serialize(
)); |
| 1310 if (positions[i - 1].first < positions[i].first) | |
| 1311 continue; | |
| 1312 if (positions[i - 1].first == positions[i].first && positions[i - 1].sec
ond < positions[i].second) | |
| 1313 continue; | |
| 1314 *error = "Input positions array is not sorted or contains duplicate valu
es."; | |
| 1315 return; | |
| 1316 } | |
| 1317 | 1421 |
| 1318 m_blackboxedPositions.set(scriptId, positions); | 1422 Vector<std::pair<int, int>> positions(1); |
| 1423 for (auto& hash : hashes) |
| 1424 m_hashToBlackboxPositions.set(hash, positions); |
| 1425 m_blackboxPattern = blackboxPattern; |
| 1319 } | 1426 } |
| 1320 | 1427 |
| 1321 void V8DebuggerAgentImpl::willExecuteScript(int scriptId) | 1428 void V8DebuggerAgentImpl::willExecuteScript(int scriptId) |
| 1322 { | 1429 { |
| 1323 changeJavaScriptRecursionLevel(+1); | 1430 changeJavaScriptRecursionLevel(+1); |
| 1324 // Fast return. | 1431 // Fast return. |
| 1325 if (m_scheduledDebuggerStep != StepInto) | 1432 if (m_scheduledDebuggerStep != StepInto) |
| 1326 return; | 1433 return; |
| 1327 // Skip unknown scripts (e.g. InjectedScript). | 1434 // Skip unknown scripts (e.g. InjectedScript). |
| 1328 if (!m_scripts.contains(String::number(scriptId))) | 1435 if (!m_scripts.contains(String::number(scriptId))) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1468 const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : n
ullptr; | 1575 const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : n
ullptr; |
| 1469 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; | 1576 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; |
| 1470 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; | 1577 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; |
| 1471 const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &depr
ecatedCommentWasUsed : nullptr; | 1578 const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &depr
ecatedCommentWasUsed : nullptr; |
| 1472 if (parsedScript.success) | 1579 if (parsedScript.success) |
| 1473 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); | 1580 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); |
| 1474 else | 1581 else |
| 1475 m_frontend->scriptFailedToParse(parsedScript.scriptId, scriptURL, script
.startLine(), script.startColumn(), script.endLine(), script.endColumn(), execut
ionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, source
MapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); | 1582 m_frontend->scriptFailedToParse(parsedScript.scriptId, scriptURL, script
.startLine(), script.startColumn(), script.endLine(), script.endColumn(), execut
ionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, source
MapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); |
| 1476 | 1583 |
| 1477 m_scripts.set(parsedScript.scriptId, script); | 1584 m_scripts.set(parsedScript.scriptId, script); |
| 1585 m_loadedScriptHashes.add(script.hash()); |
| 1478 | 1586 |
| 1479 if (scriptURL.isEmpty() || !parsedScript.success) | 1587 if (scriptURL.isEmpty() || !parsedScript.success) |
| 1480 return; | 1588 return; |
| 1481 | 1589 |
| 1482 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg
entState::javaScriptBreakpoints); | 1590 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg
entState::javaScriptBreakpoints); |
| 1483 if (!breakpointsCookie) | 1591 if (!breakpointsCookie) |
| 1484 return; | 1592 return; |
| 1485 | 1593 |
| 1486 for (auto& cookie : *breakpointsCookie) { | 1594 for (auto& cookie : *breakpointsCookie) { |
| 1487 protocol::DictionaryValue* breakpointObject = protocol::DictionaryValue:
:cast(cookie.value.get()); | 1595 protocol::DictionaryValue* breakpointObject = protocol::DictionaryValue:
:cast(cookie.value.get()); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 | 1751 |
| 1644 void V8DebuggerAgentImpl::removeBreakpointAt(const String& scriptId, int lineNum
ber, int columnNumber, BreakpointSource source) | 1752 void V8DebuggerAgentImpl::removeBreakpointAt(const String& scriptId, int lineNum
ber, int columnNumber, BreakpointSource source) |
| 1645 { | 1753 { |
| 1646 removeBreakpoint(generateBreakpointId(scriptId, lineNumber, columnNumber, so
urce)); | 1754 removeBreakpoint(generateBreakpointId(scriptId, lineNumber, columnNumber, so
urce)); |
| 1647 } | 1755 } |
| 1648 | 1756 |
| 1649 void V8DebuggerAgentImpl::reset() | 1757 void V8DebuggerAgentImpl::reset() |
| 1650 { | 1758 { |
| 1651 m_scheduledDebuggerStep = NoStep; | 1759 m_scheduledDebuggerStep = NoStep; |
| 1652 m_scripts.clear(); | 1760 m_scripts.clear(); |
| 1653 m_blackboxedPositions.clear(); | 1761 m_loadedScriptHashes.clear(); |
| 1762 |
| 1763 m_hashToBlackboxPositions.clear(); |
| 1764 |
| 1654 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1765 m_breakpointIdToDebuggerBreakpointIds.clear(); |
| 1655 resetAsyncCallTracker(); | 1766 resetAsyncCallTracker(); |
| 1656 m_promiseTracker->clear(); | 1767 m_promiseTracker->clear(); |
| 1657 if (m_frontend) | 1768 if (m_frontend) |
| 1658 m_frontend->globalObjectCleared(); | 1769 m_frontend->globalObjectCleared(); |
| 1659 } | 1770 } |
| 1660 | 1771 |
| 1661 } // namespace blink | 1772 } // namespace blink |
| OLD | NEW |