Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: src/inspector/v8-stack-trace-impl.h

Issue 2825713002: Revert of [inspector] avoid cloning of async call chains (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/inspector/v8-debugger-agent-impl.cc ('k') | src/inspector/v8-stack-trace-impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
9 #include <vector> 8 #include <vector>
10 9
10 #include "src/base/macros.h"
11 #include "src/inspector/protocol/Forward.h"
12 #include "src/inspector/protocol/Runtime.h"
13
11 #include "include/v8-inspector.h" 14 #include "include/v8-inspector.h"
12 #include "include/v8.h"
13 #include "src/base/macros.h"
14 #include "src/inspector/protocol/Runtime.h"
15 #include "src/inspector/string-16.h"
16 15
17 namespace v8_inspector { 16 namespace v8_inspector {
18 17
19 class AsyncStackTrace;
20 class V8Debugger; 18 class V8Debugger;
21 class WasmTranslation;
22 19
23 class V8StackTraceImpl : public V8StackTrace { 20 // Note: async stack trace may have empty top stack with non-empty tail to
21 // indicate that current native-only state had some async story.
22 // On the other hand, any non-top async stack is guaranteed to be non-empty.
23 class V8StackTraceImpl final : public V8StackTrace {
24 public: 24 public:
25 static const size_t maxCallStackSizeToCapture = 200;
26
27 class Frame {
28 public:
29 Frame(const String16& functionName, const String16& scriptId,
30 const String16& scriptName, int lineNumber, int column = 0);
31 ~Frame() = default;
32
33 const String16& functionName() const { return m_functionName; }
34 const String16& scriptId() const { return m_scriptId; }
35 const String16& sourceURL() const { return m_scriptName; }
36 int lineNumber() const { return m_lineNumber; }
37 int columnNumber() const { return m_columnNumber; }
38
39 private:
40 friend class V8StackTraceImpl;
41 std::unique_ptr<protocol::Runtime::CallFrame> buildInspectorObject() const;
42
43 String16 m_functionName;
44 String16 m_scriptId;
45 String16 m_scriptName;
46 int m_lineNumber;
47 int m_columnNumber;
48 };
49
25 static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*, 50 static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*,
26 bool capture); 51 bool capture);
27 static const int maxCallStackSizeToCapture = 200; 52 static std::unique_ptr<V8StackTraceImpl> create(
28 static std::unique_ptr<V8StackTraceImpl> create(V8Debugger*, 53 V8Debugger*, int contextGroupId, v8::Local<v8::StackTrace>,
29 int contextGroupId, 54 size_t maxStackSize, const String16& description = String16());
30 v8::Local<v8::StackTrace>, 55 static std::unique_ptr<V8StackTraceImpl> capture(
31 int maxStackSize); 56 V8Debugger*, int contextGroupId, size_t maxStackSize,
32 static std::unique_ptr<V8StackTraceImpl> capture(V8Debugger*, 57 const String16& description = String16());
33 int contextGroupId,
34 int maxStackSize);
35 58
36 ~V8StackTraceImpl() override; 59 // This method drops the async chain. Use cloneImpl() instead.
60 std::unique_ptr<V8StackTrace> clone() override;
61 std::unique_ptr<V8StackTraceImpl> cloneImpl();
62 static std::unique_ptr<protocol::Runtime::StackTrace>
63 buildInspectorObjectForTail(V8Debugger*);
37 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectImpl() 64 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectImpl()
38 const; 65 const;
66 ~V8StackTraceImpl() override;
39 67
40 // V8StackTrace implementation. 68 // V8StackTrace implementation.
41 // This method drops the async stack trace. 69 bool isEmpty() const override { return !m_frames.size(); };
42 std::unique_ptr<V8StackTrace> clone() override;
43 bool isEmpty() const override;
44 StringView topSourceURL() const override; 70 StringView topSourceURL() const override;
45 int topLineNumber() const override; // 1-based. 71 int topLineNumber() const override;
46 int topColumnNumber() const override; // 1-based. 72 int topColumnNumber() const override;
47 StringView topScriptId() const override; 73 StringView topScriptId() const override;
48 StringView topFunctionName() const override; 74 StringView topFunctionName() const override;
49 std::unique_ptr<protocol::Runtime::API::StackTrace> buildInspectorObject() 75 std::unique_ptr<protocol::Runtime::API::StackTrace> buildInspectorObject()
50 const override; 76 const override;
51 std::unique_ptr<StringBuffer> toString() const override; 77 std::unique_ptr<StringBuffer> toString() const override;
52 78
53 class Frame { 79 private:
54 public: 80 V8StackTraceImpl(int contextGroupId, const String16& description,
55 explicit Frame(v8::Local<v8::StackFrame> frame); 81 std::vector<Frame>& frames,
56 ~Frame() = default; 82 std::unique_ptr<V8StackTraceImpl> parent,
83 std::unique_ptr<V8StackTraceImpl> creation);
57 84
58 void translate(WasmTranslation* wasmTranslation); 85 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectImpl(
86 V8StackTraceImpl* creation) const;
59 87
60 const String16& functionName() const; 88 int m_contextGroupId;
61 const String16& scriptId() const; 89 String16 m_description;
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:
76 V8StackTraceImpl(const std::vector<Frame> frames, int maxAsyncDepth,
77 std::shared_ptr<AsyncStackTrace> asyncParent,
78 std::shared_ptr<AsyncStackTrace> asyncCreation);
79
80 std::vector<Frame> m_frames; 90 std::vector<Frame> m_frames;
81 int m_maxAsyncDepth; 91 std::unique_ptr<V8StackTraceImpl> m_parent;
82 std::weak_ptr<AsyncStackTrace> m_asyncParent; 92 std::unique_ptr<V8StackTraceImpl> m_creation;
83 std::weak_ptr<AsyncStackTrace> m_asyncCreation;
84 93
85 DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl); 94 DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl);
86 }; 95 };
87 96
88 class AsyncStackTrace {
89 public:
90 static std::shared_ptr<AsyncStackTrace> capture(V8Debugger*,
91 int contextGroupId,
92 const String16& description,
93 int maxStackSize);
94
95 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObject(
96 AsyncStackTrace* asyncCreation, int maxAsyncDepth) const;
97
98 int contextGroupId() const;
99 std::weak_ptr<AsyncStackTrace> parent() const;
100 std::weak_ptr<AsyncStackTrace> creation() const;
101 bool isEmpty() const;
102
103 private:
104 AsyncStackTrace(int contextGroupId, const String16& description,
105 const std::vector<V8StackTraceImpl::Frame>& frames,
106 std::shared_ptr<AsyncStackTrace> asyncParent,
107 std::shared_ptr<AsyncStackTrace> asyncCreation);
108
109 int m_contextGroupId;
110 String16 m_description;
111
112 std::vector<V8StackTraceImpl::Frame> m_frames;
113 std::weak_ptr<AsyncStackTrace> m_asyncParent;
114 std::weak_ptr<AsyncStackTrace> m_asyncCreation;
115
116 DISALLOW_COPY_AND_ASSIGN(AsyncStackTrace);
117 };
118
119 } // namespace v8_inspector 97 } // namespace v8_inspector
120 98
121 #endif // V8_INSPECTOR_V8STACKTRACEIMPL_H_ 99 #endif // V8_INSPECTOR_V8STACKTRACEIMPL_H_
OLDNEW
« no previous file with comments | « src/inspector/v8-debugger-agent-impl.cc ('k') | src/inspector/v8-stack-trace-impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698