Commit 03ba73e4 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[inspector] Report length and endColumn correctly for Wasm.

Previously both the length and the endColumn for Wasm scripts were
reported as 0, and that was sort of okayish, since the front-end
was ignoring both of these fields in case of Wasm, and was applying
special cases. But these special casing lead to some subtle bugs,
and this is the first step towards a more uniform treatment.

Source positions for Wasm are in terms of the bytecode, and the
column field contains the bytecode offset here, while the line
number field is always 0. Hence we send 0 for both startLine and
endLine as before, but endColumn now corresponds to the bytecode
size.

Bug: chromium:1056632
Change-Id: Ia8a9cfe454ed250b87a524f5cbcbbbe242205db6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2215817
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67997}
parent 1646c9be
......@@ -1581,8 +1581,6 @@ void V8DebuggerAgentImpl::didParseSource(
return;
}
// TODO(herhut, dgozman): Report correct length for Wasm if needed for
// coverage. Or do not send the length at all and change coverage instead.
if (scriptRef->isSourceLoadedLazily()) {
m_frontend.scriptParsed(
scriptId, scriptURL, 0, 0, 0, 0, contextId, scriptRef->hash(),
......
......@@ -148,9 +148,14 @@ class ActualScript : public V8DebuggerScript {
}
bool isSourceLoadedLazily() const override { return false; }
int length() const override {
auto script = this->script();
if (script->IsWasm()) {
return static_cast<int>(
v8::debug::WasmScript::Cast(*script)->Bytecode().size());
}
v8::HandleScope scope(m_isolate);
v8::Local<v8::String> v8Source;
return script()->Source().ToLocal(&v8Source) ? v8Source->Length() : 0;
return script->Source().ToLocal(&v8Source) ? v8Source->Length() : 0;
}
const String16& sourceMappingURL() const override {
......@@ -290,6 +295,12 @@ class ActualScript : public V8DebuggerScript {
} else {
m_endColumn = source_length + m_startColumn;
}
} else if (script->IsWasm()) {
DCHECK_EQ(0, m_startLine);
DCHECK_EQ(0, m_startColumn);
m_endLine = 0;
m_endColumn = static_cast<int>(
v8::debug::WasmScript::Cast(*script)->Bytecode().size());
} else {
m_endLine = m_startLine;
m_endColumn = m_startColumn;
......
Tests how wasm scripts are reported
Check that each inspector gets a wasm script at module creation time.
Session #1: Script #0 parsed. URL: wasm://wasm/7b04570e. Script ID: 0, Source map URL: , debug symbols: None:undefined. module begin: 0, module end: 0, code offset: 34
Session #2: Script #0 parsed. URL: wasm://wasm/7b04570e. Script ID: 0, Source map URL: , debug symbols: None:undefined. module begin: 0, module end: 0, code offset: 34
Session #1: Script #1 parsed. URL: wasm://wasm/7b04570e. Script ID: 0, Source map URL: , debug symbols: None:undefined. module begin: 0, module end: 0, code offset: 34
Session #2: Script #1 parsed. URL: wasm://wasm/7b04570e. Script ID: 0, Source map URL: , debug symbols: None:undefined. module begin: 0, module end: 0, code offset: 34
Session #1: Script #2 parsed. URL: wasm://wasm/5e8bdc5a. Script ID: 1, Source map URL: , debug symbols: ExternalDWARF:abc. module begin: 0, module end: 0, code offset: 34
Session #2: Script #2 parsed. URL: wasm://wasm/5e8bdc5a. Script ID: 1, Source map URL: , debug symbols: ExternalDWARF:abc. module begin: 0, module end: 0, code offset: 34
Session #1: Script #3 parsed. URL: wasm://wasm/ba7c35be. Script ID: 2, Source map URL: , debug symbols: EmbeddedDWARF:undefined. module begin: 0, module end: 0, code offset: 34
Session #2: Script #3 parsed. URL: wasm://wasm/ba7c35be. Script ID: 2, Source map URL: , debug symbols: EmbeddedDWARF:undefined. module begin: 0, module end: 0, code offset: 34
Session #1: Script #4 parsed. URL: wasm://wasm/1baa71fe. Script ID: 3, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 0, code offset: 34
Session #2: Script #4 parsed. URL: wasm://wasm/1baa71fe. Script ID: 3, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 0, code offset: 34
Session #1: Script #5 parsed. URL: wasm://wasm/0f5a61aa. Script ID: 4, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 0, code offset: 34
Session #2: Script #5 parsed. URL: wasm://wasm/0f5a61aa. Script ID: 4, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 0, code offset: 34
Session #1: Script #6 parsed. URL: wasm://wasm/2b982afe. Script ID: 5, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 0, code offset: 34
Session #2: Script #6 parsed. URL: wasm://wasm/2b982afe. Script ID: 5, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 0, code offset: 34
Session #1: Script #7 parsed. URL: wasm://wasm/63e4f84a. Script ID: 6, Source map URL: , debug symbols: ExternalDWARF:abc. module begin: 0, module end: 0, code offset: 34
Session #2: Script #7 parsed. URL: wasm://wasm/63e4f84a. Script ID: 6, Source map URL: , debug symbols: ExternalDWARF:abc. module begin: 0, module end: 0, code offset: 34
Session #1: Script #8 parsed. URL: wasm://wasm/2c194a36. Script ID: 7, Source map URL: , debug symbols: ExternalDWARF:abc. module begin: 0, module end: 0, code offset: 34
Session #2: Script #8 parsed. URL: wasm://wasm/2c194a36. Script ID: 7, Source map URL: , debug symbols: ExternalDWARF:abc. module begin: 0, module end: 0, code offset: 34
Session #1: Script #9 parsed. URL: wasm://wasm/95e97206. Script ID: 8, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 0, code offset: 34
Session #2: Script #9 parsed. URL: wasm://wasm/95e97206. Script ID: 8, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 0, code offset: 34
Session #1: Script #10 parsed. URL: wasm://wasm/7ab47392. Script ID: 9, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 0, code offset: 34
Session #2: Script #10 parsed. URL: wasm://wasm/7ab47392. Script ID: 9, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 0, code offset: 34
Session #1: Script #0 parsed. URL: wasm://wasm/7b04570e. Script ID: 0, Source map URL: , debug symbols: None:undefined. module begin: 0, module end: 77, code offset: 34
Session #2: Script #0 parsed. URL: wasm://wasm/7b04570e. Script ID: 0, Source map URL: , debug symbols: None:undefined. module begin: 0, module end: 77, code offset: 34
Session #1: Script #1 parsed. URL: wasm://wasm/7b04570e. Script ID: 0, Source map URL: , debug symbols: None:undefined. module begin: 0, module end: 77, code offset: 34
Session #2: Script #1 parsed. URL: wasm://wasm/7b04570e. Script ID: 0, Source map URL: , debug symbols: None:undefined. module begin: 0, module end: 77, code offset: 34
Session #1: Script #2 parsed. URL: wasm://wasm/5e8bdc5a. Script ID: 1, Source map URL: , debug symbols: ExternalDWARF:abc. module begin: 0, module end: 104, code offset: 34
Session #2: Script #2 parsed. URL: wasm://wasm/5e8bdc5a. Script ID: 1, Source map URL: , debug symbols: ExternalDWARF:abc. module begin: 0, module end: 104, code offset: 34
Session #1: Script #3 parsed. URL: wasm://wasm/ba7c35be. Script ID: 2, Source map URL: , debug symbols: EmbeddedDWARF:undefined. module begin: 0, module end: 96, code offset: 34
Session #2: Script #3 parsed. URL: wasm://wasm/ba7c35be. Script ID: 2, Source map URL: , debug symbols: EmbeddedDWARF:undefined. module begin: 0, module end: 96, code offset: 34
Session #1: Script #4 parsed. URL: wasm://wasm/1baa71fe. Script ID: 3, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 100, code offset: 34
Session #2: Script #4 parsed. URL: wasm://wasm/1baa71fe. Script ID: 3, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 100, code offset: 34
Session #1: Script #5 parsed. URL: wasm://wasm/0f5a61aa. Script ID: 4, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 127, code offset: 34
Session #2: Script #5 parsed. URL: wasm://wasm/0f5a61aa. Script ID: 4, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 127, code offset: 34
Session #1: Script #6 parsed. URL: wasm://wasm/2b982afe. Script ID: 5, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 127, code offset: 34
Session #2: Script #6 parsed. URL: wasm://wasm/2b982afe. Script ID: 5, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 127, code offset: 34
Session #1: Script #7 parsed. URL: wasm://wasm/63e4f84a. Script ID: 6, Source map URL: , debug symbols: ExternalDWARF:abc. module begin: 0, module end: 123, code offset: 34
Session #2: Script #7 parsed. URL: wasm://wasm/63e4f84a. Script ID: 6, Source map URL: , debug symbols: ExternalDWARF:abc. module begin: 0, module end: 123, code offset: 34
Session #1: Script #8 parsed. URL: wasm://wasm/2c194a36. Script ID: 7, Source map URL: , debug symbols: ExternalDWARF:abc. module begin: 0, module end: 123, code offset: 34
Session #2: Script #8 parsed. URL: wasm://wasm/2c194a36. Script ID: 7, Source map URL: , debug symbols: ExternalDWARF:abc. module begin: 0, module end: 123, code offset: 34
Session #1: Script #9 parsed. URL: wasm://wasm/95e97206. Script ID: 8, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 119, code offset: 34
Session #2: Script #9 parsed. URL: wasm://wasm/95e97206. Script ID: 8, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 119, code offset: 34
Session #1: Script #10 parsed. URL: wasm://wasm/7ab47392. Script ID: 9, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 119, code offset: 34
Session #2: Script #10 parsed. URL: wasm://wasm/7ab47392. Script ID: 9, Source map URL: abc, debug symbols: SourceMap:abc. module begin: 0, module end: 119, code offset: 34
Session #1: Source for wasm://wasm/7b04570e:
Raw: 00 61 73 6d 01 00 00 00 01 07 02 60 00 00 60 00 00 03 03 02 00 01 07 08 01 04 6d 61 69 6e 00 01 0a 0e 02 03 00 01 0b 08 00 02 40 41 02 1a 0b 0b 00 1b 04 6e 61 6d 65 01 14 02 00 0b 6e 6f 70 46 75 6e 63 74 69 6f 6e 01 04 6d 61 69 6e
Imports: []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment