11cb0ef41Sopenharmony_ci// Copyright 2021 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef V8_TOOLS_V8WINDBG_SRC_JS_STACK_H_ 61cb0ef41Sopenharmony_ci#define V8_TOOLS_V8WINDBG_SRC_JS_STACK_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include <crtdbg.h> 91cb0ef41Sopenharmony_ci#include <wrl/implements.h> 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci#include <string> 121cb0ef41Sopenharmony_ci#include <vector> 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci#include "src/base/optional.h" 151cb0ef41Sopenharmony_ci#include "tools/v8windbg/base/utilities.h" 161cb0ef41Sopenharmony_ci#include "tools/v8windbg/src/v8-debug-helper-interop.h" 171cb0ef41Sopenharmony_ci#include "tools/v8windbg/src/v8windbg-extension.h" 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciclass JSStackAlias 201cb0ef41Sopenharmony_ci : public WRL::RuntimeClass< 211cb0ef41Sopenharmony_ci WRL::RuntimeClassFlags<WRL::RuntimeClassType::ClassicCom>, 221cb0ef41Sopenharmony_ci IModelMethod> { 231cb0ef41Sopenharmony_ci public: 241cb0ef41Sopenharmony_ci IFACEMETHOD(Call) 251cb0ef41Sopenharmony_ci (IModelObject* p_context_object, ULONG64 arg_count, 261cb0ef41Sopenharmony_ci _In_reads_(arg_count) IModelObject** pp_arguments, IModelObject** pp_result, 271cb0ef41Sopenharmony_ci IKeyStore** pp_metadata); 281cb0ef41Sopenharmony_ci}; 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_cistruct FrameData { 311cb0ef41Sopenharmony_ci FrameData(); 321cb0ef41Sopenharmony_ci ~FrameData(); 331cb0ef41Sopenharmony_ci FrameData(const FrameData&); 341cb0ef41Sopenharmony_ci FrameData(FrameData&&); 351cb0ef41Sopenharmony_ci FrameData& operator=(const FrameData&); 361cb0ef41Sopenharmony_ci FrameData& operator=(FrameData&&); 371cb0ef41Sopenharmony_ci WRL::ComPtr<IModelObject> script_name; 381cb0ef41Sopenharmony_ci WRL::ComPtr<IModelObject> script_source; 391cb0ef41Sopenharmony_ci WRL::ComPtr<IModelObject> function_name; 401cb0ef41Sopenharmony_ci WRL::ComPtr<IModelObject> function_character_offset; 411cb0ef41Sopenharmony_ci}; 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ciclass StackFrameIterator 441cb0ef41Sopenharmony_ci : public WRL::RuntimeClass< 451cb0ef41Sopenharmony_ci WRL::RuntimeClassFlags<WRL::RuntimeClassType::ClassicCom>, 461cb0ef41Sopenharmony_ci IModelIterator> { 471cb0ef41Sopenharmony_ci public: 481cb0ef41Sopenharmony_ci StackFrameIterator(WRL::ComPtr<IDebugHostContext>& host_context); 491cb0ef41Sopenharmony_ci ~StackFrameIterator() override; 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci HRESULT PopulateFrameData(); 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_ci IFACEMETHOD(Reset)(); 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci IFACEMETHOD(GetNext) 561cb0ef41Sopenharmony_ci (IModelObject** object, ULONG64 dimensions, IModelObject** indexers, 571cb0ef41Sopenharmony_ci IKeyStore** metadata); 581cb0ef41Sopenharmony_ci 591cb0ef41Sopenharmony_ci HRESULT GetAt(uint64_t index, IModelObject** result) const; 601cb0ef41Sopenharmony_ci 611cb0ef41Sopenharmony_ci private: 621cb0ef41Sopenharmony_ci ULONG position_ = 0; 631cb0ef41Sopenharmony_ci std::vector<FrameData> frames_; 641cb0ef41Sopenharmony_ci WRL::ComPtr<IDebugHostContext> sp_ctx_; 651cb0ef41Sopenharmony_ci}; 661cb0ef41Sopenharmony_ci 671cb0ef41Sopenharmony_ciclass StackFrames 681cb0ef41Sopenharmony_ci : public WRL::RuntimeClass< 691cb0ef41Sopenharmony_ci WRL::RuntimeClassFlags<WRL::RuntimeClassType::ClassicCom>, 701cb0ef41Sopenharmony_ci IIndexableConcept, IIterableConcept> { 711cb0ef41Sopenharmony_ci public: 721cb0ef41Sopenharmony_ci StackFrames(); 731cb0ef41Sopenharmony_ci ~StackFrames() override; 741cb0ef41Sopenharmony_ci 751cb0ef41Sopenharmony_ci // IIndexableConcept members 761cb0ef41Sopenharmony_ci IFACEMETHOD(GetDimensionality) 771cb0ef41Sopenharmony_ci (IModelObject* context_object, ULONG64* dimensionality); 781cb0ef41Sopenharmony_ci 791cb0ef41Sopenharmony_ci IFACEMETHOD(GetAt) 801cb0ef41Sopenharmony_ci (IModelObject* context_object, ULONG64 indexer_count, IModelObject** indexers, 811cb0ef41Sopenharmony_ci IModelObject** object, IKeyStore** metadata); 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_ci IFACEMETHOD(SetAt) 841cb0ef41Sopenharmony_ci (IModelObject* context_object, ULONG64 indexer_count, IModelObject** indexers, 851cb0ef41Sopenharmony_ci IModelObject* value); 861cb0ef41Sopenharmony_ci 871cb0ef41Sopenharmony_ci // IIterableConcept 881cb0ef41Sopenharmony_ci IFACEMETHOD(GetDefaultIndexDimensionality) 891cb0ef41Sopenharmony_ci (IModelObject* context_object, ULONG64* dimensionality); 901cb0ef41Sopenharmony_ci 911cb0ef41Sopenharmony_ci IFACEMETHOD(GetIterator) 921cb0ef41Sopenharmony_ci (IModelObject* context_object, IModelIterator** iterator); 931cb0ef41Sopenharmony_ci 941cb0ef41Sopenharmony_ci private: 951cb0ef41Sopenharmony_ci WRL::ComPtr<StackFrameIterator> opt_frames_; 961cb0ef41Sopenharmony_ci}; 971cb0ef41Sopenharmony_ci 981cb0ef41Sopenharmony_ci#endif // V8_TOOLS_V8WINDBG_SRC_JS_STACK_H_ 99