mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
VM reads import uri if kernel binary version >= 22
This CL also includes a service test for setting a breakpoint in a part file from a package. Fixes #35859. Change-Id: I0199006a87746dc1c27721ba0d51e502e76cb107 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97104 Reviewed-by: Siva Annamalai <asiva@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
parent
3c2bfa554a
commit
58882ffdd4
|
@ -62,6 +62,7 @@ mockito:third_party/pkg/mockito/lib
|
|||
mustache:third_party/pkg/mustache/lib
|
||||
oauth2:third_party/pkg/oauth2/lib
|
||||
observatory:runtime/observatory/lib
|
||||
observatory_test_package:runtime/observatory/tests/service/observatory_test_package
|
||||
package_config:third_party/pkg_tested/package_config/lib
|
||||
package_resolver:third_party/pkg_tested/package_resolver/lib
|
||||
path:third_party/pkg/path/lib
|
||||
|
|
|
@ -32,3 +32,4 @@ string_scanner:../../third_party/pkg/string_scanner/lib
|
|||
term_glyph:../../third_party/pkg/term_glyph/lib
|
||||
test:../../third_party/pkg/test/lib
|
||||
typed_data:../../third_party/pkg/typed_data/lib
|
||||
observatory_test_package:tests/service/observatory_test_package
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library breakpoint_in_parts_class;
|
||||
|
||||
import 'package:observatory_test_package/has_part.dart' as hasPart;
|
||||
import 'test_helper.dart';
|
||||
import 'service_test_common.dart';
|
||||
|
||||
const int LINE = 87;
|
||||
const String breakpointFile = "package:observatory_test_package/the_part.dart";
|
||||
const String shortFile = "the_part.dart";
|
||||
|
||||
code() {
|
||||
hasPart.main();
|
||||
}
|
||||
|
||||
List<String> stops = [];
|
||||
|
||||
List<String> expected = [
|
||||
"$shortFile:${LINE + 0}:5", // on 'print'
|
||||
"$shortFile:${LINE + 1}:3" // on class ending '}'
|
||||
];
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtUriAndLine(breakpointFile, LINE),
|
||||
runStepThroughProgramRecordingStops(stops),
|
||||
checkRecordedStops(stops, expected)
|
||||
];
|
||||
|
||||
main(args) {
|
||||
runIsolateTestsSynchronous(args, tests,
|
||||
testeeConcurrent: code, pause_on_start: true, pause_on_exit: true);
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
observatory_test_package:.
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library has_part;
|
||||
|
||||
part 'the_part.dart';
|
||||
|
||||
main() {
|
||||
Foo10 foo = new Foo10("Foo!");
|
||||
print(foo);
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of has_part;
|
||||
|
||||
void foo() {
|
||||
print("lalala");
|
||||
}
|
||||
|
||||
class Foo1 {
|
||||
final foo;
|
||||
|
||||
Foo1(this.foo) {
|
||||
print("hello from foo!");
|
||||
}
|
||||
}
|
||||
|
||||
class Foo2 {
|
||||
final foo;
|
||||
|
||||
Foo2(this.foo) {
|
||||
print("hello from foo!");
|
||||
}
|
||||
}
|
||||
|
||||
class Foo3 {
|
||||
final foo;
|
||||
|
||||
Foo3(this.foo) {
|
||||
print("hello from foo!");
|
||||
}
|
||||
}
|
||||
|
||||
class Foo4 {
|
||||
final foo;
|
||||
|
||||
Foo4(this.foo) {
|
||||
print("hello from foo!");
|
||||
}
|
||||
}
|
||||
|
||||
class Foo5 {
|
||||
final foo;
|
||||
|
||||
Foo5(this.foo) {
|
||||
print("hello from foo!");
|
||||
}
|
||||
}
|
||||
|
||||
class Foo6 {
|
||||
final foo;
|
||||
|
||||
Foo6(this.foo) {
|
||||
print("hello from foo!");
|
||||
}
|
||||
}
|
||||
|
||||
class Foo7 {
|
||||
final foo;
|
||||
|
||||
Foo7(this.foo) {
|
||||
print("hello from foo!");
|
||||
}
|
||||
}
|
||||
|
||||
class Foo8 {
|
||||
final foo;
|
||||
|
||||
Foo8(this.foo) {
|
||||
print("hello from foo!");
|
||||
}
|
||||
}
|
||||
|
||||
class Foo9 {
|
||||
final foo;
|
||||
|
||||
Foo9(this.foo) {
|
||||
print("hello from foo!");
|
||||
}
|
||||
}
|
||||
|
||||
class Foo10 {
|
||||
final foo;
|
||||
|
||||
Foo10(this.foo) {
|
||||
print("hello from foo!");
|
||||
}
|
||||
}
|
||||
|
||||
var foo2 = foo() as dynamic;
|
|
@ -2617,6 +2617,26 @@ RawTypedData* KernelReaderHelper::GetLineStartsFor(intptr_t index) {
|
|||
return line_starts_data.raw();
|
||||
}
|
||||
|
||||
String& KernelReaderHelper::SourceTableImportUriFor(intptr_t index,
|
||||
uint32_t binaryVersion) {
|
||||
if (binaryVersion < 22) {
|
||||
return SourceTableUriFor(index);
|
||||
}
|
||||
|
||||
AlternativeReadingScope alt(&reader_);
|
||||
SetOffset(GetOffsetForSourceInfo(index));
|
||||
SkipBytes(ReadUInt()); // skip uri.
|
||||
SkipBytes(ReadUInt()); // skip source.
|
||||
const intptr_t line_start_count = ReadUInt(); // read number of line start
|
||||
// entries.
|
||||
for (intptr_t i = 0; i < line_start_count; ++i) {
|
||||
ReadUInt();
|
||||
}
|
||||
|
||||
intptr_t size = ReadUInt(); // read import uri List<byte> size.
|
||||
return H.DartString(reader_.BufferAt(ReaderOffset()), size, Heap::kOld);
|
||||
}
|
||||
|
||||
intptr_t ActiveClass::MemberTypeParameterCount(Zone* zone) {
|
||||
ASSERT(member != NULL);
|
||||
if (member->IsFactory()) {
|
||||
|
|
|
@ -1061,6 +1061,7 @@ class KernelReaderHelper {
|
|||
String& SourceTableUriFor(intptr_t index);
|
||||
const String& GetSourceFor(intptr_t index);
|
||||
RawTypedData* GetLineStartsFor(intptr_t index);
|
||||
String& SourceTableImportUriFor(intptr_t index, uint32_t binaryVersion);
|
||||
|
||||
Zone* zone_;
|
||||
TranslationHelper& translation_helper_;
|
||||
|
|
|
@ -73,6 +73,7 @@ class Program {
|
|||
const char** error = nullptr);
|
||||
|
||||
bool is_single_program() { return single_program_; }
|
||||
uint32_t binary_version() { return binary_version_; }
|
||||
NameIndex main_method() { return main_method_reference_; }
|
||||
intptr_t source_table_offset() const { return source_table_offset_; }
|
||||
intptr_t string_table_offset() const { return string_table_offset_; }
|
||||
|
@ -92,6 +93,7 @@ class Program {
|
|||
Program() : kernel_data_(NULL), kernel_data_size_(-1) {}
|
||||
|
||||
bool single_program_;
|
||||
uint32_t binary_version_;
|
||||
NameIndex main_method_reference_; // Procedure.
|
||||
intptr_t library_count_;
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ Program* Program::ReadFrom(Reader* reader, const char** error) {
|
|||
}
|
||||
|
||||
Program* program = new Program();
|
||||
program->binary_version_ = formatVersion;
|
||||
program->kernel_data_ = reader->buffer();
|
||||
program->kernel_data_size_ = reader->size();
|
||||
|
||||
|
|
|
@ -1950,6 +1950,8 @@ const Object& KernelLoader::ClassForScriptAt(const Class& klass,
|
|||
|
||||
RawScript* KernelLoader::LoadScriptAt(intptr_t index) {
|
||||
const String& uri_string = helper_.SourceTableUriFor(index);
|
||||
const String& import_uri_string =
|
||||
helper_.SourceTableImportUriFor(index, program_->binary_version());
|
||||
const String& script_source = helper_.GetSourceFor(index);
|
||||
String& sources = String::Handle(Z);
|
||||
TypedData& line_starts =
|
||||
|
@ -1975,10 +1977,9 @@ RawScript* KernelLoader::LoadScriptAt(intptr_t index) {
|
|||
sources = script_source.raw();
|
||||
}
|
||||
|
||||
const Script& script = Script::Handle(
|
||||
Z, Script::New(uri_string, sources, RawScript::kKernelTag));
|
||||
String& script_url = String::Handle();
|
||||
script_url = script.url();
|
||||
const Script& script =
|
||||
Script::Handle(Z, Script::New(import_uri_string, uri_string, sources,
|
||||
RawScript::kKernelTag));
|
||||
script.set_kernel_script_index(index);
|
||||
script.set_kernel_program_info(kernel_program_info_);
|
||||
script.set_line_starts(line_starts);
|
||||
|
|
Loading…
Reference in a new issue