debug-frames.h 2.73 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_DEBUG_DEBUG_FRAMES_H_
#define V8_DEBUG_DEBUG_FRAMES_H_

#include "src/deoptimizer.h"
#include "src/frames.h"
#include "src/isolate.h"
#include "src/objects.h"

namespace v8 {
namespace internal {

class FrameInspector {
 public:
18
  FrameInspector(StandardFrame* frame, int inlined_jsframe_index,
19 20 21 22 23
                 Isolate* isolate);

  ~FrameInspector();

  int GetParametersCount();
24 25
  Handle<JSFunction> GetFunction();
  Handle<Script> GetScript();
26 27
  Handle<Object> GetParameter(int index);
  Handle<Object> GetExpression(int index);
28 29
  int GetSourcePosition();
  bool IsConstructor();
30
  Handle<Object> GetContext();
31

32 33 34 35 36 37 38 39
  inline JavaScriptFrame* javascript_frame() {
    return frame_->is_arguments_adaptor() ? ArgumentsAdaptorFrame::cast(frame_)
                                          : JavaScriptFrame::cast(frame_);
  }
  inline WasmFrame* wasm_frame() { return WasmFrame::cast(frame_); }

  JavaScriptFrame* GetArgumentsFrame() { return javascript_frame(); }
  void SetArgumentsFrame(StandardFrame* frame);
40 41 42 43 44 45 46 47 48 49 50 51 52 53

  void MaterializeStackLocals(Handle<JSObject> target,
                              Handle<ScopeInfo> scope_info);

  void MaterializeStackLocals(Handle<JSObject> target,
                              Handle<JSFunction> function);

  void UpdateStackLocalsFromMaterializedObject(Handle<JSObject> object,
                                               Handle<ScopeInfo> scope_info);

 private:
  bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info,
                                         Handle<String> parameter_name);

54
  StandardFrame* frame_;
55 56 57
  DeoptimizedFrameInfo* deoptimized_frame_;
  Isolate* isolate_;
  bool is_optimized_;
58
  bool is_interpreted_;
59 60 61 62 63 64 65 66 67 68
  bool is_bottommost_;
  bool has_adapted_arguments_;

  DISALLOW_COPY_AND_ASSIGN(FrameInspector);
};


class DebugFrameHelper : public AllStatic {
 public:
  static SaveContext* FindSavedContextForFrame(Isolate* isolate,
69
                                               StandardFrame* frame);
70 71
  // Advances the iterator to the frame that matches the index and returns the
  // inlined frame index, or -1 if not found.  Skips native JS functions.
72
  static int FindIndexedNonNativeFrame(StackTraceFrameIterator* it, int index);
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

  // Helper functions for wrapping and unwrapping stack frame ids.
  static Smi* WrapFrameId(StackFrame::Id id) {
    DCHECK(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4)));
    return Smi::FromInt(id >> 2);
  }

  static StackFrame::Id UnwrapFrameId(int wrapped) {
    return static_cast<StackFrame::Id>(wrapped << 2);
  }
};

}  // namespace internal
}  // namespace v8

#endif  // V8_DEBUG_DEBUG_FRAMES_H_