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) 2010-2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2010-2011 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 return ":monitor"; | 91 return ":monitor"; |
92 } | 92 } |
93 return String(); | 93 return String(); |
94 } | 94 } |
95 | 95 |
96 static String generateBreakpointId(const String& scriptId, int lineNumber, int c
olumnNumber, InspectorDebuggerAgent::BreakpointSource source) | 96 static String generateBreakpointId(const String& scriptId, int lineNumber, int c
olumnNumber, InspectorDebuggerAgent::BreakpointSource source) |
97 { | 97 { |
98 return scriptId + ':' + String::number(lineNumber) + ':' + String::number(co
lumnNumber) + breakpointIdSuffix(source); | 98 return scriptId + ':' + String::number(lineNumber) + ':' + String::number(co
lumnNumber) + breakpointIdSuffix(source); |
99 } | 99 } |
100 | 100 |
| 101 static bool asBool(const bool* const b) |
| 102 { |
| 103 return b ? *b : false; |
| 104 } |
| 105 |
101 InspectorDebuggerAgent::InspectorDebuggerAgent(InstrumentingAgents* instrumentin
gAgents, InspectorCompositeState* inspectorState, InjectedScriptManager* injecte
dScriptManager) | 106 InspectorDebuggerAgent::InspectorDebuggerAgent(InstrumentingAgents* instrumentin
gAgents, InspectorCompositeState* inspectorState, InjectedScriptManager* injecte
dScriptManager) |
102 : InspectorBaseAgent<InspectorDebuggerAgent>("Debugger", instrumentingAgents
, inspectorState) | 107 : InspectorBaseAgent<InspectorDebuggerAgent>("Debugger", instrumentingAgents
, inspectorState) |
103 , m_injectedScriptManager(injectedScriptManager) | 108 , m_injectedScriptManager(injectedScriptManager) |
104 , m_frontend(0) | 109 , m_frontend(0) |
105 , m_pausedScriptState(0) | 110 , m_pausedScriptState(0) |
106 , m_javaScriptPauseScheduled(false) | 111 , m_javaScriptPauseScheduled(false) |
107 , m_listener(0) | 112 , m_listener(0) |
108 , m_skipStepInCount(numberOfStepsBeforeStepOut) | 113 , m_skipStepInCount(numberOfStepsBeforeStepOut) |
109 , m_skipAllPauses(false) | 114 , m_skipAllPauses(false) |
110 { | 115 { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 for (size_t i = 0; i < debugServerBreakpointIdsIterator->value.size(); ++i)
{ | 410 for (size_t i = 0; i < debugServerBreakpointIdsIterator->value.size(); ++i)
{ |
406 const String& debugServerBreakpointId = debugServerBreakpointIdsIterator
->value[i]; | 411 const String& debugServerBreakpointId = debugServerBreakpointIdsIterator
->value[i]; |
407 scriptDebugServer().removeBreakpoint(debugServerBreakpointId); | 412 scriptDebugServer().removeBreakpoint(debugServerBreakpointId); |
408 m_serverBreakpoints.remove(debugServerBreakpointId); | 413 m_serverBreakpoints.remove(debugServerBreakpointId); |
409 } | 414 } |
410 m_breakpointIdToDebugServerBreakpointIds.remove(debugServerBreakpointIdsIter
ator); | 415 m_breakpointIdToDebugServerBreakpointIds.remove(debugServerBreakpointIdsIter
ator); |
411 } | 416 } |
412 | 417 |
413 void InspectorDebuggerAgent::continueToLocation(ErrorString* errorString, const
RefPtr<JSONObject>& location, const bool* interstateLocationOpt) | 418 void InspectorDebuggerAgent::continueToLocation(ErrorString* errorString, const
RefPtr<JSONObject>& location, const bool* interstateLocationOpt) |
414 { | 419 { |
415 bool interstateLocation = interstateLocationOpt ? *interstateLocationOpt : f
alse; | |
416 if (!m_continueToLocationBreakpointId.isEmpty()) { | 420 if (!m_continueToLocationBreakpointId.isEmpty()) { |
417 scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId); | 421 scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId); |
418 m_continueToLocationBreakpointId = ""; | 422 m_continueToLocationBreakpointId = ""; |
419 } | 423 } |
420 | 424 |
421 String scriptId; | 425 String scriptId; |
422 int lineNumber; | 426 int lineNumber; |
423 int columnNumber; | 427 int columnNumber; |
424 | 428 |
425 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) | 429 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) |
426 return; | 430 return; |
427 | 431 |
428 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); | 432 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); |
429 m_continueToLocationBreakpointId = scriptDebugServer().setBreakpoint(scriptI
d, breakpoint, &lineNumber, &columnNumber, interstateLocation); | 433 m_continueToLocationBreakpointId = scriptDebugServer().setBreakpoint(scriptI
d, breakpoint, &lineNumber, &columnNumber, asBool(interstateLocationOpt)); |
430 resume(errorString); | 434 resume(errorString); |
431 } | 435 } |
432 | 436 |
433 void InspectorDebuggerAgent::getStepInPositions(ErrorString* errorString, const
String& callFrameId, RefPtr<Array<Location> >& positions) | 437 void InspectorDebuggerAgent::getStepInPositions(ErrorString* errorString, const
String& callFrameId, RefPtr<Array<Location> >& positions) |
434 { | 438 { |
435 if (!isPaused() || m_currentCallStack.isNull()) { | 439 if (!isPaused() || m_currentCallStack.isNull()) { |
436 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 440 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
437 return; | 441 return; |
438 } | 442 } |
439 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); | 443 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 if (scriptObject.hasNoValue()) | 580 if (scriptObject.hasNoValue()) |
577 return 0; | 581 return 0; |
578 RefPtr<JSONValue> value = scriptObject.toJSONValue(scriptObject.scriptState(
)); | 582 RefPtr<JSONValue> value = scriptObject.toJSONValue(scriptObject.scriptState(
)); |
579 if (!value) | 583 if (!value) |
580 return 0; | 584 return 0; |
581 return value->asObject(); | 585 return value->asObject(); |
582 } | 586 } |
583 | 587 |
584 void InspectorDebuggerAgent::searchInContent(ErrorString* error, const String& s
criptId, const String& query, const bool* const optionalCaseSensitive, const boo
l* const optionalIsRegex, RefPtr<Array<WebCore::TypeBuilder::Page::SearchMatch>
>& results) | 588 void InspectorDebuggerAgent::searchInContent(ErrorString* error, const String& s
criptId, const String& query, const bool* const optionalCaseSensitive, const boo
l* const optionalIsRegex, RefPtr<Array<WebCore::TypeBuilder::Page::SearchMatch>
>& results) |
585 { | 589 { |
586 bool isRegex = optionalIsRegex ? *optionalIsRegex : false; | |
587 bool caseSensitive = optionalCaseSensitive ? *optionalCaseSensitive : false; | |
588 | |
589 ScriptsMap::iterator it = m_scripts.find(scriptId); | 590 ScriptsMap::iterator it = m_scripts.find(scriptId); |
590 if (it != m_scripts.end()) | 591 if (it != m_scripts.end()) |
591 results = ContentSearchUtils::searchInTextByLines(it->value.source, quer
y, caseSensitive, isRegex); | 592 results = ContentSearchUtils::searchInTextByLines(it->value.source, quer
y, asBool(optionalCaseSensitive), asBool(optionalIsRegex)); |
592 else | 593 else |
593 *error = "No script for id: " + scriptId; | 594 *error = "No script for id: " + scriptId; |
594 } | 595 } |
595 | 596 |
596 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) | 597 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) |
597 { | 598 { |
598 bool previewOnly = preview && *preview; | 599 bool previewOnly = preview && *preview; |
599 ScriptObject resultObject; | 600 ScriptObject resultObject; |
600 if (!scriptDebugServer().setScriptSource(scriptId, newContent, previewOnly,
error, errorData, &m_currentCallStack, &resultObject)) | 601 if (!scriptDebugServer().setScriptSource(scriptId, newContent, previewOnly,
error, errorData, &m_currentCallStack, &resultObject)) |
601 return; | 602 return; |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 | 751 |
751 void InspectorDebuggerAgent::setPauseOnExceptionsImpl(ErrorString* errorString,
int pauseState) | 752 void InspectorDebuggerAgent::setPauseOnExceptionsImpl(ErrorString* errorString,
int pauseState) |
752 { | 753 { |
753 scriptDebugServer().setPauseOnExceptionsState(static_cast<ScriptDebugServer:
:PauseOnExceptionsState>(pauseState)); | 754 scriptDebugServer().setPauseOnExceptionsState(static_cast<ScriptDebugServer:
:PauseOnExceptionsState>(pauseState)); |
754 if (scriptDebugServer().pauseOnExceptionsState() != pauseState) | 755 if (scriptDebugServer().pauseOnExceptionsState() != pauseState) |
755 *errorString = "Internal error. Could not change pause on exceptions sta
te"; | 756 *errorString = "Internal error. Could not change pause on exceptions sta
te"; |
756 else | 757 else |
757 m_state->setLong(DebuggerAgentState::pauseOnExceptionsState, pauseState)
; | 758 m_state->setLong(DebuggerAgentState::pauseOnExceptionsState, pauseState)
; |
758 } | 759 } |
759 | 760 |
760 void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString* errorString, const
String& callFrameId, const String& expression, const String* const objectGroup,
const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptio
nsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview,
RefPtr<RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown) | 761 void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString* errorString, const
String& callFrameId, const String& expression, const String* const objectGroup,
const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptio
nsAndMuteConsole, const bool* const returnByValue, const bool* const forceObject
Id, const bool* generatePreview, RefPtr<RemoteObject>& result, TypeBuilder::OptO
utput<bool>* wasThrown) |
761 { | 762 { |
762 if (!isPaused() || m_currentCallStack.isNull()) { | 763 if (!isPaused() || m_currentCallStack.isNull()) { |
763 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 764 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
764 return; | 765 return; |
765 } | 766 } |
766 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); | 767 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); |
767 if (injectedScript.hasNoValue()) { | 768 if (injectedScript.hasNoValue()) { |
768 *errorString = "Inspected frame has gone"; | 769 *errorString = "Inspected frame has gone"; |
769 return; | 770 return; |
770 } | 771 } |
771 | 772 |
772 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
criptDebugServer().pauseOnExceptionsState(); | 773 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
criptDebugServer().pauseOnExceptionsState(); |
773 if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteCon
sole : false) { | 774 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { |
774 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce
ptions) | 775 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce
ptions) |
775 scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::Don
tPauseOnExceptions); | 776 scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::Don
tPauseOnExceptions); |
776 muteConsole(); | 777 muteConsole(); |
777 } | 778 } |
778 | 779 |
779 injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFram
eId, expression, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *inclu
deCommandLineAPI : false, returnByValue ? *returnByValue : false, generatePrevie
w ? *generatePreview : false, &result, wasThrown); | 780 injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFram
eId, expression, objectGroup ? *objectGroup : "", asBool(includeCommandLineAPI),
asBool(returnByValue), asBool(forceObjectId), asBool(generatePreview), &result,
wasThrown); |
780 | 781 |
781 if (doNotPauseOnExceptionsAndMuteConsole ? *doNotPauseOnExceptionsAndMuteCon
sole : false) { | 782 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { |
782 unmuteConsole(); | 783 unmuteConsole(); |
783 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep
tionsState) | 784 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep
tionsState) |
784 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti
onsState); | 785 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti
onsState); |
785 } | 786 } |
786 } | 787 } |
787 | 788 |
788 void InspectorDebuggerAgent::compileScript(ErrorString* errorString, const Strin
g& expression, const String& sourceURL, TypeBuilder::OptOutput<ScriptId>* script
Id, TypeBuilder::OptOutput<String>* syntaxErrorMessage) | 789 void InspectorDebuggerAgent::compileScript(ErrorString* errorString, const Strin
g& expression, const String& sourceURL, TypeBuilder::OptOutput<ScriptId>* script
Id, TypeBuilder::OptOutput<String>* syntaxErrorMessage) |
789 { | 790 { |
790 InjectedScript injectedScript = injectedScriptForEval(errorString, 0); | 791 InjectedScript injectedScript = injectedScriptForEval(errorString, 0); |
791 if (injectedScript.hasNoValue()) { | 792 if (injectedScript.hasNoValue()) { |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 void InspectorDebuggerAgent::reset() | 1085 void InspectorDebuggerAgent::reset() |
1085 { | 1086 { |
1086 m_scripts.clear(); | 1087 m_scripts.clear(); |
1087 m_breakpointIdToDebugServerBreakpointIds.clear(); | 1088 m_breakpointIdToDebugServerBreakpointIds.clear(); |
1088 if (m_frontend) | 1089 if (m_frontend) |
1089 m_frontend->globalObjectCleared(); | 1090 m_frontend->globalObjectCleared(); |
1090 } | 1091 } |
1091 | 1092 |
1092 } // namespace WebCore | 1093 } // namespace WebCore |
1093 | 1094 |
OLD | NEW |