OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8Debugger_h |
| 6 #define V8Debugger_h |
| 7 |
| 8 #include "platform/inspector_protocol/Allocator.h" |
| 9 #include "platform/inspector_protocol/Maybe.h" |
| 10 #include "platform/inspector_protocol/Platform.h" |
| 11 #include "platform/v8_inspector/JavaScriptCallFrame.h" |
| 12 #include "platform/v8_inspector/V8DebuggerScript.h" |
| 13 #include "platform/v8_inspector/protocol/Runtime.h" |
| 14 #include "platform/v8_inspector/public/V8ContextInfo.h" |
| 15 |
| 16 #include <v8-debug.h> |
| 17 #include <v8.h> |
| 18 #include <vector> |
| 19 |
| 20 namespace blink { |
| 21 |
| 22 struct ScriptBreakpoint; |
| 23 class V8DebuggerAgentImpl; |
| 24 class V8InspectorImpl; |
| 25 class V8StackTraceImpl; |
| 26 |
| 27 class V8Debugger { |
| 28 PROTOCOL_DISALLOW_COPY(V8Debugger); |
| 29 public: |
| 30 V8Debugger(v8::Isolate*, V8InspectorImpl*); |
| 31 ~V8Debugger(); |
| 32 |
| 33 static int contextId(v8::Local<v8::Context>); |
| 34 static int getGroupId(v8::Local<v8::Context>); |
| 35 int markContext(const V8ContextInfo&); |
| 36 |
| 37 bool enabled() const; |
| 38 |
| 39 String16 setBreakpoint(const String16& sourceID, const ScriptBreakpoint&, in
t* actualLineNumber, int* actualColumnNumber, bool interstatementLocation); |
| 40 void removeBreakpoint(const String16& breakpointId); |
| 41 void setBreakpointsActivated(bool); |
| 42 bool breakpointsActivated() const { return m_breakpointsActivated; } |
| 43 |
| 44 enum PauseOnExceptionsState { |
| 45 DontPauseOnExceptions, |
| 46 PauseOnAllExceptions, |
| 47 PauseOnUncaughtExceptions |
| 48 }; |
| 49 PauseOnExceptionsState getPauseOnExceptionsState(); |
| 50 void setPauseOnExceptionsState(PauseOnExceptionsState); |
| 51 void setPauseOnNextStatement(bool); |
| 52 bool canBreakProgram(); |
| 53 void breakProgram(); |
| 54 void continueProgram(); |
| 55 void stepIntoStatement(); |
| 56 void stepOverStatement(); |
| 57 void stepOutOfFunction(); |
| 58 void clearStepping(); |
| 59 |
| 60 bool setScriptSource(const String16& sourceID, v8::Local<v8::String> newSour
ce, bool preview, ErrorString*, protocol::Maybe<protocol::Runtime::ExceptionDeta
ils>*, JavaScriptCallFrames* newCallFrames, protocol::Maybe<bool>* stackChanged)
; |
| 61 JavaScriptCallFrames currentCallFrames(int limit = 0); |
| 62 |
| 63 // Each script inherits debug data from v8::Context where it has been compil
ed. |
| 64 // Only scripts whose debug data matches |contextGroupId| will be reported. |
| 65 // Passing 0 will result in reporting all scripts. |
| 66 void getCompiledScripts(int contextGroupId, std::vector<std::unique_ptr<V8De
buggerScript>>&); |
| 67 void enable(); |
| 68 void disable(); |
| 69 |
| 70 bool isPaused(); |
| 71 v8::Local<v8::Context> pausedContext() { return m_pausedContext; } |
| 72 |
| 73 int maxAsyncCallChainDepth() { return m_maxAsyncCallStackDepth; } |
| 74 V8StackTraceImpl* currentAsyncCallChain(); |
| 75 void setAsyncCallStackDepth(V8DebuggerAgentImpl*, int); |
| 76 std::unique_ptr<V8StackTraceImpl> createStackTrace(v8::Local<v8::StackTrace>
); |
| 77 std::unique_ptr<V8StackTraceImpl> captureStackTrace(bool fullStack); |
| 78 |
| 79 v8::MaybeLocal<v8::Value> functionScopes(v8::Local<v8::Function>); |
| 80 v8::MaybeLocal<v8::Array> internalProperties(v8::Local<v8::Context>, v8::Loc
al<v8::Value>); |
| 81 |
| 82 void asyncTaskScheduled(const String16& taskName, void* task, bool recurring
); |
| 83 void asyncTaskCanceled(void* task); |
| 84 void asyncTaskStarted(void* task); |
| 85 void asyncTaskFinished(void* task); |
| 86 void allAsyncTasksCanceled(); |
| 87 |
| 88 private: |
| 89 void compileDebuggerScript(); |
| 90 v8::MaybeLocal<v8::Value> callDebuggerMethod(const char* functionName, int a
rgc, v8::Local<v8::Value> argv[]); |
| 91 v8::Local<v8::Context> debuggerContext() const; |
| 92 void clearBreakpoints(); |
| 93 |
| 94 static void breakProgramCallback(const v8::FunctionCallbackInfo<v8::Value>&)
; |
| 95 void handleProgramBreak(v8::Local<v8::Context> pausedContext, v8::Local<v8::
Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8::Array> hit
Breakpoints, bool isPromiseRejection = false); |
| 96 static void v8DebugEventCallback(const v8::Debug::EventDetails&); |
| 97 v8::Local<v8::Value> callInternalGetterFunction(v8::Local<v8::Object>, const
char* functionName); |
| 98 void handleV8DebugEvent(const v8::Debug::EventDetails&); |
| 99 void handleV8AsyncTaskEvent(v8::Local<v8::Context>, v8::Local<v8::Object> ex
ecutionState, v8::Local<v8::Object> eventData); |
| 100 |
| 101 v8::Local<v8::Value> collectionEntries(v8::Local<v8::Context>, v8::Local<v8:
:Object>); |
| 102 v8::Local<v8::Value> generatorObjectLocation(v8::Local<v8::Object>); |
| 103 v8::Local<v8::Value> functionLocation(v8::Local<v8::Context>, v8::Local<v8::
Function>); |
| 104 |
| 105 v8::Isolate* m_isolate; |
| 106 V8InspectorImpl* m_inspector; |
| 107 int m_lastContextId; |
| 108 int m_enableCount; |
| 109 bool m_breakpointsActivated; |
| 110 v8::Global<v8::Object> m_debuggerScript; |
| 111 v8::Global<v8::Context> m_debuggerContext; |
| 112 v8::Local<v8::Object> m_executionState; |
| 113 v8::Local<v8::Context> m_pausedContext; |
| 114 bool m_runningNestedMessageLoop; |
| 115 |
| 116 using AsyncTaskToStackTrace = protocol::HashMap<void*, std::unique_ptr<V8Sta
ckTraceImpl>>; |
| 117 AsyncTaskToStackTrace m_asyncTaskStacks; |
| 118 protocol::HashSet<void*> m_recurringTasks; |
| 119 int m_maxAsyncCallStackDepth; |
| 120 std::vector<void*> m_currentTasks; |
| 121 std::vector<std::unique_ptr<V8StackTraceImpl>> m_currentStacks; |
| 122 protocol::HashMap<V8DebuggerAgentImpl*, int> m_maxAsyncCallStackDepthMap; |
| 123 }; |
| 124 |
| 125 } // namespace blink |
| 126 |
| 127 #endif // V8Debugger_h |
OLD | NEW |