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 |
11 #include "include/v8-inspector.h" | 11 #include "include/v8-inspector.h" |
12 #include "include/v8.h" | 12 #include "include/v8.h" |
13 #include "src/base/macros.h" | 13 #include "src/base/macros.h" |
14 #include "src/inspector/protocol/Runtime.h" | 14 #include "src/inspector/protocol/Runtime.h" |
15 #include "src/inspector/string-16.h" | 15 #include "src/inspector/string-16.h" |
16 | 16 |
17 namespace v8_inspector { | 17 namespace v8_inspector { |
18 | 18 |
19 class AsyncStackTrace; | 19 class AsyncStackTrace; |
20 class V8Debugger; | 20 class V8Debugger; |
21 class WasmTranslation; | 21 class WasmTranslation; |
22 | 22 |
| 23 class StackFrame { |
| 24 public: |
| 25 explicit StackFrame(v8::Local<v8::StackFrame> frame); |
| 26 ~StackFrame() = default; |
| 27 |
| 28 void translate(WasmTranslation* wasmTranslation); |
| 29 |
| 30 const String16& functionName() const; |
| 31 const String16& scriptId() const; |
| 32 const String16& sourceURL() const; |
| 33 int lineNumber() const; // 0-based. |
| 34 int columnNumber() const; // 0-based. |
| 35 std::unique_ptr<protocol::Runtime::CallFrame> buildInspectorObject() const; |
| 36 |
| 37 private: |
| 38 String16 m_functionName; |
| 39 String16 m_scriptId; |
| 40 String16 m_sourceURL; |
| 41 int m_lineNumber; // 0-based. |
| 42 int m_columnNumber; // 0-based. |
| 43 }; |
| 44 |
23 class V8StackTraceImpl : public V8StackTrace { | 45 class V8StackTraceImpl : public V8StackTrace { |
24 public: | 46 public: |
25 static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*, | 47 static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*, |
26 bool capture); | 48 bool capture); |
27 static const int maxCallStackSizeToCapture = 200; | 49 static const int maxCallStackSizeToCapture = 200; |
28 static std::unique_ptr<V8StackTraceImpl> create(V8Debugger*, | 50 static std::unique_ptr<V8StackTraceImpl> create(V8Debugger*, |
29 int contextGroupId, | 51 int contextGroupId, |
30 v8::Local<v8::StackTrace>, | 52 v8::Local<v8::StackTrace>, |
31 int maxStackSize); | 53 int maxStackSize); |
32 static std::unique_ptr<V8StackTraceImpl> capture(V8Debugger*, | 54 static std::unique_ptr<V8StackTraceImpl> capture(V8Debugger*, |
(...skipping 10 matching lines...) Expand all Loading... |
43 bool isEmpty() const override; | 65 bool isEmpty() const override; |
44 StringView topSourceURL() const override; | 66 StringView topSourceURL() const override; |
45 int topLineNumber() const override; // 1-based. | 67 int topLineNumber() const override; // 1-based. |
46 int topColumnNumber() const override; // 1-based. | 68 int topColumnNumber() const override; // 1-based. |
47 StringView topScriptId() const override; | 69 StringView topScriptId() const override; |
48 StringView topFunctionName() const override; | 70 StringView topFunctionName() const override; |
49 std::unique_ptr<protocol::Runtime::API::StackTrace> buildInspectorObject() | 71 std::unique_ptr<protocol::Runtime::API::StackTrace> buildInspectorObject() |
50 const override; | 72 const override; |
51 std::unique_ptr<StringBuffer> toString() const override; | 73 std::unique_ptr<StringBuffer> toString() const override; |
52 | 74 |
53 class Frame { | |
54 public: | |
55 explicit Frame(v8::Local<v8::StackFrame> frame); | |
56 ~Frame() = default; | |
57 | |
58 void translate(WasmTranslation* wasmTranslation); | |
59 | |
60 const String16& functionName() const; | |
61 const String16& scriptId() const; | |
62 const String16& sourceURL() const; | |
63 int lineNumber() const; // 0-based. | |
64 int columnNumber() const; // 0-based. | |
65 std::unique_ptr<protocol::Runtime::CallFrame> buildInspectorObject() const; | |
66 | |
67 private: | |
68 String16 m_functionName; | |
69 String16 m_scriptId; | |
70 String16 m_sourceURL; | |
71 int m_lineNumber; // 0-based. | |
72 int m_columnNumber; // 0-based. | |
73 }; | |
74 | |
75 private: | 75 private: |
76 V8StackTraceImpl(const std::vector<Frame> frames, int maxAsyncDepth, | 76 V8StackTraceImpl(std::vector<std::shared_ptr<StackFrame>> frames, |
| 77 int maxAsyncDepth, |
77 std::shared_ptr<AsyncStackTrace> asyncParent, | 78 std::shared_ptr<AsyncStackTrace> asyncParent, |
78 std::shared_ptr<AsyncStackTrace> asyncCreation); | 79 std::shared_ptr<AsyncStackTrace> asyncCreation); |
79 | 80 |
80 std::vector<Frame> m_frames; | 81 std::vector<std::shared_ptr<StackFrame>> m_frames; |
81 int m_maxAsyncDepth; | 82 int m_maxAsyncDepth; |
82 std::weak_ptr<AsyncStackTrace> m_asyncParent; | 83 std::weak_ptr<AsyncStackTrace> m_asyncParent; |
83 std::weak_ptr<AsyncStackTrace> m_asyncCreation; | 84 std::weak_ptr<AsyncStackTrace> m_asyncCreation; |
84 | 85 |
85 DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl); | 86 DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl); |
86 }; | 87 }; |
87 | 88 |
88 class AsyncStackTrace { | 89 class AsyncStackTrace { |
89 public: | 90 public: |
90 static std::shared_ptr<AsyncStackTrace> capture(V8Debugger*, | 91 static std::shared_ptr<AsyncStackTrace> capture(V8Debugger*, |
91 int contextGroupId, | 92 int contextGroupId, |
92 const String16& description, | 93 const String16& description, |
93 int maxStackSize); | 94 int maxStackSize); |
94 | 95 |
95 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObject( | 96 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObject( |
96 AsyncStackTrace* asyncCreation, int maxAsyncDepth) const; | 97 AsyncStackTrace* asyncCreation, int maxAsyncDepth) const; |
97 | 98 |
98 int contextGroupId() const; | 99 int contextGroupId() const; |
99 std::weak_ptr<AsyncStackTrace> parent() const; | 100 std::weak_ptr<AsyncStackTrace> parent() const; |
100 std::weak_ptr<AsyncStackTrace> creation() const; | 101 std::weak_ptr<AsyncStackTrace> creation() const; |
101 bool isEmpty() const; | 102 bool isEmpty() const; |
102 | 103 |
103 private: | 104 private: |
104 AsyncStackTrace(int contextGroupId, const String16& description, | 105 AsyncStackTrace(int contextGroupId, const String16& description, |
105 const std::vector<V8StackTraceImpl::Frame>& frames, | 106 std::vector<std::shared_ptr<StackFrame>> frames, |
106 std::shared_ptr<AsyncStackTrace> asyncParent, | 107 std::shared_ptr<AsyncStackTrace> asyncParent, |
107 std::shared_ptr<AsyncStackTrace> asyncCreation); | 108 std::shared_ptr<AsyncStackTrace> asyncCreation); |
108 | 109 |
109 int m_contextGroupId; | 110 int m_contextGroupId; |
110 String16 m_description; | 111 String16 m_description; |
111 | 112 |
112 std::vector<V8StackTraceImpl::Frame> m_frames; | 113 std::vector<std::shared_ptr<StackFrame>> m_frames; |
113 std::weak_ptr<AsyncStackTrace> m_asyncParent; | 114 std::weak_ptr<AsyncStackTrace> m_asyncParent; |
114 std::weak_ptr<AsyncStackTrace> m_asyncCreation; | 115 std::weak_ptr<AsyncStackTrace> m_asyncCreation; |
115 | 116 |
116 DISALLOW_COPY_AND_ASSIGN(AsyncStackTrace); | 117 DISALLOW_COPY_AND_ASSIGN(AsyncStackTrace); |
117 }; | 118 }; |
118 | 119 |
119 } // namespace v8_inspector | 120 } // namespace v8_inspector |
120 | 121 |
121 #endif // V8_INSPECTOR_V8STACKTRACEIMPL_H_ | 122 #endif // V8_INSPECTOR_V8STACKTRACEIMPL_H_ |
OLD | NEW |