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

Side by Side Diff: pkg/dartino_compiler/lib/vm_commands.dart

Issue 2065933004: Support for accessing arrays in the debugger (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dartino 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library dartino_compiler.vm_commands; 5 library dartino_compiler.vm_commands;
6 6
7 import 'dart:convert' show 7 import 'dart:convert' show
8 UTF8; 8 UTF8;
9 9
10 import 'dart:typed_data' show 10 import 'dart:typed_data' show
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 int floatSize = CommandBuffer.readInt32FromBuffer(buffer, offset); 43 int floatSize = CommandBuffer.readInt32FromBuffer(buffer, offset);
44 offset += 4; 44 offset += 4;
45 int vmState = CommandBuffer.readInt32FromBuffer(buffer, offset); 45 int vmState = CommandBuffer.readInt32FromBuffer(buffer, offset);
46 return new HandShakeResult( 46 return new HandShakeResult(
47 success, version, wordSize, floatSize, VmState.values[vmState]); 47 success, version, wordSize, floatSize, VmState.values[vmState]);
48 case VmCommandCode.InstanceStructure: 48 case VmCommandCode.InstanceStructure:
49 int classId = 49 int classId =
50 translateClass(CommandBuffer.readInt64FromBuffer(buffer, 0)); 50 translateClass(CommandBuffer.readInt64FromBuffer(buffer, 0));
51 int fields = CommandBuffer.readInt32FromBuffer(buffer, 8); 51 int fields = CommandBuffer.readInt32FromBuffer(buffer, 8);
52 return new InstanceStructure(classId, fields); 52 return new InstanceStructure(classId, fields);
53 case VmCommandCode.ArrayStructure:
54 int length = CommandBuffer.readInt32FromBuffer(buffer, 0);
55 return new ArrayStructure(length);
53 case VmCommandCode.Instance: 56 case VmCommandCode.Instance:
54 int classId = translateClass( 57 int classId = translateClass(
55 CommandBuffer.readInt64FromBuffer(buffer, 0)); 58 CommandBuffer.readInt64FromBuffer(buffer, 0));
56 return new Instance(classId); 59 return new Instance(classId);
57 case VmCommandCode.Class: 60 case VmCommandCode.Class:
58 int classId = translateClass( 61 int classId = translateClass(
59 CommandBuffer.readInt64FromBuffer(buffer, 0)); 62 CommandBuffer.readInt64FromBuffer(buffer, 0));
60 return new ClassValue(classId); 63 return new ClassValue(classId);
61 case VmCommandCode.Integer: 64 case VmCommandCode.Integer:
62 int value = CommandBuffer.readInt64FromBuffer(buffer, 0); 65 int value = CommandBuffer.readInt64FromBuffer(buffer, 0);
63 return new Integer(value); 66 return new Integer(value);
64 case VmCommandCode.Double: 67 case VmCommandCode.Double:
65 return new Double(CommandBuffer.readDoubleFromBuffer(buffer, 0)); 68 return new Double(CommandBuffer.readDoubleFromBuffer(buffer, 0));
66 case VmCommandCode.Boolean: 69 case VmCommandCode.Boolean:
67 return new Boolean(CommandBuffer.readBoolFromBuffer(buffer, 0)); 70 return new Boolean(CommandBuffer.readBoolFromBuffer(buffer, 0));
68 case VmCommandCode.Null: 71 case VmCommandCode.Null:
69 return const NullValue(); 72 return const NullValue();
70 case VmCommandCode.String: 73 case VmCommandCode.String:
71 return new StringValue( 74 return new StringValue(
72 CommandBuffer.readStringFromBuffer(buffer, 0, buffer.length)); 75 CommandBuffer.readStringFromBuffer(buffer, 0, buffer.length));
76 case VmCommandCode.Array:
77 int length = CommandBuffer.readInt32FromBuffer(buffer, 0);
78 return new Array(length);
73 case VmCommandCode.StdoutData: 79 case VmCommandCode.StdoutData:
74 return new StdoutData(buffer); 80 return new StdoutData(buffer);
75 case VmCommandCode.StderrData: 81 case VmCommandCode.StderrData:
76 return new StderrData(buffer); 82 return new StderrData(buffer);
77 case VmCommandCode.ObjectId: 83 case VmCommandCode.ObjectId:
78 int id = CommandBuffer.readInt64FromBuffer(buffer, 0); 84 int id = CommandBuffer.readInt64FromBuffer(buffer, 0);
79 return new ObjectId(id); 85 return new ObjectId(id);
80 case VmCommandCode.ProcessBacktrace: 86 case VmCommandCode.ProcessBacktrace:
81 int frames = CommandBuffer.readInt32FromBuffer(buffer, 0); 87 int frames = CommandBuffer.readInt32FromBuffer(buffer, 0);
82 ProcessBacktrace backtrace = new ProcessBacktrace(frames); 88 ProcessBacktrace backtrace = new ProcessBacktrace(frames);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 Int32List classTable = readArray(classEntries); 163 Int32List classTable = readArray(classEntries);
158 164
159 int functionEntries = readInt(); 165 int functionEntries = readInt();
160 Int32List functionTable = readArray(functionEntries); 166 Int32List functionTable = readArray(functionEntries);
161 167
162 return new ProgramInfoCommand(classTable, functionTable, hash); 168 return new ProgramInfoCommand(classTable, functionTable, hash);
163 case VmCommandCode.DebuggingReply: 169 case VmCommandCode.DebuggingReply:
164 bool isFromSnapshot = CommandBuffer.readBoolFromBuffer(buffer, 0); 170 bool isFromSnapshot = CommandBuffer.readBoolFromBuffer(buffer, 0);
165 int snapshotHash = CommandBuffer.readInt32FromBuffer(buffer, 1); 171 int snapshotHash = CommandBuffer.readInt32FromBuffer(buffer, 1);
166 return new DebuggingReply(isFromSnapshot, snapshotHash); 172 return new DebuggingReply(isFromSnapshot, snapshotHash);
173 case VmCommandCode.CommandError:
174 int errorCode = CommandBuffer.readInt32FromBuffer(buffer, 0);
175 return new CommandError(ErrorCode.values[errorCode]);
167 default: 176 default:
168 throw 'Unhandled command in VmCommand.fromBuffer: $code'; 177 throw 'Unhandled command in VmCommand.fromBuffer: $code';
169 } 178 }
170 } 179 }
171 180
172 void addTo(Sink<List<int>> sink, int translateObject( 181 void addTo(Sink<List<int>> sink, int translateObject(
173 MapId mapId, int index)) { 182 MapId mapId, int index)) {
174 internalAddTo(sink, new CommandBuffer<VmCommandCode>(), translateObject); 183 internalAddTo(sink, new CommandBuffer<VmCommandCode>(), translateObject);
175 } 184 }
176 185
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 ..addUint32(fieldAccesses.length); 1202 ..addUint32(fieldAccesses.length);
1194 for (int fieldAccess in fieldAccesses) { 1203 for (int fieldAccess in fieldAccesses) {
1195 buffer.addUint32(fieldAccess); 1204 buffer.addUint32(fieldAccess);
1196 } 1205 }
1197 buffer.sendOn(sink, code); 1206 buffer.sendOn(sink, code);
1198 } 1207 }
1199 1208
1200 /// Peer will respond with a [DartValue]. 1209 /// Peer will respond with a [DartValue].
1201 int get numberOfResponsesExpected => 1; 1210 int get numberOfResponsesExpected => 1;
1202 1211
1203 String valuesToString() => "frame: $frame, slot: $slot"; 1212 String valuesToString() =>
1213 "frame: $frame, slot: $slot, fieldAccesses: $fieldAccesses";
1204 } 1214 }
1205 1215
1206 class ProcessInstanceStructure extends VmCommand { 1216 class ProcessInstanceStructure extends VmCommand {
1207 final int frame; 1217 final int frame;
1208 final int slot; 1218 final int slot;
1209 final List<int> fieldAccesses; 1219 final List<int> fieldAccesses;
1210 1220
1211 const ProcessInstanceStructure(this.frame, this.slot, this.fieldAccesses) 1221 const ProcessInstanceStructure(this.frame, this.slot, this.fieldAccesses)
1212 : super(VmCommandCode.ProcessInstanceStructure); 1222 : super(VmCommandCode.ProcessInstanceStructure);
1213 1223
(...skipping 10 matching lines...) Expand all
1224 } 1234 }
1225 buffer.sendOn(sink, code); 1235 buffer.sendOn(sink, code);
1226 } 1236 }
1227 1237
1228 /// Peer will respond with a [DartValue] or [InstanceStructure] and a number 1238 /// Peer will respond with a [DartValue] or [InstanceStructure] and a number
1229 /// of [DartValue]s. 1239 /// of [DartValue]s.
1230 /// 1240 ///
1231 /// The number of responses is not fixed. 1241 /// The number of responses is not fixed.
1232 int get numberOfResponsesExpected => null; 1242 int get numberOfResponsesExpected => null;
1233 1243
1234 String valuesToString() => "frame: $frame, slot: $slot"; 1244 String valuesToString() =>
1245 "frame: $frame, slot: $slot fieldAccesses: $fieldAccesses";
1235 } 1246 }
1236 1247
1237 class ProcessRestartFrame extends VmCommand { 1248 class ProcessRestartFrame extends VmCommand {
1238 final int frame; 1249 final int frame;
1239 1250
1240 const ProcessRestartFrame(this.frame) 1251 const ProcessRestartFrame(this.frame)
1241 : super(VmCommandCode.ProcessRestartFrame); 1252 : super(VmCommandCode.ProcessRestartFrame);
1242 1253
1243 void internalAddTo( 1254 void internalAddTo(
1244 Sink<List<int>> sink, 1255 Sink<List<int>> sink,
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 CommandBuffer<VmCommandCode> buffer, 1575 CommandBuffer<VmCommandCode> buffer,
1565 int translateObject(MapId mapId, int index)) { 1576 int translateObject(MapId mapId, int index)) {
1566 throw new UnimplementedError(); 1577 throw new UnimplementedError();
1567 } 1578 }
1568 1579
1569 int get numberOfResponsesExpected => 0; 1580 int get numberOfResponsesExpected => 0;
1570 1581
1571 String valuesToString() => "classId: $classId, fields: $fields"; 1582 String valuesToString() => "classId: $classId, fields: $fields";
1572 } 1583 }
1573 1584
1585 class ArrayStructure extends VmCommand {
1586 final int length;
1587 const ArrayStructure(this.length)
1588 : super(VmCommandCode.ArrayStructure);
1589
1590 void internalAddTo(
1591 Sink<List<int>> sink,
1592 CommandBuffer<VmCommandCode> buffer,
1593 int translateObject(MapId mapId, int index)) {
1594 throw new UnimplementedError();
1595 }
1596
1597 int get numberOfResponsesExpected => 0;
1598
1599 String valuesToString() => "length: $length";
1600 }
1601
1574 abstract class DartValue extends VmCommand { 1602 abstract class DartValue extends VmCommand {
1575 const DartValue(VmCommandCode code) 1603 const DartValue(VmCommandCode code)
1576 : super(code); 1604 : super(code);
1577 1605
1578 void internalAddTo( 1606 void internalAddTo(
1579 Sink<List<int>> sink, 1607 Sink<List<int>> sink,
1580 CommandBuffer<VmCommandCode> buffer, 1608 CommandBuffer<VmCommandCode> buffer,
1581 int translateObject(MapId mapId, int index)) { 1609 int translateObject(MapId mapId, int index)) {
1582 throw new UnimplementedError(); 1610 throw new UnimplementedError();
1583 } 1611 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 1686
1659 class StringValue extends DartValue { 1687 class StringValue extends DartValue {
1660 final String value; 1688 final String value;
1661 1689
1662 const StringValue(this.value) 1690 const StringValue(this.value)
1663 : super(VmCommandCode.String); 1691 : super(VmCommandCode.String);
1664 1692
1665 String dartToString() => "'$value'"; 1693 String dartToString() => "'$value'";
1666 } 1694 }
1667 1695
1696 class Array extends DartValue {
1697 final int length;
1698
1699 const Array(this.length)
1700 : super(VmCommandCode.Array);
1701
1702 String dartToString() => "array of length $length";
1703 }
1704
1668 class CommandError extends VmCommand { 1705 class CommandError extends VmCommand {
1669 final ErrorCode errorCode; 1706 final ErrorCode errorCode;
1670 1707
1671 const CommandError(this.errorCode) 1708 const CommandError(this.errorCode)
1672 : super(VmCommandCode.CommandError); 1709 : super(VmCommandCode.CommandError);
1673 1710
1674 int get numberOfResponsesExpected => 0; 1711 int get numberOfResponsesExpected => 0;
1675 1712
1676 String valuesToString() => "command error: $errorCode"; 1713 String valuesToString() => "command error: $errorCode";
1677 } 1714 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 MapLookup, 1830 MapLookup,
1794 ObjectId, 1831 ObjectId,
1795 1832
1796 Integer, 1833 Integer,
1797 Boolean, 1834 Boolean,
1798 Null, 1835 Null,
1799 Double, 1836 Double,
1800 String, 1837 String,
1801 Instance, 1838 Instance,
1802 Class, 1839 Class,
1803 InstanceStructure 1840 Array,
1841 InstanceStructure,
1842 ArrayStructure,
1804 } 1843 }
1805 1844
1806 enum MapId { 1845 enum MapId {
1807 methods, 1846 methods,
1808 classes, 1847 classes,
1809 constants, 1848 constants,
1810 fibers, 1849 fibers,
1811 } 1850 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698