OLD | NEW |
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 fletch.debug_state; | 5 library dartino.debug_state; |
6 | 6 |
7 import 'bytecodes.dart'; | 7 import 'bytecodes.dart'; |
8 import 'fletch_system.dart'; | 8 import 'dartino_system.dart'; |
9 import 'incremental/fletchc_incremental.dart'; | 9 import 'incremental/dartino_compiler_incremental.dart'; |
10 import 'vm_session.dart'; | 10 import 'vm_session.dart'; |
11 import 'src/debug_info.dart'; | 11 import 'src/debug_info.dart'; |
12 import 'src/class_debug_info.dart'; | 12 import 'src/class_debug_info.dart'; |
13 | 13 |
14 import 'vm_commands.dart' show | 14 import 'vm_commands.dart' show |
15 DartValue, | 15 DartValue, |
16 InstanceStructure; | 16 InstanceStructure; |
17 | 17 |
18 import 'src/hub/session_manager.dart' show | 18 import 'src/hub/session_manager.dart' show |
19 SessionState; | 19 SessionState; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 final int id; | 52 final int id; |
53 Breakpoint(this.methodName, this.bytecodeIndex, this.id); | 53 Breakpoint(this.methodName, this.bytecodeIndex, this.id); |
54 String toString() => "id: '$id' method: '$methodName' " | 54 String toString() => "id: '$id' method: '$methodName' " |
55 "bytecode index: '$bytecodeIndex'"; | 55 "bytecode index: '$bytecodeIndex'"; |
56 } | 56 } |
57 | 57 |
58 class DebugState { | 58 class DebugState { |
59 final Session session; | 59 final Session session; |
60 | 60 |
61 final Map<int, Breakpoint> breakpoints = <int, Breakpoint>{}; | 61 final Map<int, Breakpoint> breakpoints = <int, Breakpoint>{}; |
62 final Map<FletchFunction, DebugInfo> debugInfos = | 62 final Map<DartinoFunction, DebugInfo> debugInfos = |
63 <FletchFunction, DebugInfo>{}; | 63 <DartinoFunction, DebugInfo>{}; |
64 final Map<FletchClass, ClassDebugInfo> classDebugInfos = | 64 final Map<DartinoClass, ClassDebugInfo> classDebugInfos = |
65 <FletchClass, ClassDebugInfo>{}; | 65 <DartinoClass, ClassDebugInfo>{}; |
66 | 66 |
67 bool showInternalFrames = false; | 67 bool showInternalFrames = false; |
68 bool verbose = true; | 68 bool verbose = true; |
69 BackTraceFrame _topFrame; | 69 BackTraceFrame _topFrame; |
70 RemoteObject currentUncaughtException; | 70 RemoteObject currentUncaughtException; |
71 BackTrace _currentBackTrace; | 71 BackTrace _currentBackTrace; |
72 int currentFrame = 0; | 72 int currentFrame = 0; |
73 SourceLocation _currentLocation; | 73 SourceLocation _currentLocation; |
74 | 74 |
75 DebugState(this.session); | 75 DebugState(this.session); |
(...skipping 24 matching lines...) Expand all Loading... |
100 _currentBackTrace = backTrace; | 100 _currentBackTrace = backTrace; |
101 } | 101 } |
102 | 102 |
103 BackTraceFrame get topFrame => _topFrame; | 103 BackTraceFrame get topFrame => _topFrame; |
104 | 104 |
105 void set topFrame(BackTraceFrame frame) { | 105 void set topFrame(BackTraceFrame frame) { |
106 _currentLocation = frame.sourceLocation(); | 106 _currentLocation = frame.sourceLocation(); |
107 _topFrame = frame; | 107 _topFrame = frame; |
108 } | 108 } |
109 | 109 |
110 DebugInfo getDebugInfo(FletchFunction function) { | 110 DebugInfo getDebugInfo(DartinoFunction function) { |
111 return debugInfos.putIfAbsent(function, () { | 111 return debugInfos.putIfAbsent(function, () { |
112 return session.compiler.createDebugInfo(function, session.fletchSystem); | 112 return session.compiler.createDebugInfo(function, session.dartinoSystem); |
113 }); | 113 }); |
114 } | 114 } |
115 | 115 |
116 ClassDebugInfo getClassDebugInfo(FletchClass klass) { | 116 ClassDebugInfo getClassDebugInfo(DartinoClass klass) { |
117 return classDebugInfos.putIfAbsent(klass, () { | 117 return classDebugInfos.putIfAbsent(klass, () { |
118 return session.compiler.createClassDebugInfo(klass); | 118 return session.compiler.createClassDebugInfo(klass); |
119 }); | 119 }); |
120 } | 120 } |
121 | 121 |
122 String lookupFieldName(FletchClass klass, int field) { | 122 String lookupFieldName(DartinoClass klass, int field) { |
123 while (field < klass.superclassFields) { | 123 while (field < klass.superclassFields) { |
124 klass = session.fletchSystem.lookupClassById(klass.superclassId); | 124 klass = session.dartinoSystem.lookupClassById(klass.superclassId); |
125 } | 125 } |
126 return getClassDebugInfo(klass).fieldNames[field - klass.superclassFields]; | 126 return getClassDebugInfo(klass).fieldNames[field - klass.superclassFields]; |
127 } | 127 } |
128 | 128 |
129 bool atLocation(SourceLocation previous) { | 129 bool atLocation(SourceLocation previous) { |
130 return (!topFrame.isVisible || | 130 return (!topFrame.isVisible || |
131 currentLocation == null || | 131 currentLocation == null || |
132 currentLocation.isSameSourceLevelLocationAs(previous) || | 132 currentLocation.isSameSourceLevelLocationAs(previous) || |
133 currentLocation.node == null); | 133 currentLocation.node == null); |
134 } | 134 } |
135 | 135 |
136 SourceLocation sourceLocationForFrame(int frame) { | 136 SourceLocation sourceLocationForFrame(int frame) { |
137 return currentBackTrace.frames[frame].sourceLocation(); | 137 return currentBackTrace.frames[frame].sourceLocation(); |
138 } | 138 } |
139 } | 139 } |
OLD | NEW |