OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 338 |
339 static bool matches(const String& url, const String& pattern, bool isRegex) | 339 static bool matches(const String& url, const String& pattern, bool isRegex) |
340 { | 340 { |
341 if (isRegex) { | 341 if (isRegex) { |
342 ScriptRegexp regex(pattern, TextCaseSensitive); | 342 ScriptRegexp regex(pattern, TextCaseSensitive); |
343 return regex.match(url) != -1; | 343 return regex.match(url) != -1; |
344 } | 344 } |
345 return url == pattern; | 345 return url == pattern; |
346 } | 346 } |
347 | 347 |
348 void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString* errorString, int li
neNumber, const String* const optionalURL, const String* const optionalURLRegex,
const int* const optionalColumnNumber, const String* const optionalCondition, B
reakpointId* outBreakpointId, RefPtr<Array<TypeBuilder::Debugger::Location> >& l
ocations) | 348 void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString* errorString, int li
neNumber, const String* const optionalURL, const String* const optionalURLRegex,
const int* const optionalColumnNumber, const String* const optionalCondition, B
reakpointId* outBreakpointId, RefPtr<Array<TypeBuilder::Debugger::Location>>& lo
cations) |
349 { | 349 { |
350 locations = Array<TypeBuilder::Debugger::Location>::create(); | 350 locations = Array<TypeBuilder::Debugger::Location>::create(); |
351 if (!optionalURL == !optionalURLRegex) { | 351 if (!optionalURL == !optionalURLRegex) { |
352 *errorString = "Either url or urlRegex must be specified."; | 352 *errorString = "Either url or urlRegex must be specified."; |
353 return; | 353 return; |
354 } | 354 } |
355 | 355 |
356 String url = optionalURL ? *optionalURL : *optionalURLRegex; | 356 String url = optionalURL ? *optionalURL : *optionalURLRegex; |
357 int columnNumber = 0; | 357 int columnNumber = 0; |
358 if (optionalColumnNumber) { | 358 if (optionalColumnNumber) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 int columnNumber; | 456 int columnNumber; |
457 | 457 |
458 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) | 458 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) |
459 return; | 459 return; |
460 | 460 |
461 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); | 461 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); |
462 m_continueToLocationBreakpointId = scriptDebugServer().setBreakpoint(scriptI
d, breakpoint, &lineNumber, &columnNumber, asBool(interstateLocationOpt)); | 462 m_continueToLocationBreakpointId = scriptDebugServer().setBreakpoint(scriptI
d, breakpoint, &lineNumber, &columnNumber, asBool(interstateLocationOpt)); |
463 resume(errorString); | 463 resume(errorString); |
464 } | 464 } |
465 | 465 |
466 void InspectorDebuggerAgent::getStepInPositions(ErrorString* errorString, const
String& callFrameId, RefPtr<Array<TypeBuilder::Debugger::Location> >& positions) | 466 void InspectorDebuggerAgent::getStepInPositions(ErrorString* errorString, const
String& callFrameId, RefPtr<Array<TypeBuilder::Debugger::Location>>& positions) |
467 { | 467 { |
468 if (!isPaused() || m_currentCallStack.isEmpty()) { | 468 if (!isPaused() || m_currentCallStack.isEmpty()) { |
469 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 469 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
470 return; | 470 return; |
471 } | 471 } |
472 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); | 472 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); |
473 if (injectedScript.isEmpty()) { | 473 if (injectedScript.isEmpty()) { |
474 *errorString = "Inspected frame has gone"; | 474 *errorString = "Inspected frame has gone"; |
475 return; | 475 return; |
476 } | 476 } |
477 | 477 |
478 injectedScript.getStepInPositions(errorString, m_currentCallStack, callFrame
Id, positions); | 478 injectedScript.getStepInPositions(errorString, m_currentCallStack, callFrame
Id, positions); |
479 } | 479 } |
480 | 480 |
481 void InspectorDebuggerAgent::getBacktrace(ErrorString* errorString, RefPtr<Array
<CallFrame> >& callFrames, RefPtr<StackTrace>& asyncStackTrace) | 481 void InspectorDebuggerAgent::getBacktrace(ErrorString* errorString, RefPtr<Array
<CallFrame>>& callFrames, RefPtr<StackTrace>& asyncStackTrace) |
482 { | 482 { |
483 if (!assertPaused(errorString)) | 483 if (!assertPaused(errorString)) |
484 return; | 484 return; |
485 m_currentCallStack = scriptDebugServer().currentCallFrames(); | 485 m_currentCallStack = scriptDebugServer().currentCallFrames(); |
486 callFrames = currentCallFrames(); | 486 callFrames = currentCallFrames(); |
487 asyncStackTrace = currentAsyncStackTrace(); | 487 asyncStackTrace = currentAsyncStackTrace(); |
488 } | 488 } |
489 | 489 |
490 bool InspectorDebuggerAgent::isCallStackEmptyOrBlackboxed() | 490 bool InspectorDebuggerAgent::isCallStackEmptyOrBlackboxed() |
491 { | 491 { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 else | 583 else |
584 debugServerBreakpointIdsIterator->value.append(debugServerBreakpointId); | 584 debugServerBreakpointIdsIterator->value.append(debugServerBreakpointId); |
585 | 585 |
586 RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Lo
cation::create() | 586 RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Lo
cation::create() |
587 .setScriptId(scriptId) | 587 .setScriptId(scriptId) |
588 .setLineNumber(actualLineNumber); | 588 .setLineNumber(actualLineNumber); |
589 location->setColumnNumber(actualColumnNumber); | 589 location->setColumnNumber(actualColumnNumber); |
590 return location; | 590 return location; |
591 } | 591 } |
592 | 592 |
593 void InspectorDebuggerAgent::searchInContent(ErrorString* error, const String& s
criptId, const String& query, const bool* const optionalCaseSensitive, const boo
l* const optionalIsRegex, RefPtr<Array<blink::TypeBuilder::Page::SearchMatch> >&
results) | 593 void InspectorDebuggerAgent::searchInContent(ErrorString* error, const String& s
criptId, const String& query, const bool* const optionalCaseSensitive, const boo
l* const optionalIsRegex, RefPtr<Array<blink::TypeBuilder::Page::SearchMatch>>&
results) |
594 { | 594 { |
595 ScriptsMap::iterator it = m_scripts.find(scriptId); | 595 ScriptsMap::iterator it = m_scripts.find(scriptId); |
596 if (it != m_scripts.end()) | 596 if (it != m_scripts.end()) |
597 results = ContentSearchUtils::searchInTextByLines(it->value.source(), qu
ery, asBool(optionalCaseSensitive), asBool(optionalIsRegex)); | 597 results = ContentSearchUtils::searchInTextByLines(it->value.source(), qu
ery, asBool(optionalCaseSensitive), asBool(optionalIsRegex)); |
598 else | 598 else |
599 *error = "No script for id: " + scriptId; | 599 *error = "No script for id: " + scriptId; |
600 } | 600 } |
601 | 601 |
602 void InspectorDebuggerAgent::setScriptSource(ErrorString* error, RefPtr<TypeBuil
der::Debugger::SetScriptSourceError>& errorData, const String& scriptId, const S
tring& newContent, const bool* const preview, RefPtr<Array<CallFrame> >& newCall
Frames, RefPtr<JSONObject>& result, RefPtr<StackTrace>& asyncStackTrace) | 602 void InspectorDebuggerAgent::setScriptSource(ErrorString* error, RefPtr<TypeBuil
der::Debugger::SetScriptSourceError>& errorData, const String& scriptId, const S
tring& newContent, const bool* const preview, RefPtr<Array<CallFrame>>& newCallF
rames, RefPtr<JSONObject>& result, RefPtr<StackTrace>& asyncStackTrace) |
603 { | 603 { |
604 if (!scriptDebugServer().setScriptSource(scriptId, newContent, asBool(previe
w), error, errorData, &m_currentCallStack, &result)) | 604 if (!scriptDebugServer().setScriptSource(scriptId, newContent, asBool(previe
w), error, errorData, &m_currentCallStack, &result)) |
605 return; | 605 return; |
606 | 606 |
607 newCallFrames = currentCallFrames(); | 607 newCallFrames = currentCallFrames(); |
608 asyncStackTrace = currentAsyncStackTrace(); | 608 asyncStackTrace = currentAsyncStackTrace(); |
609 | 609 |
610 ScriptsMap::iterator it = m_scripts.find(scriptId); | 610 ScriptsMap::iterator it = m_scripts.find(scriptId); |
611 if (it == m_scripts.end()) | 611 if (it == m_scripts.end()) |
612 return; | 612 return; |
613 String url = it->value.url(); | 613 String url = it->value.url(); |
614 if (url.isEmpty()) | 614 if (url.isEmpty()) |
615 return; | 615 return; |
616 if (InspectorPageAgent* pageAgent = m_instrumentingAgents->inspectorPageAgen
t()) | 616 if (InspectorPageAgent* pageAgent = m_instrumentingAgents->inspectorPageAgen
t()) |
617 pageAgent->addEditedResourceContent(url, newContent); | 617 pageAgent->addEditedResourceContent(url, newContent); |
618 } | 618 } |
619 | 619 |
620 void InspectorDebuggerAgent::restartFrame(ErrorString* errorString, const String
& callFrameId, RefPtr<Array<CallFrame> >& newCallFrames, RefPtr<JSONObject>& res
ult, RefPtr<StackTrace>& asyncStackTrace) | 620 void InspectorDebuggerAgent::restartFrame(ErrorString* errorString, const String
& callFrameId, RefPtr<Array<CallFrame>>& newCallFrames, RefPtr<JSONObject>& resu
lt, RefPtr<StackTrace>& asyncStackTrace) |
621 { | 621 { |
622 if (!isPaused() || m_currentCallStack.isEmpty()) { | 622 if (!isPaused() || m_currentCallStack.isEmpty()) { |
623 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 623 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
624 return; | 624 return; |
625 } | 625 } |
626 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); | 626 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); |
627 if (injectedScript.isEmpty()) { | 627 if (injectedScript.isEmpty()) { |
628 *errorString = "Inspected frame has gone"; | 628 *errorString = "Inspected frame has gone"; |
629 return; | 629 return; |
630 } | 630 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 void InspectorDebuggerAgent::getGeneratorObjectDetails(ErrorString* errorString,
const String& objectId, RefPtr<GeneratorObjectDetails>& details) | 667 void InspectorDebuggerAgent::getGeneratorObjectDetails(ErrorString* errorString,
const String& objectId, RefPtr<GeneratorObjectDetails>& details) |
668 { | 668 { |
669 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(objectId); | 669 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(objectId); |
670 if (injectedScript.isEmpty()) { | 670 if (injectedScript.isEmpty()) { |
671 *errorString = "Inspected frame has gone"; | 671 *errorString = "Inspected frame has gone"; |
672 return; | 672 return; |
673 } | 673 } |
674 injectedScript.getGeneratorObjectDetails(errorString, objectId, &details); | 674 injectedScript.getGeneratorObjectDetails(errorString, objectId, &details); |
675 } | 675 } |
676 | 676 |
677 void InspectorDebuggerAgent::getCollectionEntries(ErrorString* errorString, cons
t String& objectId, RefPtr<TypeBuilder::Array<CollectionEntry> >& entries) | 677 void InspectorDebuggerAgent::getCollectionEntries(ErrorString* errorString, cons
t String& objectId, RefPtr<TypeBuilder::Array<CollectionEntry>>& entries) |
678 { | 678 { |
679 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(objectId); | 679 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(objectId); |
680 if (injectedScript.isEmpty()) { | 680 if (injectedScript.isEmpty()) { |
681 *errorString = "Inspected frame has gone"; | 681 *errorString = "Inspected frame has gone"; |
682 return; | 682 return; |
683 } | 683 } |
684 injectedScript.getCollectionEntries(errorString, objectId, &entries); | 684 injectedScript.getCollectionEntries(errorString, objectId, &entries); |
685 } | 685 } |
686 | 686 |
687 void InspectorDebuggerAgent::schedulePauseOnNextStatement(InspectorFrontend::Deb
ugger::Reason::Enum breakReason, PassRefPtr<JSONObject> data) | 687 void InspectorDebuggerAgent::schedulePauseOnNextStatement(InspectorFrontend::Deb
ugger::Reason::Enum breakReason, PassRefPtr<JSONObject> data) |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 m_state->setBoolean(DebuggerAgentState::promiseTrackerCaptureStacks, asBool(
captureStacks)); | 1028 m_state->setBoolean(DebuggerAgentState::promiseTrackerCaptureStacks, asBool(
captureStacks)); |
1029 promiseTracker().setEnabled(true, asBool(captureStacks)); | 1029 promiseTracker().setEnabled(true, asBool(captureStacks)); |
1030 } | 1030 } |
1031 | 1031 |
1032 void InspectorDebuggerAgent::disablePromiseTracker(ErrorString*) | 1032 void InspectorDebuggerAgent::disablePromiseTracker(ErrorString*) |
1033 { | 1033 { |
1034 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, false); | 1034 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, false); |
1035 promiseTracker().setEnabled(false, false); | 1035 promiseTracker().setEnabled(false, false); |
1036 } | 1036 } |
1037 | 1037 |
1038 void InspectorDebuggerAgent::getPromises(ErrorString* errorString, RefPtr<Array<
PromiseDetails> >& promises) | 1038 void InspectorDebuggerAgent::getPromises(ErrorString* errorString, RefPtr<Array<
PromiseDetails>>& promises) |
1039 { | 1039 { |
1040 if (!promiseTracker().isEnabled()) { | 1040 if (!promiseTracker().isEnabled()) { |
1041 *errorString = "Promise tracking is disabled"; | 1041 *errorString = "Promise tracking is disabled"; |
1042 return; | 1042 return; |
1043 } | 1043 } |
1044 promises = promiseTracker().promises(); | 1044 promises = promiseTracker().promises(); |
1045 } | 1045 } |
1046 | 1046 |
1047 void InspectorDebuggerAgent::getPromiseById(ErrorString* errorString, int promis
eId, const String* objectGroup, RefPtr<RemoteObject>& promise) | 1047 void InspectorDebuggerAgent::getPromiseById(ErrorString* errorString, int promis
eId, const String* objectGroup, RefPtr<RemoteObject>& promise) |
1048 { | 1048 { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 // from the old StepFrame. | 1238 // from the old StepFrame. |
1239 m_skippedStepFrameCount = 0; | 1239 m_skippedStepFrameCount = 0; |
1240 if (m_scheduledDebuggerStep == NoStep) | 1240 if (m_scheduledDebuggerStep == NoStep) |
1241 scriptDebugServer().clearStepping(); | 1241 scriptDebugServer().clearStepping(); |
1242 else if (m_scheduledDebuggerStep == StepOut) | 1242 else if (m_scheduledDebuggerStep == StepOut) |
1243 m_skipNextDebuggerStepOut = true; | 1243 m_skipNextDebuggerStepOut = true; |
1244 } | 1244 } |
1245 } | 1245 } |
1246 } | 1246 } |
1247 | 1247 |
1248 PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames() | 1248 PassRefPtr<Array<CallFrame>> InspectorDebuggerAgent::currentCallFrames() |
1249 { | 1249 { |
1250 if (!m_pausedScriptState || m_currentCallStack.isEmpty()) | 1250 if (!m_pausedScriptState || m_currentCallStack.isEmpty()) |
1251 return Array<CallFrame>::create(); | 1251 return Array<CallFrame>::create(); |
1252 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m
_pausedScriptState.get()); | 1252 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m
_pausedScriptState.get()); |
1253 if (injectedScript.isEmpty()) { | 1253 if (injectedScript.isEmpty()) { |
1254 ASSERT_NOT_REACHED(); | 1254 ASSERT_NOT_REACHED(); |
1255 return Array<CallFrame>::create(); | 1255 return Array<CallFrame>::create(); |
1256 } | 1256 } |
1257 return injectedScript.wrapCallFrames(m_currentCallStack, 0); | 1257 return injectedScript.wrapCallFrames(m_currentCallStack, 0); |
1258 } | 1258 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 | 1420 |
1421 if (!exception.isEmpty()) { | 1421 if (!exception.isEmpty()) { |
1422 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptF
or(scriptState); | 1422 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptF
or(scriptState); |
1423 if (!injectedScript.isEmpty()) { | 1423 if (!injectedScript.isEmpty()) { |
1424 m_breakReason = isPromiseRejection ? InspectorFrontend::Debugger::Re
ason::PromiseRejection : InspectorFrontend::Debugger::Reason::Exception; | 1424 m_breakReason = isPromiseRejection ? InspectorFrontend::Debugger::Re
ason::PromiseRejection : InspectorFrontend::Debugger::Reason::Exception; |
1425 m_breakAuxData = injectedScript.wrapObject(exception, InspectorDebug
gerAgent::backtraceObjectGroup)->openAccessors(); | 1425 m_breakAuxData = injectedScript.wrapObject(exception, InspectorDebug
gerAgent::backtraceObjectGroup)->openAccessors(); |
1426 // m_breakAuxData might be null after this. | 1426 // m_breakAuxData might be null after this. |
1427 } | 1427 } |
1428 } | 1428 } |
1429 | 1429 |
1430 RefPtr<Array<String> > hitBreakpointIds = Array<String>::create(); | 1430 RefPtr<Array<String>> hitBreakpointIds = Array<String>::create(); |
1431 | 1431 |
1432 for (const auto& point : hitBreakpoints) { | 1432 for (const auto& point : hitBreakpoints) { |
1433 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter
ator = m_serverBreakpoints.find(point); | 1433 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter
ator = m_serverBreakpoints.find(point); |
1434 if (breakpointIterator != m_serverBreakpoints.end()) { | 1434 if (breakpointIterator != m_serverBreakpoints.end()) { |
1435 const String& localId = breakpointIterator->value.first; | 1435 const String& localId = breakpointIterator->value.first; |
1436 hitBreakpointIds->addItem(localId); | 1436 hitBreakpointIds->addItem(localId); |
1437 | 1437 |
1438 BreakpointSource source = breakpointIterator->value.second; | 1438 BreakpointSource source = breakpointIterator->value.second; |
1439 if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && s
ource == DebugCommandBreakpointSource) | 1439 if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && s
ource == DebugCommandBreakpointSource) |
1440 m_breakReason = InspectorFrontend::Debugger::Reason::DebugComman
d; | 1440 m_breakReason = InspectorFrontend::Debugger::Reason::DebugComman
d; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 visitor->trace(m_v8AsyncCallTracker); | 1556 visitor->trace(m_v8AsyncCallTracker); |
1557 visitor->trace(m_promiseTracker); | 1557 visitor->trace(m_promiseTracker); |
1558 visitor->trace(m_asyncOperations); | 1558 visitor->trace(m_asyncOperations); |
1559 visitor->trace(m_currentAsyncCallChain); | 1559 visitor->trace(m_currentAsyncCallChain); |
1560 visitor->trace(m_asyncCallTrackingListeners); | 1560 visitor->trace(m_asyncCallTrackingListeners); |
1561 #endif | 1561 #endif |
1562 InspectorBaseAgent::trace(visitor); | 1562 InspectorBaseAgent::trace(visitor); |
1563 } | 1563 } |
1564 | 1564 |
1565 } // namespace blink | 1565 } // namespace blink |
OLD | NEW |