-
Notifications
You must be signed in to change notification settings - Fork 87
Add support for variables in stack frames #479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
57d185f
e87e291
6675035
1cceebf
28ce43f
0b02c7e
64a6121
d5a13c8
a24b113
246afe1
dda2222
129a644
9dd7547
2943bd4
d18c9e7
9ba4f55
a9abbfd
fcaaba6
d77dae9
094889f
e2ee451
3a556eb
db672cd
c8efe59
9d17811
b22df55
c2c751c
4833ddf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,21 +2,24 @@ | |
| // 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.import 'dart:async'; | ||
|
|
||
| import 'dart:math' as math show min; | ||
|
|
||
| import 'package:path/path.dart' as p; | ||
| import 'package:vm_service_lib/vm_service_lib.dart'; | ||
| import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; | ||
|
|
||
| import 'chrome_proxy_service.dart'; | ||
| import 'dart_uri.dart'; | ||
| import 'debugger.dart'; | ||
| import 'domain.dart'; | ||
| import 'helpers.dart'; | ||
|
|
||
| /// An inspector for a running Dart application contained in the | ||
| /// [WipConnection]. | ||
| /// | ||
| /// Provides information about currently loaded scripts and objects and support | ||
| /// for eval. | ||
| class AppInspector { | ||
| class AppInspector extends Domain { | ||
| /// Map of class ID to [Class]. | ||
| final _classes = <String, Class>{}; | ||
|
|
||
|
|
@@ -50,7 +53,13 @@ class AppInspector { | |
| this._assetHandler, | ||
| this._debugger, | ||
| this._root, | ||
| ) : isolateRef = _toIsolateRef(isolate); | ||
| ) : isolateRef = _toIsolateRef(isolate), | ||
| super.forInspector(); | ||
|
|
||
| @override | ||
|
|
||
| /// We are the inspector, so this getter is trivial. | ||
| AppInspector get inspector => this; | ||
|
|
||
| Future<void> _initialize() async { | ||
| isolate.libraries.addAll(await _getLibraryRefs()); | ||
|
|
@@ -146,9 +155,16 @@ function($argsString) { | |
| 'scope': scope, | ||
| }); | ||
| } | ||
| var remoteObject = | ||
| RemoteObject(result.result['result'] as Map<String, dynamic>); | ||
| return await instanceRefFor( | ||
| RemoteObject(result.result['result'] as Map<String, dynamic>)); | ||
| } | ||
|
|
||
| /// Create an [InstanceRef] for the given Chrome [remoteObject]. | ||
| Future<InstanceRef> instanceRefFor(RemoteObject remoteObject) async { | ||
| // If we have a null result, treat it as a reference to null. | ||
| if (remoteObject == null) { | ||
| return _primitiveInstance(InstanceKind.kNull, remoteObject); | ||
| } | ||
| switch (remoteObject.type) { | ||
| case 'string': | ||
| return _primitiveInstance(InstanceKind.kString, remoteObject); | ||
|
|
@@ -157,16 +173,27 @@ function($argsString) { | |
| case 'boolean': | ||
| return _primitiveInstance(InstanceKind.kBool, remoteObject); | ||
| case 'object': | ||
| // TODO: Actual toString() | ||
| var toString = 'Placeholder for toString() result'; | ||
| // TODO: Make the truncation consistent with the VM. | ||
| var truncated = toString.substring(0, math.min(100, toString.length)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious where this 100 value is coming from.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's completely arbitrary. Added a TODO to make that consistent with what the VM does. |
||
| return InstanceRef() | ||
| ..kind = InstanceKind.kPlainInstance | ||
| ..id = remoteObject.objectId | ||
| ..valueAsString = toString | ||
| ..valueAsStringIsTruncated = truncated.length != toString.length | ||
| // TODO(jakemac): Create a real ClassRef, we need a way of looking | ||
| // up the library for a given instance to create it though. | ||
| // https://github.com/dart-lang/sdk/issues/36771. | ||
| ..classRef = ClassRef(); | ||
| default: | ||
| throw UnsupportedError( | ||
| 'Unsupported response type ${remoteObject.type}'); | ||
| // Return unsupported types as a String placeholder for now. | ||
| var unsupported = RemoteObject({ | ||
| 'type': 'String', | ||
| 'value': | ||
| 'Unsupported type:${remoteObject.type} (${remoteObject.description})' | ||
| }); | ||
| return _primitiveInstance(InstanceKind.kString, unsupported); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -189,7 +216,6 @@ function($argsString) { | |
| if (clazz != null) return clazz; | ||
| var scriptRef = _scriptRefs[objectId]; | ||
| if (scriptRef != null) return await _getScript(isolateId, scriptRef); | ||
|
|
||
| throw UnsupportedError( | ||
| 'Only libraries and classes are supported for getObject'); | ||
| } | ||
|
|
@@ -350,10 +376,7 @@ function($argsString) { | |
|
|
||
| /// Returns all scripts in the isolate. | ||
| Future<List<ScriptRef>> scriptRefs(String isolateId) async { | ||
| if (isolateId != isolate.id) { | ||
| throw ArgumentError.value( | ||
| isolateId, 'isolateId', 'Unrecognized isolate id'); | ||
| } | ||
| checkIsolate(isolateId); | ||
| var scripts = <ScriptRef>[]; | ||
| for (var lib in isolate.libraries) { | ||
| // We can't provide the source for `dart:` imports so ignore for now. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // 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.import 'dart:async'; | ||
|
|
||
| /// A library for WebKit mirror objects and support code. These probably should | ||
| /// get migrated into webkit_inspection_protocol over time. | ||
| import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we not depend on this package for this abstraction? This will become problematic as we make use of the Chrome Debug Extension.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It needs that now because it can return RemoteObject from that package for its values. My thought was more to fold this into that package than to re-implement what it does. Why is it problematic if we use the extension? Is the extension going to use an incompatible protocol?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed offline. We'll likely reuse the abstractions provided by webkit_inspection_protocol but change out the actual communication layer. |
||
|
|
||
| /// Represents a property of an object. | ||
| class Property { | ||
| final Map<String, dynamic> _map; | ||
|
|
||
| Property(this._map); | ||
|
|
||
| /// The remote object value in unwrapped form. | ||
| /// | ||
| /// Useful for getting access to properties of particular types of | ||
| /// RemoteObject. | ||
| Map<String, dynamic> get rawValue => _map['value'] as Map<String, dynamic>; | ||
|
|
||
| /// Remote object value in case of primitive values or JSON values (if it was | ||
| /// requested). (optional) | ||
| RemoteObject get value => RemoteObject(rawValue); | ||
|
|
||
| /// The name of the property | ||
| String get name => _map['name'] as String; | ||
|
|
||
| @override | ||
| String toString() => '$name $value'; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.