LCOV - code coverage report
Current view: top level - src/inspector - v8-stack-trace-impl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 2 2 100.0 %
Date: 2017-04-26 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright 2016 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_V8STACKTRACEIMPL_H_
       6             : #define V8_INSPECTOR_V8STACKTRACEIMPL_H_
       7             : 
       8             : #include <memory>
       9             : #include <vector>
      10             : 
      11             : #include "include/v8-inspector.h"
      12             : #include "include/v8.h"
      13             : #include "src/base/macros.h"
      14             : #include "src/inspector/protocol/Runtime.h"
      15             : #include "src/inspector/string-16.h"
      16             : 
      17             : namespace v8_inspector {
      18             : 
      19             : class AsyncStackTrace;
      20             : class V8Debugger;
      21             : class WasmTranslation;
      22             : 
      23             : class StackFrame {
      24             :  public:
      25             :   explicit StackFrame(v8::Local<v8::StackFrame> frame);
      26       90262 :   ~StackFrame() = default;
      27             : 
      28             :   void translate(WasmTranslation* wasmTranslation);
      29             : 
      30             :   const String16& functionName() const;
      31             :   const String16& scriptId() const;
      32             :   const String16& sourceURL() const;
      33             :   int lineNumber() const;    // 0-based.
      34             :   int columnNumber() const;  // 0-based.
      35             :   std::unique_ptr<protocol::Runtime::CallFrame> buildInspectorObject() const;
      36             : 
      37             :  private:
      38             :   String16 m_functionName;
      39             :   String16 m_scriptId;
      40             :   String16 m_sourceURL;
      41             :   int m_lineNumber;    // 0-based.
      42             :   int m_columnNumber;  // 0-based.
      43             : };
      44             : 
      45             : class V8StackTraceImpl : public V8StackTrace {
      46             :  public:
      47             :   static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*,
      48             :                                                         bool capture);
      49             :   static const int maxCallStackSizeToCapture = 200;
      50             :   static std::unique_ptr<V8StackTraceImpl> create(V8Debugger*,
      51             :                                                   int contextGroupId,
      52             :                                                   v8::Local<v8::StackTrace>,
      53             :                                                   int maxStackSize);
      54             :   static std::unique_ptr<V8StackTraceImpl> capture(V8Debugger*,
      55             :                                                    int contextGroupId,
      56             :                                                    int maxStackSize);
      57             : 
      58             :   ~V8StackTraceImpl() override;
      59             :   std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectImpl()
      60             :       const;
      61             : 
      62             :   // V8StackTrace implementation.
      63             :   // This method drops the async stack trace.
      64             :   std::unique_ptr<V8StackTrace> clone() override;
      65             :   bool isEmpty() const override;
      66             :   StringView topSourceURL() const override;
      67             :   int topLineNumber() const override;    // 1-based.
      68             :   int topColumnNumber() const override;  // 1-based.
      69             :   StringView topScriptId() const override;
      70             :   StringView topFunctionName() const override;
      71             :   std::unique_ptr<protocol::Runtime::API::StackTrace> buildInspectorObject()
      72             :       const override;
      73             :   std::unique_ptr<StringBuffer> toString() const override;
      74             : 
      75             :  private:
      76             :   V8StackTraceImpl(std::vector<std::shared_ptr<StackFrame>> frames,
      77             :                    int maxAsyncDepth,
      78             :                    std::shared_ptr<AsyncStackTrace> asyncParent,
      79             :                    std::shared_ptr<AsyncStackTrace> asyncCreation);
      80             : 
      81             :   std::vector<std::shared_ptr<StackFrame>> m_frames;
      82             :   int m_maxAsyncDepth;
      83             :   std::weak_ptr<AsyncStackTrace> m_asyncParent;
      84             :   std::weak_ptr<AsyncStackTrace> m_asyncCreation;
      85             : 
      86             :   DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl);
      87             : };
      88             : 
      89       25722 : class AsyncStackTrace {
      90             :  public:
      91             :   static std::shared_ptr<AsyncStackTrace> capture(V8Debugger*,
      92             :                                                   int contextGroupId,
      93             :                                                   const String16& description,
      94             :                                                   int maxStackSize);
      95             : 
      96             :   std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObject(
      97             :       AsyncStackTrace* asyncCreation, int maxAsyncDepth) const;
      98             : 
      99             :   int contextGroupId() const;
     100             :   std::weak_ptr<AsyncStackTrace> parent() const;
     101             :   std::weak_ptr<AsyncStackTrace> creation() const;
     102             :   bool isEmpty() const;
     103             : 
     104             :  private:
     105             :   AsyncStackTrace(int contextGroupId, const String16& description,
     106             :                   std::vector<std::shared_ptr<StackFrame>> frames,
     107             :                   std::shared_ptr<AsyncStackTrace> asyncParent,
     108             :                   std::shared_ptr<AsyncStackTrace> asyncCreation);
     109             : 
     110             :   int m_contextGroupId;
     111             :   String16 m_description;
     112             : 
     113             :   std::vector<std::shared_ptr<StackFrame>> m_frames;
     114             :   std::weak_ptr<AsyncStackTrace> m_asyncParent;
     115             :   std::weak_ptr<AsyncStackTrace> m_asyncCreation;
     116             : 
     117             :   DISALLOW_COPY_AND_ASSIGN(AsyncStackTrace);
     118             : };
     119             : 
     120             : }  // namespace v8_inspector
     121             : 
     122             : #endif  // V8_INSPECTOR_V8STACKTRACEIMPL_H_

Generated by: LCOV version 1.10