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_DEBUG_DEBUG_STACK_TRACE_ITERATOR_H_
6#define V8_DEBUG_DEBUG_STACK_TRACE_ITERATOR_H_
7
8#include <memory>
9
10#include "src/debug/debug-frames.h"
11#include "src/debug/debug-interface.h"
12#include "src/execution/frames.h"
13
14namespace v8 {
15namespace internal {
16
17class DebugStackTraceIterator final : public debug::StackTraceIterator {
18 public:
19  DebugStackTraceIterator(Isolate* isolate, int index);
20  ~DebugStackTraceIterator() override;
21
22  bool Done() const override;
23  void Advance() override;
24
25  int GetContextId() const override;
26  v8::MaybeLocal<v8::Value> GetReceiver() const override;
27  v8::Local<v8::Value> GetReturnValue() const override;
28  v8::Local<v8::String> GetFunctionDebugName() const override;
29  v8::Local<v8::debug::Script> GetScript() const override;
30  debug::Location GetSourceLocation() const override;
31  v8::Local<v8::Function> GetFunction() const override;
32  std::unique_ptr<v8::debug::ScopeIterator> GetScopeIterator() const override;
33
34  v8::MaybeLocal<v8::Value> Evaluate(v8::Local<v8::String> source,
35                                     bool throw_on_side_effect) override;
36
37 private:
38  Isolate* isolate_;
39  StackTraceFrameIterator iterator_;
40  std::unique_ptr<FrameInspector> frame_inspector_;
41  int inlined_frame_index_;
42  bool is_top_frame_;
43};
44}  // namespace internal
45}  // namespace v8
46
47#endif  // V8_DEBUG_DEBUG_STACK_TRACE_ITERATOR_H_
48