Skip to content

Commit

Permalink
[ VM / Service ] Allow for breakpoints to be set using either file: o…
Browse files Browse the repository at this point in the history
…r package: URIs for packages.

Additional minor changes:
- Sorted list of Symbols in symbols.h by name
- Added Symbol::PackageScheme() to symbol list

Change-Id: I2f739bfb5c8cbbe1e318614124695ae45dee4f23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98043
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
  • Loading branch information
bkonyi authored and commit-bot@chromium.org committed Mar 27, 2019
1 parent ffee99d commit ca2f03c
Show file tree
Hide file tree
Showing 6 changed files with 466 additions and 409 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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 'dart:io' show Platform;

import 'package:observatory_test_package/has_part.dart' as hasPart;
import 'package:path/path.dart' as path;
import 'test_helper.dart';
import 'service_test_common.dart';

// Chop off the file name.
String baseDirectory =
path.dirname(Platform.script.path) + Platform.pathSeparator;
Uri baseUri = Platform.script.replace(path: baseDirectory);
Uri breakpointFile = baseUri.resolve('observatory_test_package/the_part.dart');
const String shortFile = "the_part.dart";

const int LINE = 87;

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.toString(), LINE),
runStepThroughProgramRecordingStops(stops),
checkRecordedStops(stops, expected)
];

main(args) {
runIsolateTestsSynchronous(args, tests,
testeeConcurrent: code, pause_on_start: true, pause_on_exit: true);
}
1 change: 1 addition & 0 deletions runtime/observatory/tests/service/service_kernel.status
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ add_breakpoint_rpc_kernel_test: RuntimeError # Issue #34736
async_generator_breakpoint_test: SkipByDesign # No incremental compiler available.
bad_reload_test: Skip # Times out on sim architectures, also RuntimeError.
break_on_activation_test: RuntimeError # Issue #34736
breakpoint_in_package_parts_class_file_uri_test: RuntimeError # Issue #34736
complex_reload_test: Skip # Times out on sim architectures, also RuntimeError.
debugger_inspect_test: RuntimeError, Timeout # Issue #34736
developer_service_get_isolate_id_test: RuntimeError # Issue #34736
Expand Down
6 changes: 4 additions & 2 deletions runtime/vm/debugger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3011,9 +3011,10 @@ BreakpointLocation* Debugger::BreakpointLocationAtLineCol(
GrowableObjectArray::Handle(isolate_->object_store()->libraries());
const GrowableObjectArray& scripts =
GrowableObjectArray::Handle(zone, GrowableObjectArray::New());
bool is_package = script_url.StartsWith(Symbols::PackageScheme());
for (intptr_t i = 0; i < libs.Length(); i++) {
lib ^= libs.At(i);
script = lib.LookupScript(script_url);
script = lib.LookupScript(script_url, !is_package);
if (!script.IsNull()) {
scripts.Add(script);
}
Expand Down Expand Up @@ -3915,9 +3916,10 @@ void Debugger::NotifyDoneLoading() {
while (loc != NULL) {
url = loc->url();
bool found_match = false;
bool is_package = url.StartsWith(Symbols::PackageScheme());
for (intptr_t i = 0; i < libs.Length(); i++) {
lib ^= libs.At(i);
script = lib.LookupScript(url);
script = lib.LookupScript(url, !is_package);
if (!script.IsNull()) {
// Found a script with matching url for this latent breakpoint.
// Unlink the latent breakpoint from the list.
Expand Down
8 changes: 5 additions & 3 deletions runtime/vm/object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10422,10 +10422,12 @@ RawScript* Library::LookupScript(const String& url,
const intptr_t num_scripts = scripts.Length();
for (int i = 0; i < num_scripts; i++) {
script ^= scripts.At(i);
if (!useResolvedUri) {
script_url = script.url();
} else {
if (useResolvedUri) {
// Use for urls with 'org-dartlang-sdk:' or 'file:' schemes
script_url = script.resolved_url();
} else {
// Use for urls with 'dart:', 'package:', or 'file:' schemes
script_url = script.url();
}
const intptr_t start_idx = script_url.Length() - url_length;
if ((start_idx == 0) && url.Equals(script_url)) {
Expand Down
7 changes: 7 additions & 0 deletions runtime/vm/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -3790,6 +3790,13 @@ class Library : public Object {
RawFunction* LookupFunctionAllowPrivate(const String& name) const;
RawFunction* LookupLocalFunction(const String& name) const;
RawLibraryPrefix* LookupLocalLibraryPrefix(const String& name) const;

// Look up a Script based on a url. If 'useResolvedUri' is not provided or is
// false, 'url' should have a 'dart:' scheme for Dart core libraries,
// a 'package:' scheme for packages, and 'file:' scheme otherwise.
//
// If 'useResolvedUri' is true, 'url' should have a 'org-dartlang-sdk:' scheme
// for Dart core libraries and a 'file:' scheme otherwise.
RawScript* LookupScript(const String& url, bool useResolvedUri = false) const;
RawArray* LoadedScripts() const;

Expand Down
Loading

0 comments on commit ca2f03c

Please sign in to comment.