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

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

Issue 2816043006: [inspector] avoid cloning of async call chains (Closed)
Patch Set: lines and columns in stack string should be 1-based 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>
8 #include <vector> 9 #include <vector>
9 10
11 #include "include/v8-inspector.h"
12 #include "include/v8.h"
10 #include "src/base/macros.h" 13 #include "src/base/macros.h"
11 #include "src/inspector/protocol/Forward.h"
12 #include "src/inspector/protocol/Runtime.h" 14 #include "src/inspector/protocol/Runtime.h"
13 15 #include "src/inspector/string-16.h"
14 #include "include/v8-inspector.h"
15 16
16 namespace v8_inspector { 17 namespace v8_inspector {
17 18
19 class AsyncStackTrace;
18 class V8Debugger; 20 class V8Debugger;
21 class WasmTranslation;
19 22
20 // Note: async stack trace may have empty top stack with non-empty tail to 23 class V8StackTraceImpl : public V8StackTrace {
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
50 static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*, 25 static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*,
51 bool capture); 26 bool capture);
52 static std::unique_ptr<V8StackTraceImpl> create( 27 static const int maxCallStackSizeToCapture = 200;
53 V8Debugger*, int contextGroupId, v8::Local<v8::StackTrace>, 28 static std::unique_ptr<V8StackTraceImpl> create(V8Debugger*,
54 size_t maxStackSize, const String16& description = String16()); 29 int contextGroupId,
55 static std::unique_ptr<V8StackTraceImpl> capture( 30 v8::Local<v8::StackTrace>,
56 V8Debugger*, int contextGroupId, size_t maxStackSize, 31 int maxStackSize);
57 const String16& description = String16()); 32 static std::unique_ptr<V8StackTraceImpl> capture(V8Debugger*,
33 int contextGroupId,
34 int maxStackSize);
58 35
59 // This method drops the async chain. Use cloneImpl() instead. 36 ~V8StackTraceImpl() override;
60 std::unique_ptr<V8StackTrace> clone() override;
61 std::unique_ptr<V8StackTraceImpl> cloneImpl();
62 static std::unique_ptr<protocol::Runtime::StackTrace>
63 buildInspectorObjectForTail(V8Debugger*);
64 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectImpl() 37 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectImpl()
65 const; 38 const;
66 ~V8StackTraceImpl() override;
67 39
68 // V8StackTrace implementation. 40 // V8StackTrace implementation.
69 bool isEmpty() const override { return !m_frames.size(); }; 41 // This method drops the async stack trace.
42 std::unique_ptr<V8StackTrace> clone() override;
43 bool isEmpty() const override;
70 StringView topSourceURL() const override; 44 StringView topSourceURL() const override;
71 int topLineNumber() const override; 45 int topLineNumber() const override; // 1-based.
72 int topColumnNumber() const override; 46 int topColumnNumber() const override; // 1-based.
73 StringView topScriptId() const override; 47 StringView topScriptId() const override;
74 StringView topFunctionName() const override; 48 StringView topFunctionName() const override;
75 std::unique_ptr<protocol::Runtime::API::StackTrace> buildInspectorObject() 49 std::unique_ptr<protocol::Runtime::API::StackTrace> buildInspectorObject()
76 const override; 50 const override;
77 std::unique_ptr<StringBuffer> toString() const override; 51 std::unique_ptr<StringBuffer> toString() const override;
78 52
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
79 private: 75 private:
80 V8StackTraceImpl(int contextGroupId, const String16& description, 76 V8StackTraceImpl(const std::vector<Frame> frames, int maxAsyncDepth,
81 std::vector<Frame>& frames, 77 std::shared_ptr<AsyncStackTrace> asyncParent,
82 std::unique_ptr<V8StackTraceImpl> parent, 78 std::shared_ptr<AsyncStackTrace> asyncCreation);
83 std::unique_ptr<V8StackTraceImpl> creation);
84 79
85 std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectImpl(
86 V8StackTraceImpl* creation) const;
87
88 int m_contextGroupId;
89 String16 m_description;
90 std::vector<Frame> m_frames; 80 std::vector<Frame> m_frames;
91 std::unique_ptr<V8StackTraceImpl> m_parent; 81 int m_maxAsyncDepth;
92 std::unique_ptr<V8StackTraceImpl> m_creation; 82 std::weak_ptr<AsyncStackTrace> m_asyncParent;
83 std::weak_ptr<AsyncStackTrace> m_asyncCreation;
93 84
94 DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl); 85 DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl);
95 }; 86 };
96 87
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
97 } // namespace v8_inspector 119 } // namespace v8_inspector
98 120
99 #endif // V8_INSPECTOR_V8STACKTRACEIMPL_H_ 121 #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