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 <memory> 9 10 #include "src/deoptimizer/deoptimizer.h" 11 #include "src/execution/isolate.h" 12 #include "src/execution/v8threads.h" 13 #include "src/objects/objects.h" 14 15 namespace v8 { 16 namespace internal { 17 18 class JavaScriptFrame; 19 class CommonFrame; 20 class WasmFrame; 21 22 class FrameInspector { 23 public: 24 FrameInspector(CommonFrame* frame, int inlined_frame_index, Isolate* isolate); 25 26 ~FrameInspector(); 27 GetFunction()28 Handle<JSFunction> GetFunction() const { return function_; } GetScript()29 Handle<Script> GetScript() { return script_; } 30 Handle<Object> GetParameter(int index); 31 Handle<Object> GetExpression(int index); GetSourcePosition()32 int GetSourcePosition() { return source_position_; } IsConstructor()33 bool IsConstructor() { return is_constructor_; } 34 Handle<Object> GetContext(); GetReceiver()35 Handle<Object> GetReceiver() { return receiver_; } 36 GetFunctionName()37 Handle<String> GetFunctionName() { return function_name_; } 38 39 bool IsWasm(); 40 bool IsJavaScript(); 41 42 JavaScriptFrame* javascript_frame(); 43 inlined_frame_index()44 int inlined_frame_index() const { return inlined_frame_index_; } 45 46 private: 47 bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info, 48 Handle<String> parameter_name); 49 50 CommonFrame* frame_; 51 int inlined_frame_index_; 52 std::unique_ptr<DeoptimizedFrameInfo> deoptimized_frame_; 53 Isolate* isolate_; 54 Handle<Script> script_; 55 Handle<Object> receiver_; 56 Handle<JSFunction> function_; 57 Handle<String> function_name_; 58 int source_position_ = -1; 59 bool is_optimized_ = false; 60 bool is_interpreted_ = false; 61 bool has_adapted_arguments_ = false; 62 bool is_constructor_ = false; 63 64 DISALLOW_COPY_AND_ASSIGN(FrameInspector); 65 }; 66 67 class RedirectActiveFunctions : public ThreadVisitor { 68 public: 69 enum class Mode { 70 kUseOriginalBytecode, 71 kUseDebugBytecode, 72 }; 73 74 explicit RedirectActiveFunctions(SharedFunctionInfo shared, Mode mode); 75 76 void VisitThread(Isolate* isolate, ThreadLocalTop* top) override; 77 78 private: 79 SharedFunctionInfo shared_; 80 Mode mode_; 81 DisallowHeapAllocation no_gc_; 82 }; 83 84 } // namespace internal 85 } // namespace v8 86 87 #endif // V8_DEBUG_DEBUG_FRAMES_H_ 88