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

Side by Side Diff: runtime/observatory/lib/src/service/object.dart

Issue 866663003: Add a working command line debugger to Observatory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of service; 5 part of service;
6 6
7 /// A [ServiceObject] represents a persistent object within the vm. 7 /// A [ServiceObject] represents a persistent object within the vm.
8 abstract class ServiceObject extends Observable { 8 abstract class ServiceObject extends Observable {
9 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { 9 static int LexicalSortName(ServiceObject o1, ServiceObject o2) {
10 return o1.name.compareTo(o2.name); 10 return o1.name.compareTo(o2.name);
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 // Recursively read child nodes. 1015 // Recursively read child nodes.
1016 for (var i = 0; i < children; i++) { 1016 for (var i = 0; i < children; i++) {
1017 var child = _readTrieNode(codeTable); 1017 var child = _readTrieNode(codeTable);
1018 node.children.add(child); 1018 node.children.add(child);
1019 node.summedChildCount += child.count; 1019 node.summedChildCount += child.count;
1020 } 1020 }
1021 return node; 1021 return node;
1022 } 1022 }
1023 1023
1024 // TODO(turnidge): Make this an ObservableList instead. 1024 // TODO(turnidge): Make this an ObservableList instead.
1025 ServiceMap breakpoints; 1025 ObservableList breakpoints = new ObservableList();
Cutch 2015/02/09 21:45:06 comment is out of date now.
turnidge 2015/02/09 21:53:08 Done.
1026 1026
1027 void _removeBreakpoint(ServiceMap bpt) { 1027 void _removeBreakpoint(ServiceMap bpt) {
1028 var script = bpt['location']['script']; 1028 var script = bpt['location']['script'];
1029 var tokenPos = bpt['location']['tokenPos']; 1029 var tokenPos = bpt['location']['tokenPos'];
1030 assert(tokenPos != null); 1030 assert(tokenPos != null);
1031 if (script.loaded) { 1031 if (script.loaded) {
1032 var line = script.tokenToLine(tokenPos); 1032 var line = script.tokenToLine(tokenPos);
1033 assert(line != null); 1033 assert(line != null);
1034 if (script.lines[line - 1] != null) { 1034 if (script.lines[line - 1] != null) {
1035 assert(script.lines[line - 1].bpt == bpt); 1035 assert(script.lines[line - 1].bpt == bpt);
(...skipping 15 matching lines...) Expand all
1051 // Load the script and then plop in the breakpoint. 1051 // Load the script and then plop in the breakpoint.
1052 script.load().then((_) { 1052 script.load().then((_) {
1053 _addBreakpoint(bpt); 1053 _addBreakpoint(bpt);
1054 }); 1054 });
1055 } 1055 }
1056 } 1056 }
1057 1057
1058 void _updateBreakpoints(ServiceMap newBreakpoints) { 1058 void _updateBreakpoints(ServiceMap newBreakpoints) {
1059 // Remove all of the old breakpoints from the Script lines. 1059 // Remove all of the old breakpoints from the Script lines.
1060 if (breakpoints != null) { 1060 if (breakpoints != null) {
1061 for (var bpt in breakpoints['breakpoints']) { 1061 for (var bpt in breakpoints) {
1062 _removeBreakpoint(bpt); 1062 _removeBreakpoint(bpt);
1063 } 1063 }
1064 } 1064 }
1065 // Add all of the new breakpoints to the Script lines. 1065 // Add all of the new breakpoints to the Script lines.
1066 for (var bpt in newBreakpoints['breakpoints']) { 1066 for (var bpt in newBreakpoints['breakpoints']) {
1067 _addBreakpoint(bpt); 1067 _addBreakpoint(bpt);
1068 } 1068 }
1069 breakpoints = newBreakpoints; 1069 breakpoints.clear();
1070 breakpoints.addAll(newBreakpoints['breakpoints']);
1071
1072 // Sort the breakpoints by breakpointNumber.
1073 breakpoints.sort((a, b) => (a['breakpointNumber'] - b['breakpointNumber']));
1070 } 1074 }
1071 1075
1072 Future<ServiceObject> _inProgressReloadBpts; 1076 Future<ServiceObject> _inProgressReloadBpts;
1073 1077
1074 Future reloadBreakpoints() { 1078 Future reloadBreakpoints() {
1075 // TODO(turnidge): Can reusing the Future here ever cause us to 1079 // TODO(turnidge): Can reusing the Future here ever cause us to
1076 // get stale breakpoints? 1080 // get stale breakpoints?
1077 if (_inProgressReloadBpts == null) { 1081 if (_inProgressReloadBpts == null) {
1078 _inProgressReloadBpts = 1082 _inProgressReloadBpts =
1079 invokeRpc('getBreakpoints', {}).then((newBpts) { 1083 invokeRpc('getBreakpoints', {}).then((newBpts) {
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 } 1935 }
1932 } 1936 }
1933 } 1937 }
1934 return true; 1938 return true;
1935 } 1939 }
1936 1940
1937 ScriptLine(this.script, this.line, this.text) { 1941 ScriptLine(this.script, this.line, this.text) {
1938 possibleBpt = !_isTrivialLine(text); 1942 possibleBpt = !_isTrivialLine(text);
1939 1943
1940 // TODO(turnidge): This is not so efficient. Consider improving. 1944 // TODO(turnidge): This is not so efficient. Consider improving.
1941 for (var bpt in this.script.isolate.breakpoints['breakpoints']) { 1945 for (var bpt in this.script.isolate.breakpoints) {
1942 var bptScript = bpt['location']['script']; 1946 var bptScript = bpt['location']['script'];
1943 var bptTokenPos = bpt['location']['tokenPos']; 1947 var bptTokenPos = bpt['location']['tokenPos'];
1944 if (bptScript == this.script && 1948 if (bptScript == this.script &&
1945 bptScript.tokenToLine(bptTokenPos) == line) { 1949 bptScript.tokenToLine(bptTokenPos) == line) {
1946 this.bpt = bpt; 1950 this.bpt = bpt;
1947 } 1951 }
1948 } 1952 }
1949 } 1953 }
1950 } 1954 }
1951 1955
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
2852 var v = list[i]; 2856 var v = list[i];
2853 if ((v is ObservableMap) && _isServiceMap(v)) { 2857 if ((v is ObservableMap) && _isServiceMap(v)) {
2854 list[i] = owner.getFromMap(v); 2858 list[i] = owner.getFromMap(v);
2855 } else if (v is ObservableList) { 2859 } else if (v is ObservableList) {
2856 _upgradeObservableList(v, owner); 2860 _upgradeObservableList(v, owner);
2857 } else if (v is ObservableMap) { 2861 } else if (v is ObservableMap) {
2858 _upgradeObservableMap(v, owner); 2862 _upgradeObservableMap(v, owner);
2859 } 2863 }
2860 } 2864 }
2861 } 2865 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698