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