| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "core/platform/text/RegularExpression.h" | 45 #include "core/platform/text/RegularExpression.h" |
| 46 #include "platform/JSONValues.h" | 46 #include "platform/JSONValues.h" |
| 47 #include "wtf/text/WTFString.h" | 47 #include "wtf/text/WTFString.h" |
| 48 | 48 |
| 49 using WebCore::TypeBuilder::Array; | 49 using WebCore::TypeBuilder::Array; |
| 50 using WebCore::TypeBuilder::Debugger::BreakpointId; | 50 using WebCore::TypeBuilder::Debugger::BreakpointId; |
| 51 using WebCore::TypeBuilder::Debugger::CallFrame; | 51 using WebCore::TypeBuilder::Debugger::CallFrame; |
| 52 using WebCore::TypeBuilder::Debugger::FunctionDetails; | 52 using WebCore::TypeBuilder::Debugger::FunctionDetails; |
| 53 using WebCore::TypeBuilder::Debugger::Location; | 53 using WebCore::TypeBuilder::Debugger::Location; |
| 54 using WebCore::TypeBuilder::Debugger::ScriptId; | 54 using WebCore::TypeBuilder::Debugger::ScriptId; |
| 55 using WebCore::TypeBuilder::Debugger::StackTrace; |
| 55 using WebCore::TypeBuilder::Runtime::RemoteObject; | 56 using WebCore::TypeBuilder::Runtime::RemoteObject; |
| 56 | 57 |
| 57 namespace WebCore { | 58 namespace WebCore { |
| 58 | 59 |
| 59 namespace DebuggerAgentState { | 60 namespace DebuggerAgentState { |
| 60 static const char debuggerEnabled[] = "debuggerEnabled"; | 61 static const char debuggerEnabled[] = "debuggerEnabled"; |
| 61 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; | 62 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; |
| 62 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; | 63 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; |
| 63 | 64 |
| 64 // Breakpoint properties. | 65 // Breakpoint properties. |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 } | 437 } |
| 437 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); | 438 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); |
| 438 if (injectedScript.hasNoValue()) { | 439 if (injectedScript.hasNoValue()) { |
| 439 *errorString = "Inspected frame has gone"; | 440 *errorString = "Inspected frame has gone"; |
| 440 return; | 441 return; |
| 441 } | 442 } |
| 442 | 443 |
| 443 injectedScript.getStepInPositions(errorString, m_currentCallStack, callFrame
Id, positions); | 444 injectedScript.getStepInPositions(errorString, m_currentCallStack, callFrame
Id, positions); |
| 444 } | 445 } |
| 445 | 446 |
| 446 void InspectorDebuggerAgent::getBacktrace(ErrorString* errorString, RefPtr<Array
<CallFrame> >& callFrames) | 447 void InspectorDebuggerAgent::getBacktrace(ErrorString* errorString, RefPtr<Array
<CallFrame> >& callFrames, RefPtr<StackTrace>& asyncStackTrace) |
| 447 { | 448 { |
| 448 if (!assertPaused(errorString)) | 449 if (!assertPaused(errorString)) |
| 449 return; | 450 return; |
| 450 scriptDebugServer().updateCallStack(&m_currentCallStack); | 451 scriptDebugServer().updateCallStack(&m_currentCallStack); |
| 451 callFrames = currentCallFrames(); | 452 callFrames = currentCallFrames(); |
| 453 asyncStackTrace = currentAsyncStackTrace(); |
| 452 } | 454 } |
| 453 | 455 |
| 454 String InspectorDebuggerAgent::scriptURL(JavaScriptCallFrame* frame) | 456 String InspectorDebuggerAgent::scriptURL(JavaScriptCallFrame* frame) |
| 455 { | 457 { |
| 456 String scriptIdString = String::number(frame->sourceID()); | 458 String scriptIdString = String::number(frame->sourceID()); |
| 457 ScriptsMap::iterator it = m_scripts.find(scriptIdString); | 459 ScriptsMap::iterator it = m_scripts.find(scriptIdString); |
| 458 if (it == m_scripts.end()) | 460 if (it == m_scripts.end()) |
| 459 return String(); | 461 return String(); |
| 460 return it->value.url; | 462 return it->value.url; |
| 461 } | 463 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 bool isRegex = optionalIsRegex ? *optionalIsRegex : false; | 586 bool isRegex = optionalIsRegex ? *optionalIsRegex : false; |
| 585 bool caseSensitive = optionalCaseSensitive ? *optionalCaseSensitive : false; | 587 bool caseSensitive = optionalCaseSensitive ? *optionalCaseSensitive : false; |
| 586 | 588 |
| 587 ScriptsMap::iterator it = m_scripts.find(scriptId); | 589 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 588 if (it != m_scripts.end()) | 590 if (it != m_scripts.end()) |
| 589 results = ContentSearchUtils::searchInTextByLines(it->value.source, quer
y, caseSensitive, isRegex); | 591 results = ContentSearchUtils::searchInTextByLines(it->value.source, quer
y, caseSensitive, isRegex); |
| 590 else | 592 else |
| 591 *error = "No script for id: " + scriptId; | 593 *error = "No script for id: " + scriptId; |
| 592 } | 594 } |
| 593 | 595 |
| 594 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) | 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, RefPtr<StackTrace>& asyncStackTrace) |
| 595 { | 597 { |
| 596 bool previewOnly = preview && *preview; | 598 bool previewOnly = preview && *preview; |
| 597 ScriptObject resultObject; | 599 ScriptObject resultObject; |
| 598 if (!scriptDebugServer().setScriptSource(scriptId, newContent, previewOnly,
error, errorData, &m_currentCallStack, &resultObject)) | 600 if (!scriptDebugServer().setScriptSource(scriptId, newContent, previewOnly,
error, errorData, &m_currentCallStack, &resultObject)) |
| 599 return; | 601 return; |
| 600 newCallFrames = currentCallFrames(); | 602 newCallFrames = currentCallFrames(); |
| 603 asyncStackTrace = currentAsyncStackTrace(); |
| 601 RefPtr<JSONObject> object = scriptToInspectorObject(resultObject); | 604 RefPtr<JSONObject> object = scriptToInspectorObject(resultObject); |
| 602 if (object) | 605 if (object) |
| 603 result = object; | 606 result = object; |
| 604 } | 607 } |
| 605 void InspectorDebuggerAgent::restartFrame(ErrorString* errorString, const String
& callFrameId, RefPtr<Array<CallFrame> >& newCallFrames, RefPtr<JSONObject>& res
ult) | 608 |
| 609 void InspectorDebuggerAgent::restartFrame(ErrorString* errorString, const String
& callFrameId, RefPtr<Array<CallFrame> >& newCallFrames, RefPtr<JSONObject>& res
ult, RefPtr<StackTrace>& asyncStackTrace) |
| 606 { | 610 { |
| 607 if (!isPaused() || m_currentCallStack.isNull()) { | 611 if (!isPaused() || m_currentCallStack.isNull()) { |
| 608 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 612 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
| 609 return; | 613 return; |
| 610 } | 614 } |
| 611 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); | 615 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); |
| 612 if (injectedScript.hasNoValue()) { | 616 if (injectedScript.hasNoValue()) { |
| 613 *errorString = "Inspected frame has gone"; | 617 *errorString = "Inspected frame has gone"; |
| 614 return; | 618 return; |
| 615 } | 619 } |
| 616 | 620 |
| 617 injectedScript.restartFrame(errorString, m_currentCallStack, callFrameId, &r
esult); | 621 injectedScript.restartFrame(errorString, m_currentCallStack, callFrameId, &r
esult); |
| 618 scriptDebugServer().updateCallStack(&m_currentCallStack); | 622 scriptDebugServer().updateCallStack(&m_currentCallStack); |
| 619 newCallFrames = currentCallFrames(); | 623 newCallFrames = currentCallFrames(); |
| 624 asyncStackTrace = currentAsyncStackTrace(); |
| 620 } | 625 } |
| 621 | 626 |
| 622 void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& s
criptId, String* scriptSource) | 627 void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& s
criptId, String* scriptSource) |
| 623 { | 628 { |
| 624 ScriptsMap::iterator it = m_scripts.find(scriptId); | 629 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 625 if (it != m_scripts.end()) | 630 if (it != m_scripts.end()) |
| 626 *scriptSource = it->value.source; | 631 *scriptSource = it->value.source; |
| 627 else | 632 else |
| 628 *error = "No script for id: " + scriptId; | 633 *error = "No script for id: " + scriptId; |
| 629 } | 634 } |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 if (!m_pausedScriptState) | 903 if (!m_pausedScriptState) |
| 899 return Array<CallFrame>::create(); | 904 return Array<CallFrame>::create(); |
| 900 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m
_pausedScriptState); | 905 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m
_pausedScriptState); |
| 901 if (injectedScript.hasNoValue()) { | 906 if (injectedScript.hasNoValue()) { |
| 902 ASSERT_NOT_REACHED(); | 907 ASSERT_NOT_REACHED(); |
| 903 return Array<CallFrame>::create(); | 908 return Array<CallFrame>::create(); |
| 904 } | 909 } |
| 905 return injectedScript.wrapCallFrames(m_currentCallStack); | 910 return injectedScript.wrapCallFrames(m_currentCallStack); |
| 906 } | 911 } |
| 907 | 912 |
| 913 PassRefPtr<StackTrace> InspectorDebuggerAgent::currentAsyncStackTrace() |
| 914 { |
| 915 // FIXME: Implement async stack traces. |
| 916 return 0; |
| 917 } |
| 918 |
| 908 String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script) | 919 String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script) |
| 909 { | 920 { |
| 910 bool deprecated; | 921 bool deprecated; |
| 911 String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source, Co
ntentSearchUtils::JavaScriptMagicComment, &deprecated); | 922 String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source, Co
ntentSearchUtils::JavaScriptMagicComment, &deprecated); |
| 912 if (!sourceMapURL.isEmpty()) { | 923 if (!sourceMapURL.isEmpty()) { |
| 913 // FIXME: add deprecated console message here. | 924 // FIXME: add deprecated console message here. |
| 914 return sourceMapURL; | 925 return sourceMapURL; |
| 915 } | 926 } |
| 916 | 927 |
| 917 if (script.url.isEmpty()) | 928 if (script.url.isEmpty()) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 if (breakpointIterator != m_serverBreakpoints.end()) { | 1010 if (breakpointIterator != m_serverBreakpoints.end()) { |
| 1000 const String& localId = breakpointIterator->value.first; | 1011 const String& localId = breakpointIterator->value.first; |
| 1001 hitBreakpointIds->addItem(localId); | 1012 hitBreakpointIds->addItem(localId); |
| 1002 | 1013 |
| 1003 BreakpointSource source = breakpointIterator->value.second; | 1014 BreakpointSource source = breakpointIterator->value.second; |
| 1004 if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && s
ource == DebugCommandBreakpointSource) | 1015 if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && s
ource == DebugCommandBreakpointSource) |
| 1005 m_breakReason = InspectorFrontend::Debugger::Reason::DebugComman
d; | 1016 m_breakReason = InspectorFrontend::Debugger::Reason::DebugComman
d; |
| 1006 } | 1017 } |
| 1007 } | 1018 } |
| 1008 | 1019 |
| 1009 m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData, hitBr
eakpointIds); | 1020 m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData, hitBr
eakpointIds, currentAsyncStackTrace()); |
| 1010 m_javaScriptPauseScheduled = false; | 1021 m_javaScriptPauseScheduled = false; |
| 1011 | 1022 |
| 1012 if (!m_continueToLocationBreakpointId.isEmpty()) { | 1023 if (!m_continueToLocationBreakpointId.isEmpty()) { |
| 1013 scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId); | 1024 scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId); |
| 1014 m_continueToLocationBreakpointId = ""; | 1025 m_continueToLocationBreakpointId = ""; |
| 1015 } | 1026 } |
| 1016 if (m_listener) | 1027 if (m_listener) |
| 1017 m_listener->didPause(); | 1028 m_listener->didPause(); |
| 1018 } | 1029 } |
| 1019 | 1030 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 void InspectorDebuggerAgent::reset() | 1093 void InspectorDebuggerAgent::reset() |
| 1083 { | 1094 { |
| 1084 m_scripts.clear(); | 1095 m_scripts.clear(); |
| 1085 m_breakpointIdToDebugServerBreakpointIds.clear(); | 1096 m_breakpointIdToDebugServerBreakpointIds.clear(); |
| 1086 if (m_frontend) | 1097 if (m_frontend) |
| 1087 m_frontend->globalObjectCleared(); | 1098 m_frontend->globalObjectCleared(); |
| 1088 } | 1099 } |
| 1089 | 1100 |
| 1090 } // namespace WebCore | 1101 } // namespace WebCore |
| 1091 | 1102 |
| OLD | NEW |