| 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 fletchc.verbs.debug_verb; | 5 library dartino_compiler.verbs.debug_verb; |
| 6 | 6 |
| 7 import 'dart:core' hide | 7 import 'dart:core' hide |
| 8 StackTrace; | 8 StackTrace; |
| 9 | 9 |
| 10 import 'infrastructure.dart'; | 10 import 'infrastructure.dart'; |
| 11 | 11 |
| 12 import 'dart:async' show | 12 import 'dart:async' show |
| 13 Stream, | 13 Stream, |
| 14 StreamController, | 14 StreamController, |
| 15 StreamIterator; | 15 StreamIterator; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 import '../worker/developer.dart' show | 27 import '../worker/developer.dart' show |
| 28 ClientEventHandler, | 28 ClientEventHandler, |
| 29 handleSignal, | 29 handleSignal, |
| 30 compileAndAttachToVmThen, | 30 compileAndAttachToVmThen, |
| 31 setupClientInOut; | 31 setupClientInOut; |
| 32 | 32 |
| 33 import '../hub/client_commands.dart' show | 33 import '../hub/client_commands.dart' show |
| 34 ClientCommandCode; | 34 ClientCommandCode; |
| 35 | 35 |
| 36 import 'package:fletchc/debug_state.dart' show | 36 import 'package:dartino_compiler/debug_state.dart' show |
| 37 Breakpoint; | 37 Breakpoint; |
| 38 | 38 |
| 39 import '../../debug_state.dart' show | 39 import '../../debug_state.dart' show |
| 40 RemoteObject, | 40 RemoteObject, |
| 41 RemoteValue, | 41 RemoteValue, |
| 42 BackTrace; | 42 BackTrace; |
| 43 | 43 |
| 44 import '../../vm_commands.dart' show | 44 import '../../vm_commands.dart' show |
| 45 VmCommand; | 45 VmCommand; |
| 46 | 46 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 243 } |
| 244 | 244 |
| 245 Future<int> interactiveDebuggerTask( | 245 Future<int> interactiveDebuggerTask( |
| 246 SessionState state, | 246 SessionState state, |
| 247 Uri base, | 247 Uri base, |
| 248 StreamController stdinController) async { | 248 StreamController stdinController) async { |
| 249 Session session = state.session; | 249 Session session = state.session; |
| 250 if (session == null) { | 250 if (session == null) { |
| 251 throwFatalError(DiagnosticKind.attachToVmBeforeRun); | 251 throwFatalError(DiagnosticKind.attachToVmBeforeRun); |
| 252 } | 252 } |
| 253 List<FletchDelta> compilationResult = state.compilationResults; | 253 List<DartinoDelta> compilationResult = state.compilationResults; |
| 254 if (compilationResult.isEmpty) { | 254 if (compilationResult.isEmpty) { |
| 255 throwFatalError(DiagnosticKind.compileBeforeRun); | 255 throwFatalError(DiagnosticKind.compileBeforeRun); |
| 256 } | 256 } |
| 257 | 257 |
| 258 // Make sure current state's session is not reused if invoked again. | 258 // Make sure current state's session is not reused if invoked again. |
| 259 state.session = null; | 259 state.session = null; |
| 260 | 260 |
| 261 for (FletchDelta delta in compilationResult) { | 261 for (DartinoDelta delta in compilationResult) { |
| 262 await session.applyDelta(delta); | 262 await session.applyDelta(delta); |
| 263 } | 263 } |
| 264 | 264 |
| 265 Stream<String> inputStream = stdinController.stream | 265 Stream<String> inputStream = stdinController.stream |
| 266 .transform(UTF8.decoder) | 266 .transform(UTF8.decoder) |
| 267 .transform(new LineSplitter()); | 267 .transform(new LineSplitter()); |
| 268 | 268 |
| 269 return await session.debug(inputStream, base, state); | 269 return await session.debug(inputStream, base, state); |
| 270 } | 270 } |
| 271 | 271 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 if (session == null) { | 342 if (session == null) { |
| 343 throwFatalError(DiagnosticKind.attachToVmBeforeRun); | 343 throwFatalError(DiagnosticKind.attachToVmBeforeRun); |
| 344 } | 344 } |
| 345 state.attachCommandSender(commandSender); | 345 state.attachCommandSender(commandSender); |
| 346 return session; | 346 return session; |
| 347 } | 347 } |
| 348 | 348 |
| 349 Future<int> runToMainDebuggerTask( | 349 Future<int> runToMainDebuggerTask( |
| 350 CommandSender commandSender, | 350 CommandSender commandSender, |
| 351 SessionState state) async { | 351 SessionState state) async { |
| 352 List<FletchDelta> compilationResults = state.compilationResults; | 352 List<DartinoDelta> compilationResults = state.compilationResults; |
| 353 Session session = state.session; | 353 Session session = state.session; |
| 354 if (session == null) { | 354 if (session == null) { |
| 355 throwFatalError(DiagnosticKind.attachToVmBeforeRun); | 355 throwFatalError(DiagnosticKind.attachToVmBeforeRun); |
| 356 } | 356 } |
| 357 if (session.loaded) { | 357 if (session.loaded) { |
| 358 // We cannot reuse a session that has already been loaded. Loading | 358 // We cannot reuse a session that has already been loaded. Loading |
| 359 // currently implies that some of the code has been run. | 359 // currently implies that some of the code has been run. |
| 360 throwFatalError(DiagnosticKind.sessionInvalidState, | 360 throwFatalError(DiagnosticKind.sessionInvalidState, |
| 361 sessionName: state.name); | 361 sessionName: state.name); |
| 362 } | 362 } |
| 363 if (compilationResults.isEmpty) { | 363 if (compilationResults.isEmpty) { |
| 364 throwFatalError(DiagnosticKind.compileBeforeRun); | 364 throwFatalError(DiagnosticKind.compileBeforeRun); |
| 365 } | 365 } |
| 366 | 366 |
| 367 state.attachCommandSender(commandSender); | 367 state.attachCommandSender(commandSender); |
| 368 for (FletchDelta delta in compilationResults) { | 368 for (DartinoDelta delta in compilationResults) { |
| 369 await session.applyDelta(delta); | 369 await session.applyDelta(delta); |
| 370 } | 370 } |
| 371 | 371 |
| 372 await session.enableDebugger(); | 372 await session.enableDebugger(); |
| 373 await session.spawnProcess(); | 373 await session.spawnProcess(); |
| 374 await session.setBreakpoint(methodName: "main", bytecodeIndex: 0); | 374 await session.setBreakpoint(methodName: "main", bytecodeIndex: 0); |
| 375 await session.debugRun(); | 375 await session.debugRun(); |
| 376 | 376 |
| 377 return 0; | 377 return 0; |
| 378 } | 378 } |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 | 703 |
| 704 if (argument != 'internal') { | 704 if (argument != 'internal') { |
| 705 // TODO(ager, lukechurch): Fix error reporting. | 705 // TODO(ager, lukechurch): Fix error reporting. |
| 706 throwInternalError("Invalid argument to toggle. " | 706 throwInternalError("Invalid argument to toggle. " |
| 707 "Valid arguments: 'internal'."); | 707 "Valid arguments: 'internal'."); |
| 708 } | 708 } |
| 709 await session.toggleInternal(); | 709 await session.toggleInternal(); |
| 710 | 710 |
| 711 return 0; | 711 return 0; |
| 712 } | 712 } |
| OLD | NEW |