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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "src/base/macros.h" | 10 #include "src/base/macros.h" |
11 #include "src/inspector/protocol/Forward.h" | 11 #include "src/inspector/protocol/Forward.h" |
12 #include "src/inspector/protocol/Runtime.h" | 12 #include "src/inspector/protocol/Runtime.h" |
13 | 13 |
14 #include "include/v8-inspector.h" | 14 #include "include/v8-inspector.h" |
15 | 15 |
16 namespace v8_inspector { | 16 namespace v8_inspector { |
17 | 17 |
18 class TracedValue; | |
19 class V8Debugger; | 18 class V8Debugger; |
20 | 19 |
21 // Note: async stack trace may have empty top stack with non-empty tail to | 20 // Note: async stack trace may have empty top stack with non-empty tail to |
22 // indicate | 21 // indicate that current native-only state had some async story. |
23 // that current native-only state had some async story. | |
24 // On the other hand, any non-top async stack is guaranteed to be non-empty. | 22 // On the other hand, any non-top async stack is guaranteed to be non-empty. |
25 class V8StackTraceImpl final : public V8StackTrace { | 23 class V8StackTraceImpl final : public V8StackTrace { |
26 public: | 24 public: |
27 static const size_t maxCallStackSizeToCapture = 200; | 25 static const size_t maxCallStackSizeToCapture = 200; |
28 | 26 |
29 class Frame { | 27 class Frame { |
30 public: | 28 public: |
31 Frame(); | |
32 Frame(const String16& functionName, const String16& scriptId, | 29 Frame(const String16& functionName, const String16& scriptId, |
33 const String16& scriptName, int lineNumber, int column = 0); | 30 const String16& scriptName, int lineNumber, int column = 0); |
34 ~Frame(); | 31 ~Frame() = default; |
35 | 32 |
36 const String16& functionName() const { return m_functionName; } | 33 const String16& functionName() const { return m_functionName; } |
37 const String16& scriptId() const { return m_scriptId; } | 34 const String16& scriptId() const { return m_scriptId; } |
38 const String16& sourceURL() const { return m_scriptName; } | 35 const String16& sourceURL() const { return m_scriptName; } |
39 int lineNumber() const { return m_lineNumber; } | 36 int lineNumber() const { return m_lineNumber; } |
40 int columnNumber() const { return m_columnNumber; } | 37 int columnNumber() const { return m_columnNumber; } |
41 Frame clone() const; | |
42 | 38 |
43 private: | 39 private: |
44 friend class V8StackTraceImpl; | 40 friend class V8StackTraceImpl; |
45 std::unique_ptr<protocol::Runtime::CallFrame> buildInspectorObject() const; | 41 std::unique_ptr<protocol::Runtime::CallFrame> buildInspectorObject() const; |
46 void toTracedValue(TracedValue*) const; | |
47 | 42 |
48 String16 m_functionName; | 43 String16 m_functionName; |
49 String16 m_scriptId; | 44 String16 m_scriptId; |
50 String16 m_scriptName; | 45 String16 m_scriptName; |
51 int m_lineNumber; | 46 int m_lineNumber; |
52 int m_columnNumber; | 47 int m_columnNumber; |
53 }; | 48 }; |
54 | 49 |
55 static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*, | 50 static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*, |
56 bool capture); | 51 bool capture); |
57 static std::unique_ptr<V8StackTraceImpl> create( | 52 static std::unique_ptr<V8StackTraceImpl> create( |
58 V8Debugger*, int contextGroupId, v8::Local<v8::StackTrace>, | 53 V8Debugger*, int contextGroupId, v8::Local<v8::StackTrace>, |
59 size_t maxStackSize, const String16& description = String16()); | 54 size_t maxStackSize, const String16& description = String16()); |
60 static std::unique_ptr<V8StackTraceImpl> capture( | 55 static std::unique_ptr<V8StackTraceImpl> capture( |
61 V8Debugger*, int contextGroupId, size_t maxStackSize, | 56 V8Debugger*, int contextGroupId, size_t maxStackSize, |
62 const String16& description = String16()); | 57 const String16& description = String16()); |
63 | 58 |
64 // This method drops the async chain. Use cloneImpl() instead. | 59 // This method drops the async chain. Use cloneImpl() instead. |
65 std::unique_ptr<V8StackTrace> clone() override; | 60 std::unique_ptr<V8StackTrace> clone() override; |
66 std::unique_ptr<V8StackTraceImpl> cloneImpl(); | 61 std::unique_ptr<V8StackTraceImpl> cloneImpl(); |
67 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectForTail( | 62 static std::unique_ptr<protocol::Runtime::StackTrace> |
68 V8Debugger*) const; | 63 buildInspectorObjectForTail(V8Debugger*); |
69 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectImpl() | 64 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectImpl() |
70 const; | 65 const; |
71 ~V8StackTraceImpl() override; | 66 ~V8StackTraceImpl() override; |
72 | 67 |
73 // V8StackTrace implementation. | 68 // V8StackTrace implementation. |
74 bool isEmpty() const override { return !m_frames.size(); }; | 69 bool isEmpty() const override { return !m_frames.size(); }; |
75 StringView topSourceURL() const override; | 70 StringView topSourceURL() const override; |
76 int topLineNumber() const override; | 71 int topLineNumber() const override; |
77 int topColumnNumber() const override; | 72 int topColumnNumber() const override; |
78 StringView topScriptId() const override; | 73 StringView topScriptId() const override; |
79 StringView topFunctionName() const override; | 74 StringView topFunctionName() const override; |
80 std::unique_ptr<protocol::Runtime::API::StackTrace> buildInspectorObject() | 75 std::unique_ptr<protocol::Runtime::API::StackTrace> buildInspectorObject() |
81 const override; | 76 const override; |
82 std::unique_ptr<StringBuffer> toString() const override; | 77 std::unique_ptr<StringBuffer> toString() const override; |
83 | 78 |
84 void setCreation(std::unique_ptr<V8StackTraceImpl> creation); | |
85 | |
86 private: | 79 private: |
87 V8StackTraceImpl(int contextGroupId, const String16& description, | 80 V8StackTraceImpl(int contextGroupId, const String16& description, |
88 std::vector<Frame>& frames, | 81 std::vector<Frame>& frames, |
89 std::unique_ptr<V8StackTraceImpl> parent); | 82 std::unique_ptr<V8StackTraceImpl> parent, |
| 83 std::unique_ptr<V8StackTraceImpl> creation); |
| 84 |
| 85 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectImpl( |
| 86 V8StackTraceImpl* creation) const; |
90 | 87 |
91 int m_contextGroupId; | 88 int m_contextGroupId; |
92 String16 m_description; | 89 String16 m_description; |
93 std::vector<Frame> m_frames; | 90 std::vector<Frame> m_frames; |
94 std::unique_ptr<V8StackTraceImpl> m_parent; | 91 std::unique_ptr<V8StackTraceImpl> m_parent; |
95 std::unique_ptr<V8StackTraceImpl> m_creation; | 92 std::unique_ptr<V8StackTraceImpl> m_creation; |
96 | 93 |
97 DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl); | 94 DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl); |
98 }; | 95 }; |
99 | 96 |
100 } // namespace v8_inspector | 97 } // namespace v8_inspector |
101 | 98 |
102 #endif // V8_INSPECTOR_V8STACKTRACEIMPL_H_ | 99 #endif // V8_INSPECTOR_V8STACKTRACEIMPL_H_ |
OLD | NEW |