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

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

Issue 2493773003: [inspector] Introduce translation of wasm frames (Closed)
Patch Set: Address Dmitry's comments Created 4 years, 1 month 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
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 #include "src/inspector/v8-stack-trace-impl.h" 5 #include "src/inspector/v8-stack-trace-impl.h"
6 6
7 #include "src/inspector/string-util.h" 7 #include "src/inspector/string-util.h"
8 #include "src/inspector/v8-debugger-agent-impl.h"
8 #include "src/inspector/v8-debugger.h" 9 #include "src/inspector/v8-debugger.h"
9 #include "src/inspector/v8-inspector-impl.h" 10 #include "src/inspector/v8-inspector-impl.h"
10 11
11 #include "include/v8-debug.h" 12 #include "include/v8-debug.h"
12 #include "include/v8-version.h" 13 #include "include/v8-version.h"
13 14
14 namespace v8_inspector { 15 namespace v8_inspector {
15 16
16 namespace { 17 namespace {
17 18
18 static const v8::StackTrace::StackTraceOptions stackTraceOptions = 19 static const v8::StackTrace::StackTraceOptions stackTraceOptions =
19 static_cast<v8::StackTrace::StackTraceOptions>( 20 static_cast<v8::StackTrace::StackTraceOptions>(
20 v8::StackTrace::kLineNumber | v8::StackTrace::kColumnOffset | 21 v8::StackTrace::kLineNumber | v8::StackTrace::kColumnOffset |
21 v8::StackTrace::kScriptId | v8::StackTrace::kScriptNameOrSourceURL | 22 v8::StackTrace::kScriptId | v8::StackTrace::kScriptNameOrSourceURL |
22 v8::StackTrace::kFunctionName); 23 v8::StackTrace::kFunctionName);
23 24
24 V8StackTraceImpl::Frame toFrame(v8::Local<v8::StackFrame> frame) { 25 V8StackTraceImpl::Frame toFrame(v8::Local<v8::StackFrame> frame,
26 WasmTranslation* wasmTranslation,
27 int contextGroupId) {
25 String16 scriptId = String16::fromInteger(frame->GetScriptId()); 28 String16 scriptId = String16::fromInteger(frame->GetScriptId());
26 String16 sourceName; 29 String16 sourceName;
27 v8::Local<v8::String> sourceNameValue(frame->GetScriptNameOrSourceURL()); 30 v8::Local<v8::String> sourceNameValue(frame->GetScriptNameOrSourceURL());
28 if (!sourceNameValue.IsEmpty()) 31 if (!sourceNameValue.IsEmpty())
29 sourceName = toProtocolString(sourceNameValue); 32 sourceName = toProtocolString(sourceNameValue);
30 33
31 String16 functionName; 34 String16 functionName;
32 v8::Local<v8::String> functionNameValue(frame->GetFunctionName()); 35 v8::Local<v8::String> functionNameValue(frame->GetFunctionName());
33 if (!functionNameValue.IsEmpty()) 36 if (!functionNameValue.IsEmpty())
34 functionName = toProtocolString(functionNameValue); 37 functionName = toProtocolString(functionNameValue);
35 38
36 int sourceLineNumber = frame->GetLineNumber(); 39 int sourceLineNumber = frame->GetLineNumber() - 1;
37 int sourceColumn = frame->GetColumn(); 40 int sourceColumn = frame->GetColumn() - 1;
41 wasmTranslation->TranslateWasmScriptLocationToProtocolLocation(
42 &scriptId, &sourceLineNumber, &sourceColumn, contextGroupId);
38 return V8StackTraceImpl::Frame(functionName, scriptId, sourceName, 43 return V8StackTraceImpl::Frame(functionName, scriptId, sourceName,
39 sourceLineNumber, sourceColumn); 44 sourceLineNumber + 1, sourceColumn + 1);
40 } 45 }
41 46
42 void toFramesVector(v8::Local<v8::StackTrace> stackTrace, 47 void toFramesVector(v8::Local<v8::StackTrace> stackTrace,
43 std::vector<V8StackTraceImpl::Frame>& frames, 48 std::vector<V8StackTraceImpl::Frame>& frames,
44 size_t maxStackSize, v8::Isolate* isolate) { 49 size_t maxStackSize, v8::Isolate* isolate,
50 WasmTranslation* wasmTranslation, int contextGroupId) {
45 DCHECK(isolate->InContext()); 51 DCHECK(isolate->InContext());
46 int frameCount = stackTrace->GetFrameCount(); 52 int frameCount = stackTrace->GetFrameCount();
47 if (frameCount > static_cast<int>(maxStackSize)) 53 if (frameCount > static_cast<int>(maxStackSize))
48 frameCount = static_cast<int>(maxStackSize); 54 frameCount = static_cast<int>(maxStackSize);
49 for (int i = 0; i < frameCount; i++) { 55 for (int i = 0; i < frameCount; i++) {
50 v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i); 56 v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i);
51 frames.push_back(toFrame(stackFrame)); 57 frames.push_back(toFrame(stackFrame, wasmTranslation, contextGroupId));
52 } 58 }
53 } 59 }
54 60
55 } // namespace 61 } // namespace
56 62
57 V8StackTraceImpl::Frame::Frame() 63 V8StackTraceImpl::Frame::Frame()
58 : m_functionName("undefined"), 64 : m_functionName("undefined"),
59 m_scriptId(""), 65 m_scriptId(""),
60 m_scriptName("undefined"), 66 m_scriptName("undefined"),
61 m_lineNumber(0), 67 m_lineNumber(0),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 110
105 // static 111 // static
106 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create( 112 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(
107 V8Debugger* debugger, int contextGroupId, 113 V8Debugger* debugger, int contextGroupId,
108 v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize, 114 v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize,
109 const String16& description) { 115 const String16& description) {
110 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 116 v8::Isolate* isolate = v8::Isolate::GetCurrent();
111 v8::HandleScope scope(isolate); 117 v8::HandleScope scope(isolate);
112 std::vector<V8StackTraceImpl::Frame> frames; 118 std::vector<V8StackTraceImpl::Frame> frames;
113 if (!stackTrace.IsEmpty()) 119 if (!stackTrace.IsEmpty())
114 toFramesVector(stackTrace, frames, maxStackSize, isolate); 120 toFramesVector(stackTrace, frames, maxStackSize, isolate,
121 debugger->wasmTranslation(), contextGroupId);
115 122
116 int maxAsyncCallChainDepth = 1; 123 int maxAsyncCallChainDepth = 1;
117 V8StackTraceImpl* asyncCallChain = nullptr; 124 V8StackTraceImpl* asyncCallChain = nullptr;
118 if (debugger && maxStackSize > 1) { 125 if (debugger && maxStackSize > 1) {
119 asyncCallChain = debugger->currentAsyncCallChain(); 126 asyncCallChain = debugger->currentAsyncCallChain();
120 maxAsyncCallChainDepth = debugger->maxAsyncCallChainDepth(); 127 maxAsyncCallChainDepth = debugger->maxAsyncCallChainDepth();
121 } 128 }
122 // Do not accidentally append async call chain from another group. This should 129 // Do not accidentally append async call chain from another group. This should
123 // not 130 // not
124 // happen if we have proper instrumentation, but let's double-check to be 131 // happen if we have proper instrumentation, but let's double-check to be
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 stackTrace.append(String16::fromInteger(frame.lineNumber())); 271 stackTrace.append(String16::fromInteger(frame.lineNumber()));
265 stackTrace.append(':'); 272 stackTrace.append(':');
266 stackTrace.append(String16::fromInteger(frame.columnNumber())); 273 stackTrace.append(String16::fromInteger(frame.columnNumber()));
267 stackTrace.append(')'); 274 stackTrace.append(')');
268 } 275 }
269 String16 string = stackTrace.toString(); 276 String16 string = stackTrace.toString();
270 return StringBufferImpl::adopt(string); 277 return StringBufferImpl::adopt(string);
271 } 278 }
272 279
273 } // namespace v8_inspector 280 } // namespace v8_inspector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698