LCOV - code coverage report
Current view: top level - src/debug - debug-coverage.h (source / functions) Hit Total Coverage
Test: app.info Lines: 6 6 100.0 %
Date: 2019-04-18 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2017 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_DEBUG_DEBUG_COVERAGE_H_
       6             : #define V8_DEBUG_DEBUG_COVERAGE_H_
       7             : 
       8             : #include <vector>
       9             : 
      10             : #include "src/debug/debug-interface.h"
      11             : #include "src/handles.h"
      12             : #include "src/objects.h"
      13             : 
      14             : namespace v8 {
      15             : namespace internal {
      16             : 
      17             : // Forward declaration.
      18             : class Isolate;
      19             : 
      20             : struct CoverageBlock {
      21       89935 :   CoverageBlock(int s, int e, uint32_t c) : start(s), end(e), count(c) {}
      22             :   CoverageBlock() : CoverageBlock(kNoSourcePosition, kNoSourcePosition, 0) {}
      23             :   int start;
      24             :   int end;
      25             :   uint32_t count;
      26             : };
      27             : 
      28       48857 : struct CoverageFunction {
      29             :   CoverageFunction(int s, int e, uint32_t c, Handle<String> n)
      30       57396 :       : start(s), end(e), count(c), name(n), has_block_coverage(false) {}
      31             :   int start;
      32             :   int end;
      33             :   uint32_t count;
      34             :   Handle<String> name;
      35             :   // Blocks are sorted by start position, from outer to inner blocks.
      36             :   std::vector<CoverageBlock> blocks;
      37             :   bool has_block_coverage;
      38             : };
      39             : 
      40        7851 : struct CoverageScript {
      41             :   // Initialize top-level function in case it has been garbage-collected.
      42        5891 :   explicit CoverageScript(Handle<Script> s) : script(s) {}
      43             :   Handle<Script> script;
      44             :   // Functions are sorted by start position, from outer to inner function.
      45             :   std::vector<CoverageFunction> functions;
      46             : };
      47             : 
      48         447 : class Coverage : public std::vector<CoverageScript> {
      49             :  public:
      50             :   // Collecting precise coverage only works if the modes kPreciseCount or
      51             :   // kPreciseBinary is selected. The invocation count is reset on collection.
      52             :   // In case of kPreciseCount, an updated count since last collection is
      53             :   // returned. In case of kPreciseBinary, a count of 1 is returned if a
      54             :   // function has been executed for the first time since last collection.
      55             :   static std::unique_ptr<Coverage> CollectPrecise(Isolate* isolate);
      56             :   // Collecting best effort coverage always works, but may be imprecise
      57             :   // depending on selected mode. The invocation count is not reset.
      58             :   static std::unique_ptr<Coverage> CollectBestEffort(Isolate* isolate);
      59             : 
      60             :   // Select code coverage mode.
      61             :   static void SelectMode(Isolate* isolate, debug::CoverageMode mode);
      62             : 
      63             :  private:
      64             :   static std::unique_ptr<Coverage> Collect(
      65             :       Isolate* isolate, v8::debug::CoverageMode collectionMode);
      66             : 
      67             :   Coverage() = default;
      68             : };
      69             : 
      70             : }  // namespace internal
      71             : }  // namespace v8
      72             : 
      73             : #endif  // V8_DEBUG_DEBUG_COVERAGE_H_

Generated by: LCOV version 1.10