diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/debugger/Debugger.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/debugger/Debugger.h')
-rw-r--r-- | Source/JavaScriptCore/debugger/Debugger.h | 123 |
1 files changed, 82 insertions, 41 deletions
diff --git a/Source/JavaScriptCore/debugger/Debugger.h b/Source/JavaScriptCore/debugger/Debugger.h index f7b734f37..3f51bb42d 100644 --- a/Source/JavaScriptCore/debugger/Debugger.h +++ b/Source/JavaScriptCore/debugger/Debugger.h @@ -19,21 +19,23 @@ * */ -#ifndef Debugger_h -#define Debugger_h +#pragma once #include "Breakpoint.h" +#include "CallData.h" #include "DebuggerCallFrame.h" +#include "DebuggerParseData.h" #include "DebuggerPrimitives.h" #include "JSCJSValue.h" #include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/RefPtr.h> -#include <wtf/Vector.h> #include <wtf/text/TextPosition.h> namespace JSC { +class CodeBlock; +class Exception; class ExecState; class JSGlobalObject; class SourceProvider; @@ -43,10 +45,12 @@ typedef ExecState CallFrame; class JS_EXPORT_PRIVATE Debugger { public: - Debugger(bool isInWorkerThread = false); + Debugger(VM&); virtual ~Debugger(); - JSC::DebuggerCallFrame* currentDebuggerCallFrame() const; + VM& vm() { return m_vm; } + + JSC::DebuggerCallFrame& currentDebuggerCallFrame(); bool hasHandlerForExceptionCallback() const { ASSERT(m_reasonForPause == PausedForException); @@ -58,21 +62,25 @@ public: return m_currentException; } - bool needsExceptionCallbacks() const { return m_pauseOnExceptionsState != DontPauseOnExceptions; } + bool needsExceptionCallbacks() const { return m_breakpointsActivated && m_pauseOnExceptionsState != DontPauseOnExceptions; } + bool isInteractivelyDebugging() const { return m_breakpointsActivated; } - void attach(JSGlobalObject*); enum ReasonForDetach { TerminatingDebuggingSession, GlobalObjectIsDestructing }; - virtual void detach(JSGlobalObject*, ReasonForDetach); + void attach(JSGlobalObject*); + void detach(JSGlobalObject*, ReasonForDetach); + bool isAttached(JSGlobalObject*); - BreakpointID setBreakpoint(Breakpoint, unsigned& actualLine, unsigned& actualColumn); + void resolveBreakpoint(Breakpoint&, SourceProvider*); + BreakpointID setBreakpoint(Breakpoint&, bool& existing); void removeBreakpoint(BreakpointID); void clearBreakpoints(); - void setBreakpointsActivated(bool); + void activateBreakpoints() { setBreakpointsActivated(true); } void deactivateBreakpoints() { setBreakpointsActivated(false); } + bool breakpointsActive() const { return m_breakpointsActivated; } enum PauseOnExceptionsState { DontPauseOnExceptions, @@ -82,6 +90,19 @@ public: PauseOnExceptionsState pauseOnExceptionsState() const { return m_pauseOnExceptionsState; } void setPauseOnExceptionsState(PauseOnExceptionsState); + enum ReasonForPause { + NotPaused, + PausedForException, + PausedAtStatement, + PausedAtExpression, + PausedBeforeReturn, + PausedAtEndOfProgram, + PausedForBreakpoint, + PausedForDebuggerStatement, + }; + ReasonForPause reasonForPause() const { return m_reasonForPause; } + BreakpointID pausingBreakpointID() const { return m_pausingBreakpointID; } + void setPauseOnNextStatement(bool); void breakProgram(); void continueProgram(); @@ -89,47 +110,56 @@ public: void stepOverStatement(); void stepOutOfFunction(); - bool isPaused() { return m_isPaused; } + bool isBlacklisted(SourceID) const; + void addToBlacklist(SourceID); + void clearBlacklist(); + + bool isPaused() const { return m_isPaused; } bool isStepping() const { return m_steppingMode == SteppingModeEnabled; } + bool suppressAllPauses() const { return m_suppressAllPauses; } + void setSuppressAllPauses(bool suppress) { m_suppressAllPauses = suppress; } + virtual void sourceParsed(ExecState*, SourceProvider*, int errorLineNumber, const WTF::String& errorMessage) = 0; - void exception(CallFrame*, JSValue exceptionValue, bool hasHandler); + void exception(CallFrame*, JSValue exceptionValue, bool hasCatchHandler); void atStatement(CallFrame*); + void atExpression(CallFrame*); void callEvent(CallFrame*); void returnEvent(CallFrame*); + void unwindEvent(CallFrame*); void willExecuteProgram(CallFrame*); void didExecuteProgram(CallFrame*); void didReachBreakpoint(CallFrame*); - void recompileAllJSFunctions(VM*); + virtual void recompileAllJSFunctions(); void registerCodeBlock(CodeBlock*); -protected: - virtual bool needPauseHandling(JSGlobalObject*) { return false; } - virtual void handleBreakpointHit(const Breakpoint&) { } - virtual void handleExceptionInBreakpointCondition(ExecState*, JSValue exception) const { UNUSED_PARAM(exception); } - - enum ReasonForPause { - NotPaused, - PausedForException, - PausedAtStatement, - PausedAfterCall, - PausedBeforeReturn, - PausedAtStartOfProgram, - PausedAtEndOfProgram, - PausedForBreakpoint + class ProfilingClient { + public: + virtual ~ProfilingClient(); + virtual bool isAlreadyProfiling() const = 0; + virtual double willEvaluateScript() = 0; + virtual void didEvaluateScript(double startTime, ProfilingReason) = 0; }; - virtual void handlePause(ReasonForPause, JSGlobalObject*) { } + void setProfilingClient(ProfilingClient*); + bool hasProfilingClient() const { return m_profilingClient != nullptr; } + bool isAlreadyProfiling() const { return m_profilingClient && m_profilingClient->isAlreadyProfiling(); } + double willEvaluateScript(); + void didEvaluateScript(double startTime, ProfilingReason); + +protected: + virtual void handleBreakpointHit(JSGlobalObject*, const Breakpoint&) { } + virtual void handleExceptionInBreakpointCondition(ExecState*, Exception*) const { } + virtual void handlePause(JSGlobalObject*, ReasonForPause) { } virtual void notifyDoneProcessingDebuggerEvents() { } private: typedef HashMap<BreakpointID, Breakpoint*> BreakpointIDToBreakpointMap; - typedef Vector<Breakpoint> BreakpointsInLine; - typedef HashMap<unsigned, BreakpointsInLine, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>> LineToBreakpointsMap; + typedef HashMap<unsigned, RefPtr<BreakpointsList>, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>> LineToBreakpointsMap; typedef HashMap<SourceID, LineToBreakpointsMap, WTF::IntHash<SourceID>, WTF::UnsignedWithZeroKeyHashTraits<SourceID>> SourceIDToBreakpointsMap; class ClearCodeBlockDebuggerRequestsFunctor; @@ -155,6 +185,8 @@ private: bool hasBreakpoint(SourceID, const TextPosition&, Breakpoint* hitBreakpoint); + DebuggerParseData& debuggerParseData(SourceID, SourceProvider*); + void updateNeedForOpDebugCallbacks(); // These update functions are only needed because our current breakpoints are @@ -162,9 +194,11 @@ private: // that we don't break on the same line more than once. Once we switch to a // bytecode PC key'ed breakpoint, we will not need these anymore and should // be able to remove them. - void updateCallFrame(JSC::CallFrame*); - void updateCallFrameAndPauseIfNeeded(JSC::CallFrame*); + enum CallFrameUpdateAction { AttemptPause, NoPause }; + void updateCallFrame(JSC::CallFrame*, CallFrameUpdateAction); + void updateCallFrameInternal(JSC::CallFrame*); void pauseIfNeeded(JSC::CallFrame*); + void clearNextPauseState(); enum SteppingMode { SteppingModeDisabled, @@ -176,41 +210,48 @@ private: BreakpointDisabled, BreakpointEnabled }; + void setBreakpointsActivated(bool); void toggleBreakpoint(CodeBlock*, Breakpoint&, BreakpointState); void applyBreakpoints(CodeBlock*); void toggleBreakpoint(Breakpoint&, BreakpointState); void clearDebuggerRequests(JSGlobalObject*); + void clearParsedData(); - VM* m_vm; + VM& m_vm; HashSet<JSGlobalObject*> m_globalObjects; + HashMap<SourceID, DebuggerParseData, WTF::IntHash<SourceID>, WTF::UnsignedWithZeroKeyHashTraits<SourceID>> m_parseDataMap; + HashSet<SourceID, WTF::IntHash<SourceID>, WTF::UnsignedWithZeroKeyHashTraits<SourceID>> m_blacklistedScripts; PauseOnExceptionsState m_pauseOnExceptionsState; - bool m_pauseOnNextStatement : 1; + bool m_pauseAtNextOpportunity : 1; + bool m_pauseOnStepOut : 1; + bool m_pastFirstExpressionInStatement : 1; bool m_isPaused : 1; bool m_breakpointsActivated : 1; bool m_hasHandlerForExceptionCallback : 1; - bool m_isInWorkerThread : 1; - SteppingMode m_steppingMode : 1; + bool m_suppressAllPauses : 1; + unsigned m_steppingMode : 1; // SteppingMode ReasonForPause m_reasonForPause; JSValue m_currentException; - CallFrame* m_pauseOnCallFrame; - CallFrame* m_currentCallFrame; + CallFrame* m_pauseOnCallFrame { nullptr }; + CallFrame* m_currentCallFrame { nullptr }; unsigned m_lastExecutedLine; SourceID m_lastExecutedSourceID; BreakpointID m_topBreakpointID; + BreakpointID m_pausingBreakpointID; BreakpointIDToBreakpointMap m_breakpointIDToBreakpoint; SourceIDToBreakpointsMap m_sourceIDToBreakpoints; RefPtr<JSC::DebuggerCallFrame> m_currentDebuggerCallFrame; - friend class DebuggerCallFrameScope; + ProfilingClient* m_profilingClient { nullptr }; + + friend class DebuggerPausedScope; friend class TemporaryPausedState; friend class LLIntOffsetsExtractor; }; } // namespace JSC - -#endif // Debugger_h |