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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 return; | 616 return; |
617 if (!debugger().setScriptSource(scriptId, newContent, asBool(preview), error
, errorData, &m_currentCallStack, &result)) | 617 if (!debugger().setScriptSource(scriptId, newContent, asBool(preview), error
, errorData, &m_currentCallStack, &result)) |
618 return; | 618 return; |
619 | 619 |
620 newCallFrames = currentCallFrames(); | 620 newCallFrames = currentCallFrames(); |
621 asyncStackTrace = currentAsyncStackTrace(); | 621 asyncStackTrace = currentAsyncStackTrace(); |
622 | 622 |
623 ScriptsMap::iterator it = m_scripts.find(scriptId); | 623 ScriptsMap::iterator it = m_scripts.find(scriptId); |
624 if (it == m_scripts.end()) | 624 if (it == m_scripts.end()) |
625 return; | 625 return; |
626 String url = it->value.url(); | 626 it->value.setSource(newContent); |
627 if (url.isEmpty()) | |
628 return; | |
629 m_editedScripts.set(url, newContent); | |
630 } | 627 } |
631 | 628 |
632 void InspectorDebuggerAgent::restartFrame(ErrorString* errorString, const String
& callFrameId, RefPtr<Array<CallFrame> >& newCallFrames, RefPtr<JSONObject>& res
ult, RefPtr<StackTrace>& asyncStackTrace) | 629 void InspectorDebuggerAgent::restartFrame(ErrorString* errorString, const String
& callFrameId, RefPtr<Array<CallFrame> >& newCallFrames, RefPtr<JSONObject>& res
ult, RefPtr<StackTrace>& asyncStackTrace) |
633 { | 630 { |
634 if (!isPaused() || m_currentCallStack.isEmpty()) { | 631 if (!isPaused() || m_currentCallStack.isEmpty()) { |
635 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 632 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
636 return; | 633 return; |
637 } | 634 } |
638 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); | 635 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); |
639 if (injectedScript.isEmpty()) { | 636 if (injectedScript.isEmpty()) { |
640 *errorString = "Inspected frame has gone"; | 637 *errorString = "Inspected frame has gone"; |
641 return; | 638 return; |
642 } | 639 } |
643 | 640 |
644 injectedScript.restartFrame(errorString, m_currentCallStack, callFrameId, &r
esult); | 641 injectedScript.restartFrame(errorString, m_currentCallStack, callFrameId, &r
esult); |
645 m_currentCallStack = debugger().currentCallFrames(); | 642 m_currentCallStack = debugger().currentCallFrames(); |
646 newCallFrames = currentCallFrames(); | 643 newCallFrames = currentCallFrames(); |
647 asyncStackTrace = currentAsyncStackTrace(); | 644 asyncStackTrace = currentAsyncStackTrace(); |
648 } | 645 } |
649 | 646 |
650 void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& s
criptId, String* scriptSource) | 647 void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& s
criptId, String* scriptSource) |
651 { | 648 { |
652 if (!checkEnabled(error)) | 649 if (!checkEnabled(error)) |
653 return; | 650 return; |
654 ScriptsMap::iterator it = m_scripts.find(scriptId); | 651 ScriptsMap::iterator it = m_scripts.find(scriptId); |
655 if (it == m_scripts.end()) { | 652 if (it == m_scripts.end()) { |
656 *error = "No script for id: " + scriptId; | 653 *error = "No script for id: " + scriptId; |
657 return; | 654 return; |
658 } | 655 } |
659 | |
660 String url = it->value.url(); | |
661 if (!url.isEmpty() && getEditedScript(url, scriptSource)) | |
662 return; | |
663 *scriptSource = it->value.source(); | 656 *scriptSource = it->value.source(); |
664 } | 657 } |
665 | 658 |
666 void InspectorDebuggerAgent::getFunctionDetails(ErrorString* errorString, const
String& functionId, RefPtr<FunctionDetails>& details) | 659 void InspectorDebuggerAgent::getFunctionDetails(ErrorString* errorString, const
String& functionId, RefPtr<FunctionDetails>& details) |
667 { | 660 { |
668 if (!checkEnabled(errorString)) | 661 if (!checkEnabled(errorString)) |
669 return; | 662 return; |
670 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(functionId); | 663 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(functionId); |
671 if (injectedScript.isEmpty()) { | 664 if (injectedScript.isEmpty()) { |
672 *errorString = "Function object id is obsolete"; | 665 *errorString = "Function object id is obsolete"; |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 // from the old StepFrame. | 1412 // from the old StepFrame. |
1420 m_skippedStepFrameCount = 0; | 1413 m_skippedStepFrameCount = 0; |
1421 if (m_scheduledDebuggerStep == NoStep) | 1414 if (m_scheduledDebuggerStep == NoStep) |
1422 debugger().clearStepping(); | 1415 debugger().clearStepping(); |
1423 else if (m_scheduledDebuggerStep == StepOut) | 1416 else if (m_scheduledDebuggerStep == StepOut) |
1424 m_skipNextDebuggerStepOut = true; | 1417 m_skipNextDebuggerStepOut = true; |
1425 } | 1418 } |
1426 } | 1419 } |
1427 } | 1420 } |
1428 | 1421 |
1429 bool InspectorDebuggerAgent::getEditedScript(const String& url, String* content) | |
1430 { | |
1431 if (!m_editedScripts.contains(url)) | |
1432 return false; | |
1433 *content = m_editedScripts.get(url); | |
1434 return true; | |
1435 } | |
1436 | |
1437 PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames() | 1422 PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames() |
1438 { | 1423 { |
1439 if (!m_pausedScriptState || m_currentCallStack.isEmpty()) | 1424 if (!m_pausedScriptState || m_currentCallStack.isEmpty()) |
1440 return Array<CallFrame>::create(); | 1425 return Array<CallFrame>::create(); |
1441 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m
_pausedScriptState.get()); | 1426 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m
_pausedScriptState.get()); |
1442 if (injectedScript.isEmpty()) { | 1427 if (injectedScript.isEmpty()) { |
1443 ASSERT_NOT_REACHED(); | 1428 ASSERT_NOT_REACHED(); |
1444 return Array<CallFrame>::create(); | 1429 return Array<CallFrame>::create(); |
1445 } | 1430 } |
1446 return injectedScript.wrapCallFrames(m_currentCallStack, 0); | 1431 return injectedScript.wrapCallFrames(m_currentCallStack, 0); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1718 { | 1703 { |
1719 m_scheduledDebuggerStep = NoStep; | 1704 m_scheduledDebuggerStep = NoStep; |
1720 m_scripts.clear(); | 1705 m_scripts.clear(); |
1721 m_breakpointIdToDebuggerBreakpointIds.clear(); | 1706 m_breakpointIdToDebuggerBreakpointIds.clear(); |
1722 resetAsyncCallTracker(); | 1707 resetAsyncCallTracker(); |
1723 promiseTracker().clear(); | 1708 promiseTracker().clear(); |
1724 if (frontend()) | 1709 if (frontend()) |
1725 frontend()->globalObjectCleared(); | 1710 frontend()->globalObjectCleared(); |
1726 } | 1711 } |
1727 | 1712 |
1728 void InspectorDebuggerAgent::resetModifiedSources() | |
1729 { | |
1730 m_editedScripts.clear(); | |
1731 } | |
1732 | |
1733 DEFINE_TRACE(InspectorDebuggerAgent) | 1713 DEFINE_TRACE(InspectorDebuggerAgent) |
1734 { | 1714 { |
1735 #if ENABLE(OILPAN) | 1715 #if ENABLE(OILPAN) |
1736 visitor->trace(m_injectedScriptManager); | 1716 visitor->trace(m_injectedScriptManager); |
1737 visitor->trace(m_debugger); | 1717 visitor->trace(m_debugger); |
1738 visitor->trace(m_listener); | 1718 visitor->trace(m_listener); |
1739 visitor->trace(m_v8AsyncCallTracker); | 1719 visitor->trace(m_v8AsyncCallTracker); |
1740 visitor->trace(m_promiseTracker); | 1720 visitor->trace(m_promiseTracker); |
1741 visitor->trace(m_asyncOperations); | 1721 visitor->trace(m_asyncOperations); |
1742 visitor->trace(m_currentAsyncCallChain); | 1722 visitor->trace(m_currentAsyncCallChain); |
1743 visitor->trace(m_asyncCallTrackingListeners); | 1723 visitor->trace(m_asyncCallTrackingListeners); |
1744 #endif | 1724 #endif |
1745 InspectorBaseAgent::trace(visitor); | 1725 InspectorBaseAgent::trace(visitor); |
1746 } | 1726 } |
1747 | 1727 |
1748 PassRefPtr<TypeBuilder::Debugger::ExceptionDetails> InspectorDebuggerAgent::crea
teExceptionDetails(v8::Isolate* isolate, v8::Local<v8::Message> message) | 1728 PassRefPtr<TypeBuilder::Debugger::ExceptionDetails> InspectorDebuggerAgent::crea
teExceptionDetails(v8::Isolate* isolate, v8::Local<v8::Message> message) |
1749 { | 1729 { |
1750 RefPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe
xt(toCoreStringWithUndefinedOrNullCheck(message->Get())); | 1730 RefPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe
xt(toCoreStringWithUndefinedOrNullCheck(message->Get())); |
1751 exceptionDetails->setLine(message->GetLineNumber()); | 1731 exceptionDetails->setLine(message->GetLineNumber()); |
1752 exceptionDetails->setColumn(message->GetStartColumn()); | 1732 exceptionDetails->setColumn(message->GetStartColumn()); |
1753 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace(); | 1733 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace(); |
1754 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0) | 1734 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0) |
1755 exceptionDetails->setStackTrace(createScriptCallStack(isolate, messageSt
ackTrace, messageStackTrace->GetFrameCount())->buildInspectorArray()); | 1735 exceptionDetails->setStackTrace(createScriptCallStack(isolate, messageSt
ackTrace, messageStackTrace->GetFrameCount())->buildInspectorArray()); |
1756 return exceptionDetails.release(); | 1736 return exceptionDetails.release(); |
1757 } | 1737 } |
1758 | 1738 |
1759 } // namespace blink | 1739 } // namespace blink |
OLD | NEW |