OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 21 matching lines...) Expand all Loading... | |
32 #define StackTrace_h | 32 #define StackTrace_h |
33 | 33 |
34 #include "bindings/common/ScriptValue.h" | 34 #include "bindings/common/ScriptValue.h" |
35 #include <dart_debugger_api.h> | 35 #include <dart_debugger_api.h> |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 class JSONValue; | 39 class JSONValue; |
40 class ScriptState; | 40 class ScriptState; |
41 class V8ScriptState; | 41 class V8ScriptState; |
42 class DartScriptState; | |
42 | 43 |
43 class StackTrace { | 44 class StackTrace { |
vsm
2014/08/13 14:26:45
Can this be pushed to multivm?
Jacob
2014/08/13 21:36:15
This one is ugly to push to multi-vm because it re
| |
44 public: | 45 public: |
45 explicit StackTrace() | 46 explicit StackTrace(); |
47 explicit StackTrace(const StackTrace& javaScriptStackTrace, const StackTrace & dartStackTrace); | |
48 explicit StackTrace(const ScriptValue& stackTrace, V8ScriptState*); | |
49 explicit StackTrace(Dart_StackTrace, DartScriptState*); | |
50 | |
51 bool hasJavaScript() const | |
46 { | 52 { |
47 m_isJavaScript = true; | 53 return m_hasJavaScript; |
48 m_dartStackTrace = 0; | |
49 } | 54 } |
50 | 55 |
51 explicit StackTrace(const ScriptValue& stackTrace) | 56 bool hasDart() const |
52 { | 57 { |
53 m_isJavaScript = true; | 58 return m_hasDart; |
54 m_scriptValue = stackTrace; | |
55 m_dartStackTrace = 0; | |
56 } | |
57 | |
58 explicit StackTrace(Dart_StackTrace stackTrace) | |
59 { | |
60 m_isJavaScript = false; | |
61 m_dartStackTrace = stackTrace; | |
62 } | |
63 | |
64 bool isJavaScript() const | |
65 { | |
66 return m_isJavaScript; | |
67 } | 59 } |
68 | 60 |
69 ScriptValue asJavaScript() const | 61 ScriptValue asJavaScript() const |
70 { | 62 { |
71 ASSERT(m_isJavaScript); | 63 ASSERT(m_hasJavaScript); |
72 return m_scriptValue; | 64 return m_scriptValue; |
73 } | 65 } |
74 | 66 |
75 Dart_StackTrace asDart() const | 67 Dart_StackTrace asDart() const |
76 { | 68 { |
77 ASSERT(!m_isJavaScript); | 69 ASSERT(m_hasDart); |
78 return m_dartStackTrace; | 70 return m_dartStackTrace; |
79 } | 71 } |
80 | 72 |
81 bool isNull() const | 73 bool isNull() const |
82 { | 74 { |
83 return m_isJavaScript ? m_scriptValue.isEmpty() : !m_dartStackTrace; | 75 return !m_hasDart && !m_hasJavaScript; |
vsm
2014/08/13 14:26:45
If m_hasJavaScript, should you check m_scriptValue
Jacob
2014/08/13 21:36:15
No need to now that we have hasJavaScript and hasD
| |
76 } | |
77 | |
78 bool isMixedLanguageStackTrace() const | |
79 { | |
80 return m_hasJavaScript && m_hasDart; | |
81 } | |
82 | |
83 DartScriptState* dartScriptState() const | |
84 { | |
85 return m_dartScriptState; | |
86 } | |
87 | |
88 V8ScriptState* v8ScriptState() const | |
89 { | |
90 return m_v8ScriptState; | |
84 } | 91 } |
85 | 92 |
86 private: | 93 private: |
87 bool m_isJavaScript; | 94 bool m_hasJavaScript; |
95 bool m_hasDart; | |
88 ScriptValue m_scriptValue; | 96 ScriptValue m_scriptValue; |
89 Dart_StackTrace m_dartStackTrace; | 97 Dart_StackTrace m_dartStackTrace; |
98 V8ScriptState* m_v8ScriptState; | |
99 DartScriptState* m_dartScriptState; | |
90 }; | 100 }; |
91 | 101 |
92 class ActivationFrame { | 102 class ActivationFrame { |
93 public: | 103 public: |
94 explicit ActivationFrame() | 104 explicit ActivationFrame() |
95 { | 105 { |
96 m_isJavaScript = true; | 106 m_isJavaScript = true; |
97 m_dartActivationFrame = 0; | 107 m_dartActivationFrame = 0; |
98 } | 108 } |
99 | 109 |
100 explicit ActivationFrame(const ScriptValue& activationFrame) | 110 explicit ActivationFrame(const ScriptValue& activationFrame) |
101 { | 111 { |
102 m_isJavaScript = true; | 112 m_isJavaScript = true; |
103 m_scriptValue = activationFrame; | 113 m_scriptValue = activationFrame; |
104 m_dartActivationFrame = 0; | 114 m_dartActivationFrame = 0; |
105 } | 115 } |
106 | 116 |
107 explicit ActivationFrame(Dart_ActivationFrame activationFrame) | 117 explicit ActivationFrame(Dart_ActivationFrame activationFrame) |
108 { | 118 { |
109 m_isJavaScript = false; | 119 m_isJavaScript = false; |
110 m_dartActivationFrame = activationFrame; | 120 m_dartActivationFrame = activationFrame; |
111 } | 121 } |
112 | 122 |
113 bool isJavaScript() const { return m_isJavaScript; } | 123 bool isJavaScript() const { return m_isJavaScript; } |
124 | |
114 ScriptValue asJavaScript() const | 125 ScriptValue asJavaScript() const |
115 { | 126 { |
116 ASSERT(m_isJavaScript); | 127 ASSERT(m_isJavaScript); |
117 return m_scriptValue; | 128 return m_scriptValue; |
118 } | 129 } |
119 | 130 |
120 Dart_ActivationFrame asDart() const | 131 Dart_ActivationFrame asDart() const |
121 { | 132 { |
122 ASSERT(!m_isJavaScript); | 133 ASSERT(!m_isJavaScript); |
123 return m_dartActivationFrame; | 134 return m_dartActivationFrame; |
124 } | 135 } |
125 | 136 |
126 private: | 137 private: |
127 bool m_isJavaScript; | 138 bool m_isJavaScript; |
128 ScriptValue m_scriptValue; | 139 ScriptValue m_scriptValue; |
129 Dart_ActivationFrame m_dartActivationFrame; | 140 Dart_ActivationFrame m_dartActivationFrame; |
130 }; | 141 }; |
131 | 142 |
143 class StackTraceTimestamp { | |
144 public: | |
145 StackTraceTimestamp(size_t stackDepth); | |
146 | |
147 int64_t timestamp() const { return m_timestamp; } | |
148 size_t stackDepth() const { return m_stackDepth; } | |
vsm
2014/08/13 14:26:45
What is stackDepth supposed to be? The number of
Jacob
2014/08/13 21:36:15
number of frames. perhaps size_t is confusing. I
| |
149 private: | |
150 int64_t m_timestamp; | |
151 size_t m_stackDepth; | |
152 }; | |
153 | |
154 class StackTraceTimestampTracker { | |
155 public: | |
156 void decrementRecursionLevel() { m_samples.removeLast(); } | |
157 | |
158 void incrementRecursionLevel(size_t stackDepth) | |
159 { | |
160 m_samples.append(StackTraceTimestamp(stackDepth)); | |
161 } | |
162 | |
163 size_t recursionLevel() { return m_samples.size(); } | |
164 int64_t getTimestamp(size_t frame); | |
165 private: | |
166 Vector<StackTraceTimestamp> m_samples; | |
167 }; | |
168 | |
132 } // namespace WebCore | 169 } // namespace WebCore |
133 | 170 |
134 #endif // StackTrace_h | 171 #endif // StackTrace_h |
OLD | NEW |