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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 return; | 620 return; |
621 if (!debugger().setScriptSource(scriptId, newContent, asBool(preview), error
, errorData, &m_currentCallStack, stackChanged)) | 621 if (!debugger().setScriptSource(scriptId, newContent, asBool(preview), error
, errorData, &m_currentCallStack, stackChanged)) |
622 return; | 622 return; |
623 | 623 |
624 newCallFrames = currentCallFrames(); | 624 newCallFrames = currentCallFrames(); |
625 asyncStackTrace = currentAsyncStackTrace(); | 625 asyncStackTrace = currentAsyncStackTrace(); |
626 | 626 |
627 ScriptsMap::iterator it = m_scripts.find(scriptId); | 627 ScriptsMap::iterator it = m_scripts.find(scriptId); |
628 if (it == m_scripts.end()) | 628 if (it == m_scripts.end()) |
629 return; | 629 return; |
630 String url = it->value.url(); | 630 it->value.setSource(newContent); |
631 if (url.isEmpty()) | |
632 return; | |
633 m_editedScripts.set(url, newContent); | |
634 } | 631 } |
635 | 632 |
636 void InspectorDebuggerAgent::restartFrame(ErrorString* errorString, const String
& callFrameId, RefPtr<Array<CallFrame>>& newCallFrames, RefPtr<StackTrace>& asyn
cStackTrace) | 633 void InspectorDebuggerAgent::restartFrame(ErrorString* errorString, const String
& callFrameId, RefPtr<Array<CallFrame>>& newCallFrames, RefPtr<StackTrace>& asyn
cStackTrace) |
637 { | 634 { |
638 if (!isPaused() || m_currentCallStack.IsEmpty()) { | 635 if (!isPaused() || m_currentCallStack.IsEmpty()) { |
639 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 636 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
640 return; | 637 return; |
641 } | 638 } |
642 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId); | 639 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId); |
643 if (!remoteId) { | 640 if (!remoteId) { |
(...skipping 16 matching lines...) Expand all Loading... |
660 | 657 |
661 void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& s
criptId, String* scriptSource) | 658 void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& s
criptId, String* scriptSource) |
662 { | 659 { |
663 if (!checkEnabled(error)) | 660 if (!checkEnabled(error)) |
664 return; | 661 return; |
665 ScriptsMap::iterator it = m_scripts.find(scriptId); | 662 ScriptsMap::iterator it = m_scripts.find(scriptId); |
666 if (it == m_scripts.end()) { | 663 if (it == m_scripts.end()) { |
667 *error = "No script for id: " + scriptId; | 664 *error = "No script for id: " + scriptId; |
668 return; | 665 return; |
669 } | 666 } |
670 | |
671 String url = it->value.url(); | |
672 if (!url.isEmpty() && getEditedScript(url, scriptSource)) | |
673 return; | |
674 *scriptSource = it->value.source(); | 667 *scriptSource = it->value.source(); |
675 } | 668 } |
676 | 669 |
677 void InspectorDebuggerAgent::getFunctionDetails(ErrorString* errorString, const
String& functionId, RefPtr<FunctionDetails>& details) | 670 void InspectorDebuggerAgent::getFunctionDetails(ErrorString* errorString, const
String& functionId, RefPtr<FunctionDetails>& details) |
678 { | 671 { |
679 if (!checkEnabled(errorString)) | 672 if (!checkEnabled(errorString)) |
680 return; | 673 return; |
681 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionId); | 674 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionId); |
682 if (!remoteId) { | 675 if (!remoteId) { |
683 *errorString = "Invalid object id"; | 676 *errorString = "Invalid object id"; |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 // from the old StepFrame. | 1444 // from the old StepFrame. |
1452 m_skippedStepFrameCount = 0; | 1445 m_skippedStepFrameCount = 0; |
1453 if (m_scheduledDebuggerStep == NoStep) | 1446 if (m_scheduledDebuggerStep == NoStep) |
1454 debugger().clearStepping(); | 1447 debugger().clearStepping(); |
1455 else if (m_scheduledDebuggerStep == StepOut) | 1448 else if (m_scheduledDebuggerStep == StepOut) |
1456 m_skipNextDebuggerStepOut = true; | 1449 m_skipNextDebuggerStepOut = true; |
1457 } | 1450 } |
1458 } | 1451 } |
1459 } | 1452 } |
1460 | 1453 |
1461 bool InspectorDebuggerAgent::getEditedScript(const String& url, String* content) | |
1462 { | |
1463 if (!m_editedScripts.contains(url)) | |
1464 return false; | |
1465 *content = m_editedScripts.get(url); | |
1466 return true; | |
1467 } | |
1468 | |
1469 PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames() | 1454 PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames() |
1470 { | 1455 { |
1471 if (!m_pausedScriptState || m_currentCallStack.IsEmpty()) | 1456 if (!m_pausedScriptState || m_currentCallStack.IsEmpty()) |
1472 return Array<CallFrame>::create(); | 1457 return Array<CallFrame>::create(); |
1473 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m
_pausedScriptState.get()); | 1458 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m
_pausedScriptState.get()); |
1474 if (injectedScript.isEmpty()) { | 1459 if (injectedScript.isEmpty()) { |
1475 ASSERT_NOT_REACHED(); | 1460 ASSERT_NOT_REACHED(); |
1476 return Array<CallFrame>::create(); | 1461 return Array<CallFrame>::create(); |
1477 } | 1462 } |
1478 | 1463 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 { | 1739 { |
1755 m_scheduledDebuggerStep = NoStep; | 1740 m_scheduledDebuggerStep = NoStep; |
1756 m_scripts.clear(); | 1741 m_scripts.clear(); |
1757 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1742 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1758 resetAsyncCallTracker(); | 1743 resetAsyncCallTracker(); |
1759 promiseTracker().clear(); | 1744 promiseTracker().clear(); |
1760 if (frontend()) | 1745 if (frontend()) |
1761 frontend()->globalObjectCleared(); | 1746 frontend()->globalObjectCleared(); |
1762 } | 1747 } |
1763 | 1748 |
1764 void InspectorDebuggerAgent::resetModifiedSources() | |
1765 { | |
1766 m_editedScripts.clear(); | |
1767 } | |
1768 | |
1769 DEFINE_TRACE(InspectorDebuggerAgent) | 1749 DEFINE_TRACE(InspectorDebuggerAgent) |
1770 { | 1750 { |
1771 #if ENABLE(OILPAN) | 1751 #if ENABLE(OILPAN) |
1772 visitor->trace(m_injectedScriptManager); | 1752 visitor->trace(m_injectedScriptManager); |
1773 visitor->trace(m_listener); | 1753 visitor->trace(m_listener); |
1774 visitor->trace(m_v8AsyncCallTracker); | 1754 visitor->trace(m_v8AsyncCallTracker); |
1775 visitor->trace(m_promiseTracker); | 1755 visitor->trace(m_promiseTracker); |
1776 visitor->trace(m_asyncOperations); | 1756 visitor->trace(m_asyncOperations); |
1777 visitor->trace(m_currentAsyncCallChain); | 1757 visitor->trace(m_currentAsyncCallChain); |
1778 visitor->trace(m_asyncCallTrackingListeners); | 1758 visitor->trace(m_asyncCallTrackingListeners); |
1779 #endif | 1759 #endif |
1780 InspectorBaseAgent::trace(visitor); | 1760 InspectorBaseAgent::trace(visitor); |
1781 } | 1761 } |
1782 | 1762 |
1783 PassRefPtr<TypeBuilder::Debugger::ExceptionDetails> InspectorDebuggerAgent::crea
teExceptionDetails(v8::Isolate* isolate, v8::Local<v8::Message> message) | 1763 PassRefPtr<TypeBuilder::Debugger::ExceptionDetails> InspectorDebuggerAgent::crea
teExceptionDetails(v8::Isolate* isolate, v8::Local<v8::Message> message) |
1784 { | 1764 { |
1785 RefPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe
xt(toCoreStringWithUndefinedOrNullCheck(message->Get())); | 1765 RefPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe
xt(toCoreStringWithUndefinedOrNullCheck(message->Get())); |
1786 exceptionDetails->setLine(message->GetLineNumber()); | 1766 exceptionDetails->setLine(message->GetLineNumber()); |
1787 exceptionDetails->setColumn(message->GetStartColumn()); | 1767 exceptionDetails->setColumn(message->GetStartColumn()); |
1788 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace(); | 1768 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace(); |
1789 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0) | 1769 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0) |
1790 exceptionDetails->setStackTrace(createScriptCallStack(isolate, messageSt
ackTrace, messageStackTrace->GetFrameCount())->buildInspectorArray()); | 1770 exceptionDetails->setStackTrace(createScriptCallStack(isolate, messageSt
ackTrace, messageStackTrace->GetFrameCount())->buildInspectorArray()); |
1791 return exceptionDetails.release(); | 1771 return exceptionDetails.release(); |
1792 } | 1772 } |
1793 | 1773 |
1794 } // namespace blink | 1774 } // namespace blink |
OLD | NEW |