LCOV - code coverage report
Current view: top level - src/debug - debug-frames.h (source / functions) Hit Total Coverage
Test: app.info Lines: 11 12 91.7 %
Date: 2017-10-20 Functions: 7 8 87.5 %

          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_DEBUG_DEBUG_FRAMES_H_
       6             : #define V8_DEBUG_DEBUG_FRAMES_H_
       7             : 
       8             : #include "src/deoptimizer.h"
       9             : #include "src/frames.h"
      10             : #include "src/isolate.h"
      11             : #include "src/objects.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : // Forward declaration:
      17             : namespace wasm {
      18             : class InterpretedFrame;
      19             : }
      20             : 
      21             : class FrameInspector {
      22             :  public:
      23             :   FrameInspector(StandardFrame* frame, int inlined_frame_index,
      24             :                  Isolate* isolate);
      25             : 
      26             :   ~FrameInspector();
      27             : 
      28             :   int GetParametersCount();
      29       60438 :   Handle<JSFunction> GetFunction() { return function_; }
      30       30219 :   Handle<Script> GetScript() { return script_; }
      31             :   Handle<Object> GetParameter(int index);
      32             :   Handle<Object> GetExpression(int index);
      33       30219 :   int GetSourcePosition() { return source_position_; }
      34       30219 :   bool IsConstructor() { return is_constructor_; }
      35             :   Handle<Object> GetContext();
      36       30219 :   Handle<Object> GetReceiver() { return receiver_; }
      37             : 
      38           0 :   Handle<String> GetFunctionName() { return function_name_; }
      39             : 
      40             :   bool IsWasm();
      41             :   bool IsJavaScript();
      42             : 
      43             :   inline JavaScriptFrame* javascript_frame() {
      44     3627327 :     return frame_->is_arguments_adaptor() ? ArgumentsAdaptorFrame::cast(frame_)
      45     7254654 :                                           : JavaScriptFrame::cast(frame_);
      46             :   }
      47             : 
      48             :   JavaScriptFrame* GetArgumentsFrame() { return javascript_frame(); }
      49             :   void SetArgumentsFrame(StandardFrame* frame);
      50             : 
      51             :   void MaterializeStackLocals(Handle<JSObject> target,
      52             :                               Handle<ScopeInfo> scope_info,
      53             :                               bool materialize_arguments_object = false);
      54             : 
      55             :   void MaterializeStackLocals(Handle<JSObject> target,
      56             :                               Handle<JSFunction> function,
      57             :                               bool materialize_arguments_object = false);
      58             : 
      59             :   void UpdateStackLocalsFromMaterializedObject(Handle<JSObject> object,
      60             :                                                Handle<ScopeInfo> scope_info);
      61             : 
      62             :  private:
      63             :   bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info,
      64             :                                          Handle<String> parameter_name);
      65             : 
      66             :   StandardFrame* frame_;
      67             :   std::unique_ptr<DeoptimizedFrameInfo> deoptimized_frame_;
      68             :   std::unique_ptr<wasm::InterpretedFrame> wasm_interpreted_frame_;
      69             :   Isolate* isolate_;
      70             :   Handle<Script> script_;
      71             :   Handle<Object> receiver_;
      72             :   Handle<JSFunction> function_;
      73             :   Handle<String> function_name_;
      74             :   int source_position_ = -1;
      75             :   bool is_optimized_ = false;
      76             :   bool is_interpreted_ = false;
      77             :   bool has_adapted_arguments_ = false;
      78             :   bool is_constructor_ = false;
      79             : 
      80             :   DISALLOW_COPY_AND_ASSIGN(FrameInspector);
      81             : };
      82             : 
      83             : 
      84             : class DebugFrameHelper : public AllStatic {
      85             :  public:
      86             :   static SaveContext* FindSavedContextForFrame(Isolate* isolate,
      87             :                                                StandardFrame* frame);
      88             :   // Advances the iterator to the frame that matches the index and returns the
      89             :   // inlined frame index, or -1 if not found.  Skips native JS functions.
      90             :   static int FindIndexedNonNativeFrame(StackTraceFrameIterator* it, int index);
      91             : 
      92             :   // Helper functions for wrapping and unwrapping stack frame ids.
      93       30219 :   static Smi* WrapFrameId(StackFrame::Id id) {
      94             :     DCHECK(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4)));
      95       60438 :     return Smi::FromInt(id >> 2);
      96             :   }
      97             : 
      98         170 :   static StackFrame::Id UnwrapFrameId(int wrapped) {
      99         170 :     return static_cast<StackFrame::Id>(wrapped << 2);
     100             :   }
     101             : };
     102             : 
     103             : }  // namespace internal
     104             : }  // namespace v8
     105             : 
     106             : #endif  // V8_DEBUG_DEBUG_FRAMES_H_

Generated by: LCOV version 1.10