LCOV - code coverage report
Current view: top level - src/inspector - v8-debugger-agent-impl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 1 1 100.0 %
Date: 2019-04-19 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright 2015 the V8 project 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 V8_INSPECTOR_V8_DEBUGGER_AGENT_IMPL_H_
       6             : #define V8_INSPECTOR_V8_DEBUGGER_AGENT_IMPL_H_
       7             : 
       8             : #include <deque>
       9             : #include <unordered_map>
      10             : #include <vector>
      11             : 
      12             : #include "src/base/macros.h"
      13             : #include "src/debug/debug-interface.h"
      14             : #include "src/debug/interface-types.h"
      15             : #include "src/inspector/protocol/Debugger.h"
      16             : #include "src/inspector/protocol/Forward.h"
      17             : 
      18             : namespace v8_inspector {
      19             : 
      20             : struct ScriptBreakpoint;
      21             : class V8Debugger;
      22             : class V8DebuggerScript;
      23             : class V8InspectorImpl;
      24             : class V8InspectorSessionImpl;
      25             : class V8Regex;
      26             : 
      27             : using protocol::Maybe;
      28             : using protocol::Response;
      29             : 
      30       15516 : class V8DebuggerAgentImpl : public protocol::Debugger::Backend {
      31             :  public:
      32             :   enum BreakpointSource {
      33             :     UserBreakpointSource,
      34             :     DebugCommandBreakpointSource,
      35             :     MonitorCommandBreakpointSource
      36             :   };
      37             : 
      38             :   V8DebuggerAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*,
      39             :                       protocol::DictionaryValue* state);
      40             :   ~V8DebuggerAgentImpl() override;
      41             :   void restore();
      42             : 
      43             :   // Part of the protocol.
      44             :   Response enable(Maybe<double> maxScriptsCacheSize,
      45             :                   String16* outDebuggerId) override;
      46             :   Response disable() override;
      47             :   Response setBreakpointsActive(bool active) override;
      48             :   Response setSkipAllPauses(bool skip) override;
      49             :   Response setBreakpointByUrl(
      50             :       int lineNumber, Maybe<String16> optionalURL,
      51             :       Maybe<String16> optionalURLRegex, Maybe<String16> optionalScriptHash,
      52             :       Maybe<int> optionalColumnNumber, Maybe<String16> optionalCondition,
      53             :       String16*,
      54             :       std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations)
      55             :       override;
      56             :   Response setBreakpoint(
      57             :       std::unique_ptr<protocol::Debugger::Location>,
      58             :       Maybe<String16> optionalCondition, String16*,
      59             :       std::unique_ptr<protocol::Debugger::Location>* actualLocation) override;
      60             :   Response setBreakpointOnFunctionCall(const String16& functionObjectId,
      61             :                                        Maybe<String16> optionalCondition,
      62             :                                        String16* outBreakpointId) override;
      63             :   Response removeBreakpoint(const String16& breakpointId) override;
      64             :   Response continueToLocation(std::unique_ptr<protocol::Debugger::Location>,
      65             :                               Maybe<String16> targetCallFrames) override;
      66             :   Response getStackTrace(
      67             :       std::unique_ptr<protocol::Runtime::StackTraceId> inStackTraceId,
      68             :       std::unique_ptr<protocol::Runtime::StackTrace>* outStackTrace) override;
      69             :   Response searchInContent(
      70             :       const String16& scriptId, const String16& query,
      71             :       Maybe<bool> optionalCaseSensitive, Maybe<bool> optionalIsRegex,
      72             :       std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>>*)
      73             :       override;
      74             :   Response getPossibleBreakpoints(
      75             :       std::unique_ptr<protocol::Debugger::Location> start,
      76             :       Maybe<protocol::Debugger::Location> end, Maybe<bool> restrictToFunction,
      77             :       std::unique_ptr<protocol::Array<protocol::Debugger::BreakLocation>>*
      78             :           locations) override;
      79             :   Response setScriptSource(
      80             :       const String16& inScriptId, const String16& inScriptSource,
      81             :       Maybe<bool> dryRun,
      82             :       Maybe<protocol::Array<protocol::Debugger::CallFrame>>* optOutCallFrames,
      83             :       Maybe<bool>* optOutStackChanged,
      84             :       Maybe<protocol::Runtime::StackTrace>* optOutAsyncStackTrace,
      85             :       Maybe<protocol::Runtime::StackTraceId>* optOutAsyncStackTraceId,
      86             :       Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) override;
      87             :   Response restartFrame(
      88             :       const String16& callFrameId,
      89             :       std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>>*
      90             :           newCallFrames,
      91             :       Maybe<protocol::Runtime::StackTrace>* asyncStackTrace,
      92             :       Maybe<protocol::Runtime::StackTraceId>* asyncStackTraceId) override;
      93             :   Response getScriptSource(const String16& scriptId,
      94             :                            String16* scriptSource) override;
      95             :   Response pause() override;
      96             :   Response resume() override;
      97             :   Response stepOver() override;
      98             :   Response stepInto(Maybe<bool> inBreakOnAsyncCall) override;
      99             :   Response stepOut() override;
     100             :   Response pauseOnAsyncCall(std::unique_ptr<protocol::Runtime::StackTraceId>
     101             :                                 inParentStackTraceId) override;
     102             :   Response setPauseOnExceptions(const String16& pauseState) override;
     103             :   Response evaluateOnCallFrame(
     104             :       const String16& callFrameId, const String16& expression,
     105             :       Maybe<String16> objectGroup, Maybe<bool> includeCommandLineAPI,
     106             :       Maybe<bool> silent, Maybe<bool> returnByValue,
     107             :       Maybe<bool> generatePreview, Maybe<bool> throwOnSideEffect,
     108             :       Maybe<double> timeout,
     109             :       std::unique_ptr<protocol::Runtime::RemoteObject>* result,
     110             :       Maybe<protocol::Runtime::ExceptionDetails>*) override;
     111             :   Response setVariableValue(
     112             :       int scopeNumber, const String16& variableName,
     113             :       std::unique_ptr<protocol::Runtime::CallArgument> newValue,
     114             :       const String16& callFrame) override;
     115             :   Response setReturnValue(
     116             :       std::unique_ptr<protocol::Runtime::CallArgument> newValue) override;
     117             :   Response setAsyncCallStackDepth(int depth) override;
     118             :   Response setBlackboxPatterns(
     119             :       std::unique_ptr<protocol::Array<String16>> patterns) override;
     120             :   Response setBlackboxedRanges(
     121             :       const String16& scriptId,
     122             :       std::unique_ptr<protocol::Array<protocol::Debugger::ScriptPosition>>
     123             :           positions) override;
     124             : 
     125             :   bool enabled() const { return m_enabled; }
     126             : 
     127             :   void setBreakpointFor(v8::Local<v8::Function> function,
     128             :                         v8::Local<v8::String> condition,
     129             :                         BreakpointSource source);
     130             :   void removeBreakpointFor(v8::Local<v8::Function> function,
     131             :                            BreakpointSource source);
     132             :   void schedulePauseOnNextStatement(
     133             :       const String16& breakReason,
     134             :       std::unique_ptr<protocol::DictionaryValue> data);
     135             :   void cancelPauseOnNextStatement();
     136             :   void breakProgram(const String16& breakReason,
     137             :                     std::unique_ptr<protocol::DictionaryValue> data);
     138             : 
     139             :   void reset();
     140             : 
     141             :   // Interface for V8InspectorImpl
     142             :   void didPause(int contextId, v8::Local<v8::Value> exception,
     143             :                 const std::vector<v8::debug::BreakpointId>& hitBreakpoints,
     144             :                 v8::debug::ExceptionType exceptionType, bool isUncaught,
     145             :                 bool isOOMBreak, bool isAssert);
     146             :   void didContinue();
     147             :   void didParseSource(std::unique_ptr<V8DebuggerScript>, bool success);
     148             : 
     149             :   bool isFunctionBlackboxed(const String16& scriptId,
     150             :                             const v8::debug::Location& start,
     151             :                             const v8::debug::Location& end);
     152             : 
     153             :   bool acceptsPause(bool isOOMBreak) const;
     154             : 
     155             :   void ScriptCollected(const V8DebuggerScript* script);
     156             : 
     157             :   v8::Isolate* isolate() { return m_isolate; }
     158             : 
     159             :  private:
     160             :   void enableImpl();
     161             : 
     162             :   Response currentCallFrames(
     163             :       std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>>*);
     164             :   std::unique_ptr<protocol::Runtime::StackTrace> currentAsyncStackTrace();
     165             :   std::unique_ptr<protocol::Runtime::StackTraceId> currentExternalStackTrace();
     166             :   std::unique_ptr<protocol::Runtime::StackTraceId> currentScheduledAsyncCall();
     167             : 
     168             :   void setPauseOnExceptionsImpl(int);
     169             : 
     170             :   std::unique_ptr<protocol::Debugger::Location> setBreakpointImpl(
     171             :       const String16& breakpointId, const String16& scriptId,
     172             :       const String16& condition, int lineNumber, int columnNumber);
     173             :   void setBreakpointImpl(const String16& breakpointId,
     174             :                          v8::Local<v8::Function> function,
     175             :                          v8::Local<v8::String> condition);
     176             :   void removeBreakpointImpl(const String16& breakpointId);
     177             :   void clearBreakDetails();
     178             : 
     179             :   void internalSetAsyncCallStackDepth(int);
     180             :   void increaseCachedSkipStackGeneration();
     181             : 
     182             :   Response setBlackboxPattern(const String16& pattern);
     183             :   void resetBlackboxedStateCache();
     184             : 
     185             :   bool isPaused() const;
     186             : 
     187             :   using ScriptsMap =
     188             :       std::unordered_map<String16, std::unique_ptr<V8DebuggerScript>>;
     189             :   using BreakpointIdToDebuggerBreakpointIdsMap =
     190             :       std::unordered_map<String16, std::vector<v8::debug::BreakpointId>>;
     191             :   using DebuggerBreakpointIdToBreakpointIdMap =
     192             :       std::unordered_map<v8::debug::BreakpointId, String16>;
     193             : 
     194             :   V8InspectorImpl* m_inspector;
     195             :   V8Debugger* m_debugger;
     196             :   V8InspectorSessionImpl* m_session;
     197             :   bool m_enabled;
     198             :   protocol::DictionaryValue* m_state;
     199             :   protocol::Debugger::Frontend m_frontend;
     200             :   v8::Isolate* m_isolate;
     201             :   ScriptsMap m_scripts;
     202             :   BreakpointIdToDebuggerBreakpointIdsMap m_breakpointIdToDebuggerBreakpointIds;
     203             :   DebuggerBreakpointIdToBreakpointIdMap m_debuggerBreakpointIdToBreakpointId;
     204             : 
     205             :   size_t m_maxScriptCacheSize = 0;
     206             :   size_t m_cachedScriptSize = 0;
     207             :   std::deque<String16> m_cachedScriptIds;
     208             : 
     209             :   using BreakReason =
     210             :       std::pair<String16, std::unique_ptr<protocol::DictionaryValue>>;
     211             :   std::vector<BreakReason> m_breakReason;
     212             : 
     213             :   void pushBreakDetails(
     214             :       const String16& breakReason,
     215             :       std::unique_ptr<protocol::DictionaryValue> breakAuxData);
     216             :   void popBreakDetails();
     217             : 
     218             :   bool m_skipAllPauses = false;
     219             :   bool m_breakpointsActive = false;
     220             : 
     221             :   std::unique_ptr<V8Regex> m_blackboxPattern;
     222             :   std::unordered_map<String16, std::vector<std::pair<int, int>>>
     223             :       m_blackboxedPositions;
     224             : 
     225             :   DISALLOW_COPY_AND_ASSIGN(V8DebuggerAgentImpl);
     226             : };
     227             : 
     228             : }  // namespace v8_inspector
     229             : 
     230             : #endif  // V8_INSPECTOR_V8_DEBUGGER_AGENT_IMPL_H_

Generated by: LCOV version 1.10