OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_INSPECTOR_V8STACKTRACEIMPL_H_ | 5 #ifndef V8_INSPECTOR_V8STACKTRACEIMPL_H_ |
6 #define V8_INSPECTOR_V8STACKTRACEIMPL_H_ | 6 #define V8_INSPECTOR_V8STACKTRACEIMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 ~StackFrame() = default; | 26 ~StackFrame() = default; |
27 | 27 |
28 void translate(WasmTranslation* wasmTranslation); | 28 void translate(WasmTranslation* wasmTranslation); |
29 | 29 |
30 const String16& functionName() const; | 30 const String16& functionName() const; |
31 const String16& scriptId() const; | 31 const String16& scriptId() const; |
32 const String16& sourceURL() const; | 32 const String16& sourceURL() const; |
33 int lineNumber() const; // 0-based. | 33 int lineNumber() const; // 0-based. |
34 int columnNumber() const; // 0-based. | 34 int columnNumber() const; // 0-based. |
35 std::unique_ptr<protocol::Runtime::CallFrame> buildInspectorObject() const; | 35 std::unique_ptr<protocol::Runtime::CallFrame> buildInspectorObject() const; |
| 36 bool isEqual(StackFrame* frame) const; |
36 | 37 |
37 private: | 38 private: |
38 String16 m_functionName; | 39 String16 m_functionName; |
39 String16 m_scriptId; | 40 String16 m_scriptId; |
40 String16 m_sourceURL; | 41 String16 m_sourceURL; |
41 int m_lineNumber; // 0-based. | 42 int m_lineNumber; // 0-based. |
42 int m_columnNumber; // 0-based. | 43 int m_columnNumber; // 0-based. |
43 }; | 44 }; |
44 | 45 |
45 class V8StackTraceImpl : public V8StackTrace { | 46 class V8StackTraceImpl : public V8StackTrace { |
(...skipping 19 matching lines...) Expand all Loading... |
65 bool isEmpty() const override; | 66 bool isEmpty() const override; |
66 StringView topSourceURL() const override; | 67 StringView topSourceURL() const override; |
67 int topLineNumber() const override; // 1-based. | 68 int topLineNumber() const override; // 1-based. |
68 int topColumnNumber() const override; // 1-based. | 69 int topColumnNumber() const override; // 1-based. |
69 StringView topScriptId() const override; | 70 StringView topScriptId() const override; |
70 StringView topFunctionName() const override; | 71 StringView topFunctionName() const override; |
71 std::unique_ptr<protocol::Runtime::API::StackTrace> buildInspectorObject() | 72 std::unique_ptr<protocol::Runtime::API::StackTrace> buildInspectorObject() |
72 const override; | 73 const override; |
73 std::unique_ptr<StringBuffer> toString() const override; | 74 std::unique_ptr<StringBuffer> toString() const override; |
74 | 75 |
| 76 bool isEqualIgnoringTopFrame(V8StackTraceImpl* stackTrace) const; |
| 77 |
75 private: | 78 private: |
76 V8StackTraceImpl(std::vector<std::shared_ptr<StackFrame>> frames, | 79 V8StackTraceImpl(std::vector<std::shared_ptr<StackFrame>> frames, |
77 int maxAsyncDepth, | 80 int maxAsyncDepth, |
78 std::shared_ptr<AsyncStackTrace> asyncParent, | 81 std::shared_ptr<AsyncStackTrace> asyncParent, |
79 std::shared_ptr<AsyncStackTrace> asyncCreation); | 82 std::shared_ptr<AsyncStackTrace> asyncCreation); |
80 | 83 |
| 84 class StackFrameIterator { |
| 85 public: |
| 86 explicit StackFrameIterator(const V8StackTraceImpl* stackTrace); |
| 87 |
| 88 void next(); |
| 89 StackFrame* frame(); |
| 90 bool done(); |
| 91 |
| 92 private: |
| 93 std::vector<std::shared_ptr<StackFrame>>::const_iterator m_currentIt; |
| 94 std::vector<std::shared_ptr<StackFrame>>::const_iterator m_currentEnd; |
| 95 AsyncStackTrace* m_parent; |
| 96 }; |
| 97 |
81 std::vector<std::shared_ptr<StackFrame>> m_frames; | 98 std::vector<std::shared_ptr<StackFrame>> m_frames; |
82 int m_maxAsyncDepth; | 99 int m_maxAsyncDepth; |
83 std::weak_ptr<AsyncStackTrace> m_asyncParent; | 100 std::weak_ptr<AsyncStackTrace> m_asyncParent; |
84 std::weak_ptr<AsyncStackTrace> m_asyncCreation; | 101 std::weak_ptr<AsyncStackTrace> m_asyncCreation; |
85 | 102 |
86 DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl); | 103 DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl); |
87 }; | 104 }; |
88 | 105 |
89 class AsyncStackTrace { | 106 class AsyncStackTrace { |
90 public: | 107 public: |
91 static std::shared_ptr<AsyncStackTrace> capture(V8Debugger*, | 108 static std::shared_ptr<AsyncStackTrace> capture(V8Debugger*, |
92 int contextGroupId, | 109 int contextGroupId, |
93 const String16& description, | 110 const String16& description, |
94 int maxStackSize); | 111 int maxStackSize); |
95 | 112 |
96 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObject( | 113 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObject( |
97 AsyncStackTrace* asyncCreation, int maxAsyncDepth) const; | 114 AsyncStackTrace* asyncCreation, int maxAsyncDepth) const; |
98 | 115 |
99 int contextGroupId() const; | 116 int contextGroupId() const; |
100 const String16& description() const; | 117 const String16& description() const; |
101 std::weak_ptr<AsyncStackTrace> parent() const; | 118 std::weak_ptr<AsyncStackTrace> parent() const; |
102 std::weak_ptr<AsyncStackTrace> creation() const; | 119 std::weak_ptr<AsyncStackTrace> creation() const; |
103 bool isEmpty() const; | 120 bool isEmpty() const; |
104 | 121 |
105 void setDescription(const String16& description) { | 122 void setDescription(const String16& description) { |
106 // TODO(kozyatinskiy): implement it without hack. | 123 // TODO(kozyatinskiy): implement it without hack. |
107 m_description = description; | 124 m_description = description; |
108 } | 125 } |
| 126 const std::vector<std::shared_ptr<StackFrame>>& frames() const { |
| 127 return m_frames; |
| 128 } |
109 | 129 |
110 private: | 130 private: |
111 AsyncStackTrace(int contextGroupId, const String16& description, | 131 AsyncStackTrace(int contextGroupId, const String16& description, |
112 std::vector<std::shared_ptr<StackFrame>> frames, | 132 std::vector<std::shared_ptr<StackFrame>> frames, |
113 std::shared_ptr<AsyncStackTrace> asyncParent, | 133 std::shared_ptr<AsyncStackTrace> asyncParent, |
114 std::shared_ptr<AsyncStackTrace> asyncCreation); | 134 std::shared_ptr<AsyncStackTrace> asyncCreation); |
115 | 135 |
116 int m_contextGroupId; | 136 int m_contextGroupId; |
117 String16 m_description; | 137 String16 m_description; |
118 | 138 |
119 std::vector<std::shared_ptr<StackFrame>> m_frames; | 139 std::vector<std::shared_ptr<StackFrame>> m_frames; |
120 std::weak_ptr<AsyncStackTrace> m_asyncParent; | 140 std::weak_ptr<AsyncStackTrace> m_asyncParent; |
121 std::weak_ptr<AsyncStackTrace> m_asyncCreation; | 141 std::weak_ptr<AsyncStackTrace> m_asyncCreation; |
122 | 142 |
123 DISALLOW_COPY_AND_ASSIGN(AsyncStackTrace); | 143 DISALLOW_COPY_AND_ASSIGN(AsyncStackTrace); |
124 }; | 144 }; |
125 | 145 |
126 } // namespace v8_inspector | 146 } // namespace v8_inspector |
127 | 147 |
128 #endif // V8_INSPECTOR_V8STACKTRACEIMPL_H_ | 148 #endif // V8_INSPECTOR_V8STACKTRACEIMPL_H_ |
OLD | NEW |