summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h')
-rw-r--r--Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h180
1 files changed, 103 insertions, 77 deletions
diff --git a/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h b/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h
index 0e652499d..6f8132ac2 100644
--- a/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h
+++ b/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2010, 2013 Apple Inc. All rights reserved.
- * Copyright (C) 2010-2011 Google Inc. All rights reserved.
+ * Copyright (C) 2010, 2013, 2015-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@@ -27,37 +27,32 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef InspectorDebuggerAgent_h
-#define InspectorDebuggerAgent_h
+#pragma once
-#if ENABLE(INSPECTOR)
-
-#include "InspectorJSBackendDispatchers.h"
-#include "InspectorJSFrontendDispatchers.h"
+#include "InspectorBackendDispatchers.h"
+#include "InspectorFrontendDispatchers.h"
#include "bindings/ScriptValue.h"
#include "debugger/Debugger.h"
#include "inspector/InspectorAgentBase.h"
#include "inspector/ScriptBreakpoint.h"
+#include "inspector/ScriptCallStack.h"
#include "inspector/ScriptDebugListener.h"
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
#include <wtf/Vector.h>
-#include <wtf/text/StringHash.h>
namespace Inspector {
+class AsyncStackTrace;
class InjectedScript;
class InjectedScriptManager;
class InspectorArray;
class InspectorObject;
-class InspectorValue;
class ScriptDebugServer;
typedef String ErrorString;
-class JS_EXPORT_PRIVATE InspectorDebuggerAgent : public InspectorAgentBase, public ScriptDebugListener, public InspectorDebuggerBackendDispatcherHandler {
+class JS_EXPORT_PRIVATE InspectorDebuggerAgent : public InspectorAgentBase, public ScriptDebugListener, public DebuggerBackendDispatcherHandler {
WTF_MAKE_NONCOPYABLE(InspectorDebuggerAgent);
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -65,35 +60,48 @@ public:
virtual ~InspectorDebuggerAgent();
- virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) override;
- virtual void willDestroyFrontendAndBackend(InspectorDisconnectReason) override;
-
- virtual void enable(ErrorString*) override;
- virtual void disable(ErrorString*) override;
- virtual void setBreakpointsActive(ErrorString*, bool active) override;
- virtual void setBreakpointByUrl(ErrorString*, int lineNumber, const String* optionalURL, const String* optionalURLRegex, const int* optionalColumnNumber, const RefPtr<Inspector::InspectorObject>* options, Inspector::TypeBuilder::Debugger::BreakpointId*, RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Debugger::Location>>& locations, RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Debugger::BreakpointActionIdentifier>>& breakpointActionIdentifiers) override;
- virtual void setBreakpoint(ErrorString*, const RefPtr<Inspector::InspectorObject>& location, const RefPtr<Inspector::InspectorObject>* options, Inspector::TypeBuilder::Debugger::BreakpointId*, RefPtr<Inspector::TypeBuilder::Debugger::Location>& actualLocation, RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Debugger::BreakpointActionIdentifier>>& breakpointActionIdentifiers) override;
- virtual void removeBreakpoint(ErrorString*, const String& breakpointIdentifier) override;
- virtual void continueToLocation(ErrorString*, const RefPtr<InspectorObject>& location) override;
- virtual void searchInContent(ErrorString*, const String& scriptID, const String& query, const bool* optionalCaseSensitive, const bool* optionalIsRegex, RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::GenericTypes::SearchMatch>>&) override;
- virtual void getScriptSource(ErrorString*, const String& scriptID, String* scriptSource) override;
- virtual void getFunctionDetails(ErrorString*, const String& functionId, RefPtr<Inspector::TypeBuilder::Debugger::FunctionDetails>&) override;
- virtual void pause(ErrorString*) override;
- virtual void resume(ErrorString*) override;
- virtual void stepOver(ErrorString*) override;
- virtual void stepInto(ErrorString*) override;
- virtual void stepOut(ErrorString*) override;
- virtual void setPauseOnExceptions(ErrorString*, const String& pauseState) override;
- virtual void evaluateOnCallFrame(ErrorString*, const String& callFrameId, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, RefPtr<Inspector::TypeBuilder::Runtime::RemoteObject>& result, Inspector::TypeBuilder::OptOutput<bool>* wasThrown) override;
- virtual void setOverlayMessage(ErrorString*, const String*) override;
-
- bool isPaused();
-
- void handleConsoleAssert();
-
- void schedulePauseOnNextStatement(InspectorDebuggerFrontendDispatcher::Reason::Enum breakReason, PassRefPtr<InspectorObject> data);
+ void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) final;
+ void willDestroyFrontendAndBackend(DisconnectReason) final;
+
+ void enable(ErrorString&) final;
+ void disable(ErrorString&) final;
+ void setAsyncStackTraceDepth(ErrorString&, int depth) final;
+ void setBreakpointsActive(ErrorString&, bool active) final;
+ void setBreakpointByUrl(ErrorString&, int lineNumber, const String* const optionalURL, const String* const optionalURLRegex, const int* const optionalColumnNumber, const Inspector::InspectorObject* options, Inspector::Protocol::Debugger::BreakpointId*, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Debugger::Location>>& locations) final;
+ void setBreakpoint(ErrorString&, const Inspector::InspectorObject& location, const Inspector::InspectorObject* options, Inspector::Protocol::Debugger::BreakpointId*, RefPtr<Inspector::Protocol::Debugger::Location>& actualLocation) final;
+ void removeBreakpoint(ErrorString&, const String& breakpointIdentifier) final;
+ void continueUntilNextRunLoop(ErrorString&) final;
+ void continueToLocation(ErrorString&, const InspectorObject& location) final;
+ void searchInContent(ErrorString&, const String& scriptID, const String& query, const bool* const optionalCaseSensitive, const bool* const optionalIsRegex, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::GenericTypes::SearchMatch>>&) final;
+ void getScriptSource(ErrorString&, const String& scriptID, String* scriptSource) final;
+ void getFunctionDetails(ErrorString&, const String& functionId, RefPtr<Inspector::Protocol::Debugger::FunctionDetails>&) final;
+ void pause(ErrorString&) final;
+ void resume(ErrorString&) final;
+ void stepOver(ErrorString&) final;
+ void stepInto(ErrorString&) final;
+ void stepOut(ErrorString&) final;
+ void setPauseOnExceptions(ErrorString&, const String& pauseState) final;
+ void setPauseOnAssertions(ErrorString&, bool enabled) final;
+ void evaluateOnCallFrame(ErrorString&, const String& callFrameId, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, const bool* const generatePreview, const bool* const saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex) final;
+ void setOverlayMessage(ErrorString&, const String* const) override;
+
+ bool isPaused() const;
+ bool breakpointsActive() const;
+
+ void setSuppressAllPauses(bool);
+
+ void handleConsoleAssert(const String& message);
+
+ void didScheduleAsyncCall(JSC::ExecState*, int asyncCallType, int callbackIdentifier, bool singleShot);
+ void didCancelAsyncCall(int asyncCallType, int callbackIdentifier);
+ void willDispatchAsyncCall(int asyncCallType, int callbackIdentifier);
+ void didDispatchAsyncCall();
+
+ void schedulePauseOnNextStatement(DebuggerFrontendDispatcher::Reason breakReason, RefPtr<InspectorObject>&& data);
void cancelPauseOnNextStatement();
- void breakProgram(InspectorDebuggerFrontendDispatcher::Reason::Enum breakReason, PassRefPtr<InspectorObject> data);
+ bool pauseOnNextStatementEnabled() const { return m_javaScriptPauseScheduled; }
+
+ void breakProgram(DebuggerFrontendDispatcher::Reason breakReason, RefPtr<InspectorObject>&& data);
void scriptExecutionBlockedByCSP(const String& directiveText);
class Listener {
@@ -101,73 +109,91 @@ public:
virtual ~Listener() { }
virtual void debuggerWasEnabled() = 0;
virtual void debuggerWasDisabled() = 0;
- virtual void stepInto() = 0;
- virtual void didPause() = 0;
};
void setListener(Listener* listener) { m_listener = listener; }
- virtual ScriptDebugServer& scriptDebugServer() = 0;
-
protected:
- InspectorDebuggerAgent(InjectedScriptManager*);
+ InspectorDebuggerAgent(AgentContext&);
- InjectedScriptManager* injectedScriptManager() const { return m_injectedScriptManager; }
- virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId) = 0;
+ InjectedScriptManager& injectedScriptManager() const { return m_injectedScriptManager; }
+ virtual InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) = 0;
+
+ ScriptDebugServer& scriptDebugServer() { return m_scriptDebugServer; }
- virtual void startListeningScriptDebugServer() = 0;
- virtual void stopListeningScriptDebugServer(bool skipRecompile) = 0;
virtual void muteConsole() = 0;
virtual void unmuteConsole() = 0;
virtual void enable();
virtual void disable(bool skipRecompile);
- virtual void didPause(JSC::ExecState*, const Deprecated::ScriptValue& callFrames, const Deprecated::ScriptValue& exception) override;
- virtual void didContinue() override;
+ void didPause(JSC::ExecState&, JSC::JSValue callFrames, JSC::JSValue exceptionOrCaughtValue) final;
+ void didContinue() final;
virtual String sourceMapURLForScript(const Script&);
void didClearGlobalObject();
private:
- PassRefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Debugger::CallFrame>> currentCallFrames();
+ Ref<Inspector::Protocol::Array<Inspector::Protocol::Debugger::CallFrame>> currentCallFrames(const InjectedScript&);
+
+ void didParseSource(JSC::SourceID, const Script&) final;
+ void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage) final;
- virtual void didParseSource(JSC::SourceID, const Script&) override final;
- virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage) override final;
- virtual void didSampleProbe(JSC::ExecState*, int probeIdentifier, int hitCount, const Deprecated::ScriptValue& sample) override final;
+ void breakpointActionSound(int breakpointActionIdentifier) final;
+ void breakpointActionProbe(JSC::ExecState&, const ScriptBreakpointAction&, unsigned batchId, unsigned sampleId, JSC::JSValue sample) final;
- virtual void breakpointActionSound() override;
+ void resolveBreakpoint(const Script&, JSC::Breakpoint&);
+ void setBreakpoint(JSC::Breakpoint&, bool& existing);
+ void didSetBreakpoint(const JSC::Breakpoint&, const String&, const ScriptBreakpoint&);
- PassRefPtr<Inspector::TypeBuilder::Debugger::Location> resolveBreakpoint(const String& breakpointIdentifier, JSC::SourceID, const ScriptBreakpoint&);
- bool assertPaused(ErrorString*);
- void clearResolvedBreakpointState();
+ bool assertPaused(ErrorString&);
+ void clearDebuggerBreakpointState();
+ void clearInspectorBreakpointState();
void clearBreakDetails();
+ void clearExceptionValue();
+ void clearAsyncStackTraceData();
+
+ enum class ShouldDispatchResumed { No, WhenIdle, WhenContinued };
+ void registerIdleHandler();
+ void willStepAndMayBecomeIdle();
+ void didBecomeIdle();
- bool breakpointActionsFromProtocol(ErrorString*, RefPtr<InspectorArray>& actions, Vector<ScriptBreakpointAction>* result);
+ RefPtr<InspectorObject> buildBreakpointPauseReason(JSC::BreakpointID);
+ RefPtr<InspectorObject> buildExceptionPauseReason(JSC::JSValue exception, const InjectedScript&);
+
+ bool breakpointActionsFromProtocol(ErrorString&, RefPtr<InspectorArray>& actions, BreakpointActions* result);
+
+ typedef std::pair<int, int> AsyncCallIdentifier;
typedef HashMap<JSC::SourceID, Script> ScriptsMap;
typedef HashMap<String, Vector<JSC::BreakpointID>> BreakpointIdentifierToDebugServerBreakpointIDsMap;
typedef HashMap<String, RefPtr<InspectorObject>> BreakpointIdentifierToBreakpointMap;
-
- InjectedScriptManager* m_injectedScriptManager;
- std::unique_ptr<InspectorDebuggerFrontendDispatcher> m_frontendDispatcher;
- RefPtr<InspectorDebuggerBackendDispatcher> m_backendDispatcher;
- Listener* m_listener;
- JSC::ExecState* m_pausedScriptState;
+ typedef HashMap<JSC::BreakpointID, String> DebugServerBreakpointIDToBreakpointIdentifier;
+
+ InjectedScriptManager& m_injectedScriptManager;
+ std::unique_ptr<DebuggerFrontendDispatcher> m_frontendDispatcher;
+ RefPtr<DebuggerBackendDispatcher> m_backendDispatcher;
+ ScriptDebugServer& m_scriptDebugServer;
+ Listener* m_listener { nullptr };
+ JSC::ExecState* m_pausedScriptState { nullptr };
Deprecated::ScriptValue m_currentCallStack;
ScriptsMap m_scripts;
BreakpointIdentifierToDebugServerBreakpointIDsMap m_breakpointIdentifierToDebugServerBreakpointIDs;
BreakpointIdentifierToBreakpointMap m_javaScriptBreakpoints;
+ DebugServerBreakpointIDToBreakpointIdentifier m_debuggerBreakpointIdentifierToInspectorBreakpointIdentifier;
JSC::BreakpointID m_continueToLocationBreakpointID;
- InspectorDebuggerFrontendDispatcher::Reason::Enum m_breakReason;
+ DebuggerFrontendDispatcher::Reason m_breakReason;
RefPtr<InspectorObject> m_breakAuxData;
- bool m_enabled;
- bool m_javaScriptPauseScheduled;
- int m_nextProbeSampleId;
- int m_nextBreakpointActionIdentifier;
+ ShouldDispatchResumed m_conditionToDispatchResumed { ShouldDispatchResumed::No };
+ bool m_enablePauseWhenIdle { false };
+ HashMap<AsyncCallIdentifier, RefPtr<AsyncStackTrace>> m_pendingAsyncCalls;
+ std::optional<AsyncCallIdentifier> m_currentAsyncCallIdentifier { std::nullopt };
+ bool m_enabled { false };
+ bool m_javaScriptPauseScheduled { false };
+ bool m_hasExceptionValue { false };
+ bool m_didPauseStopwatch { false };
+ bool m_pauseOnAssertionFailures { false };
+ bool m_registeredIdleCallback { false };
+ int m_asyncStackTraceDepth { 0 };
};
} // namespace Inspector
-
-#endif // ENABLE(INSPECTOR)
-
-#endif // !defined(InspectorDebuggerAgent_h)