LCOV - code coverage report
Current view: top level - src/objects - debug-objects.h (source / functions) Hit Total Coverage
Test: app.info Lines: 2 2 100.0 %
Date: 2017-10-20 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_OBJECTS_DEBUG_OBJECTS_H_
       6             : #define V8_OBJECTS_DEBUG_OBJECTS_H_
       7             : 
       8             : #include "src/objects.h"
       9             : 
      10             : // Has to be the last include (doesn't have include guards):
      11             : #include "src/objects/object-macros.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : class BytecodeArray;
      17             : 
      18             : // The DebugInfo class holds additional information for a function being
      19             : // debugged.
      20             : class DebugInfo : public Struct {
      21             :  public:
      22             :   enum Flag {
      23             :     kNone = 0,
      24             :     kHasBreakInfo = 1 << 0,
      25             :     kPreparedForBreakpoints = 1 << 1,
      26             :     kHasCoverageInfo = 2 << 1,
      27             :   };
      28             :   typedef base::Flags<Flag> Flags;
      29             : 
      30             :   // A bitfield that lists uses of the current instance.
      31             :   DECL_INT_ACCESSORS(flags)
      32             : 
      33             :   // The shared function info for the source being debugged.
      34             :   DECL_ACCESSORS(shared, SharedFunctionInfo)
      35             : 
      36             :   // Bit field containing various information collected for debugging.
      37             :   DECL_INT_ACCESSORS(debugger_hints)
      38             : 
      39             :   // DebugInfo can be detached from the SharedFunctionInfo iff it is empty.
      40             :   bool IsEmpty() const;
      41             : 
      42             :   // --- Break points ---
      43             :   // --------------------
      44             : 
      45             :   bool HasBreakInfo() const;
      46             : 
      47             :   bool IsPreparedForBreakpoints() const;
      48             : 
      49             :   // Clears all fields related to break points. Returns true iff the
      50             :   // DebugInfo is now empty.
      51             :   bool ClearBreakInfo();
      52             : 
      53             :   // The instrumented bytecode array for functions with break points.
      54             :   DECL_ACCESSORS(debug_bytecode_array, Object)
      55             : 
      56             :   // Fixed array holding status information for each active break point.
      57             :   DECL_ACCESSORS(break_points, FixedArray)
      58             : 
      59             :   // Check if there is a break point at a source position.
      60             :   bool HasBreakPoint(int source_position);
      61             :   // Attempt to clear a break point. Return true if successful.
      62             :   static bool ClearBreakPoint(Handle<DebugInfo> debug_info,
      63             :                               Handle<Object> break_point_object);
      64             :   // Set a break point.
      65             :   static void SetBreakPoint(Handle<DebugInfo> debug_info, int source_position,
      66             :                             Handle<Object> break_point_object);
      67             :   // Get the break point objects for a source position.
      68             :   Handle<Object> GetBreakPointObjects(int source_position);
      69             :   // Find the break point info holding this break point object.
      70             :   static Handle<Object> FindBreakPointInfo(Handle<DebugInfo> debug_info,
      71             :                                            Handle<Object> break_point_object);
      72             :   // Get the number of break points for this function.
      73             :   int GetBreakPointCount();
      74             : 
      75             :   inline bool HasDebugBytecodeArray();
      76             : 
      77             :   inline BytecodeArray* OriginalBytecodeArray();
      78             :   inline BytecodeArray* DebugBytecodeArray();
      79             : 
      80             :   // --- Block Coverage ---
      81             :   // ----------------------
      82             : 
      83             :   bool HasCoverageInfo() const;
      84             : 
      85             :   // Clears all fields related to block coverage. Returns true iff the
      86             :   // DebugInfo is now empty.
      87             :   bool ClearCoverageInfo();
      88             :   DECL_ACCESSORS(coverage_info, Object)
      89             : 
      90             :   DECL_CAST(DebugInfo)
      91             : 
      92             :   // Dispatched behavior.
      93             :   DECL_PRINTER(DebugInfo)
      94             :   DECL_VERIFIER(DebugInfo)
      95             : 
      96             :   static const int kSharedFunctionInfoOffset = Struct::kHeaderSize;
      97             :   static const int kDebuggerHintsOffset =
      98             :       kSharedFunctionInfoOffset + kPointerSize;
      99             :   static const int kDebugBytecodeArrayOffset =
     100             :       kDebuggerHintsOffset + kPointerSize;
     101             :   static const int kBreakPointsStateOffset =
     102             :       kDebugBytecodeArrayOffset + kPointerSize;
     103             :   static const int kFlagsOffset = kBreakPointsStateOffset + kPointerSize;
     104             :   static const int kCoverageInfoOffset = kFlagsOffset + kPointerSize;
     105             :   static const int kSize = kCoverageInfoOffset + kPointerSize;
     106             : 
     107             :   static const int kEstimatedNofBreakPointsInFunction = 4;
     108             : 
     109             :  private:
     110             :   // Get the break point info object for a source position.
     111             :   Object* GetBreakPointInfo(int source_position);
     112             : 
     113             :   DISALLOW_IMPLICIT_CONSTRUCTORS(DebugInfo);
     114             : };
     115             : 
     116             : // The BreakPointInfo class holds information for break points set in a
     117             : // function. The DebugInfo object holds a BreakPointInfo object for each code
     118             : // position with one or more break points.
     119             : class BreakPointInfo : public Tuple2 {
     120             :  public:
     121             :   // The position in the source for the break position.
     122             :   DECL_INT_ACCESSORS(source_position)
     123             :   // List of related JavaScript break points.
     124             :   DECL_ACCESSORS(break_point_objects, Object)
     125             : 
     126             :   // Removes a break point.
     127             :   static void ClearBreakPoint(Handle<BreakPointInfo> info,
     128             :                               Handle<Object> break_point_object);
     129             :   // Set a break point.
     130             :   static void SetBreakPoint(Handle<BreakPointInfo> info,
     131             :                             Handle<Object> break_point_object);
     132             :   // Check if break point info has this break point object.
     133             :   static bool HasBreakPointObject(Handle<BreakPointInfo> info,
     134             :                                   Handle<Object> break_point_object);
     135             :   // Get the number of break points for this code offset.
     136             :   int GetBreakPointCount();
     137             : 
     138             :   int GetStatementPosition(Handle<DebugInfo> debug_info);
     139             : 
     140             :   DECL_CAST(BreakPointInfo)
     141             : 
     142             :   static const int kSourcePositionOffset = kValue1Offset;
     143             :   static const int kBreakPointObjectsOffset = kValue2Offset;
     144             : 
     145             :  private:
     146             :   DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPointInfo);
     147             : };
     148             : 
     149             : // Holds information related to block code coverage.
     150             : class CoverageInfo : public FixedArray {
     151             :  public:
     152             :   int SlotCount() const;
     153             : 
     154             :   int StartSourcePosition(int slot_index) const;
     155             :   int EndSourcePosition(int slot_index) const;
     156             :   int BlockCount(int slot_index) const;
     157             : 
     158             :   void InitializeSlot(int slot_index, int start_pos, int end_pos);
     159             :   void IncrementBlockCount(int slot_index);
     160             :   void ResetBlockCount(int slot_index);
     161             : 
     162             :   static int FixedArrayLengthForSlotCount(int slot_count) {
     163         781 :     return slot_count * kSlotIndexCount + kFirstSlotIndex;
     164             :   }
     165             : 
     166             :   DECL_CAST(CoverageInfo)
     167             : 
     168             :   // Print debug info.
     169             :   void Print(String* function_name);
     170             : 
     171             :  private:
     172             :   static int FirstIndexForSlot(int slot_index) {
     173      605691 :     return kFirstSlotIndex + slot_index * kSlotIndexCount;
     174             :   }
     175             : 
     176             :   static const int kFirstSlotIndex = 0;
     177             : 
     178             :   // Each slot is assigned a group of indices starting at kFirstSlotIndex.
     179             :   // Within this group, semantics are as follows:
     180             :   static const int kSlotStartSourcePositionIndex = 0;
     181             :   static const int kSlotEndSourcePositionIndex = 1;
     182             :   static const int kSlotBlockCountIndex = 2;
     183             :   static const int kSlotIndexCount = 3;
     184             : 
     185             :   DISALLOW_IMPLICIT_CONSTRUCTORS(CoverageInfo);
     186             : };
     187             : 
     188             : // Holds breakpoint related information. This object is used by inspector.
     189             : class BreakPoint : public Tuple2 {
     190             :  public:
     191             :   DECL_INT_ACCESSORS(id)
     192             :   DECL_ACCESSORS(condition, String)
     193             : 
     194             :   DECL_CAST(BreakPoint)
     195             : 
     196             :   static const int kIdOffset = kValue1Offset;
     197             :   static const int kConditionOffset = kValue2Offset;
     198             : 
     199             :  private:
     200             :   DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPoint);
     201             : };
     202             : 
     203             : }  // namespace internal
     204             : }  // namespace v8
     205             : 
     206             : #include "src/objects/object-macros-undef.h"
     207             : 
     208             : #endif  // V8_OBJECTS_DEBUG_OBJECTS_H_

Generated by: LCOV version 1.10