Chromium Code Reviews| 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 dartino.vm_session; | 5 library dartino.vm_session; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'dart:typed_data' show | 9 import 'dart:typed_data' show |
| 10 ByteData; | 10 ByteData; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 // TODO(sigurdm): for now only the stdio and stderr events are actually | 77 // TODO(sigurdm): for now only the stdio and stderr events are actually |
| 78 // notified. | 78 // notified. |
| 79 abstract class DebugListener { | 79 abstract class DebugListener { |
| 80 // Notification that a new process has started. | 80 // Notification that a new process has started. |
| 81 processStart(int processId) {} | 81 processStart(int processId) {} |
| 82 // Notification that a process is ready to run. | 82 // Notification that a process is ready to run. |
| 83 processRunnable(int processId) {} | 83 processRunnable(int processId) {} |
| 84 // Notification that a process has exited. | 84 // Notification that a process has exited. |
| 85 processExit(int processId) {} | 85 processExit(int processId) {} |
| 86 // A process has paused at start, before executing code. | 86 // A process has paused at start, before executing code. |
| 87 pauseStart(int processId, BackTraceFrame topframe) {} | 87 // This is sent on spawning processes. |
| 88 pauseStart(int processId) {} | |
| 88 // An process has paused at exit, before terminating. | 89 // An process has paused at exit, before terminating. |
| 89 pauseExit(int processId, BackTraceFrame topframe) {} | 90 pauseExit(int processId, BackTraceFrame topFrame) {} |
| 90 // A process has paused at a breakpoint or due to stepping. | 91 // A process has paused at a breakpoint or due to stepping. |
| 91 pauseBreakpoint(int processId, BackTraceFrame topframe, int breakpointId) {} | 92 pauseBreakpoint( |
| 93 int processId, BackTraceFrame topFrame, Breakpoint breakpoint) {} | |
| 92 // A process has paused due to interruption. | 94 // A process has paused due to interruption. |
| 93 pauseInterrupted(int processId, BackTraceFrame topframe) {} | 95 pauseInterrupted(int processId, BackTraceFrame topFrame) {} |
| 94 // A process has paused due to an exception. | 96 // A process has paused due to an exception. |
| 95 pauseException(int processId, BackTraceFrame topframe, RemoteObject thrown) {} | 97 pauseException(int processId, BackTraceFrame topFrame, RemoteObject thrown) {} |
| 96 // A process has started or resumed execution. | 98 // A process has started or resumed execution. |
| 97 resume(int processId) {} | 99 resume(int processId) {} |
| 98 // A breakpoint has been added for a process. | 100 // A breakpoint has been added for a process. |
| 99 breakpointAdded(int processId, Breakpoint breakpoint) {} | 101 breakpointAdded(int processId, Breakpoint breakpoint) {} |
| 100 // A breakpoint has been removed. | 102 // A breakpoint has been removed. |
| 101 breakpointRemoved(int processId, Breakpoint breakpoint) {} | 103 breakpointRemoved(int processId, Breakpoint breakpoint) {} |
| 102 // A garbage collection event. | 104 // A garbage collection event. |
| 103 gc(int processId) {} | 105 gc(int processId) {} |
| 104 // Notification of bytes written to stdout. | 106 // Notification of bytes written to stdout. |
| 105 writeStdOut(int processId, List<int> data) {} | 107 writeStdOut(int processId, List<int> data) {} |
| 106 // Notification of bytes written stderr. | 108 // Notification of bytes written stderr. |
| 107 writeStdErr(int processId, List<int> data) {} | 109 writeStdErr(int processId, List<int> data) {} |
| 108 // The connection to the vm was lost. | 110 // The connection to the vm was lost. |
| 109 lostConnection() {} | 111 lostConnection() {} |
| 112 // The debugged program is over. | |
| 113 terminated() {} | |
| 110 } | 114 } |
| 111 | 115 |
| 112 class SinkDebugListener extends DebugListener { | 116 class SinkDebugListener extends DebugListener { |
| 113 final Sink stdoutSink; | 117 final Sink stdoutSink; |
| 114 final Sink stderrSink; | 118 final Sink stderrSink; |
| 115 SinkDebugListener(this.stdoutSink, this.stderrSink); | 119 SinkDebugListener(this.stdoutSink, this.stderrSink); |
| 116 | 120 |
| 117 writeStdOut(int processId, List<int> data) { | 121 writeStdOut(int processId, List<int> data) { |
| 118 stdoutSink.add(data); | 122 stdoutSink.add(data); |
| 119 } | 123 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 while (!_drainedIncomingCommands) { | 305 while (!_drainedIncomingCommands) { |
| 302 VmCommand response = await readNextCommand(force: false); | 306 VmCommand response = await readNextCommand(force: false); |
| 303 if (!ignoreExtraCommands && response != null) { | 307 if (!ignoreExtraCommands && response != null) { |
| 304 await kill(); | 308 await kill(); |
| 305 throw new StateError( | 309 throw new StateError( |
| 306 "Got unexpected command from dartino-vm during shutdown " | 310 "Got unexpected command from dartino-vm during shutdown " |
| 307 "($response)"); | 311 "($response)"); |
| 308 } | 312 } |
| 309 } | 313 } |
| 310 vmState = VmState.terminated; | 314 vmState = VmState.terminated; |
| 315 listeners.forEach((DebugListener listener) { | |
| 316 listener.terminated(); | |
| 317 }); | |
|
Søren Gjesse
2016/06/13 13:06:30
Would it make sense to have a method for this iter
sigurdm
2016/06/14 08:17:21
Done
| |
| 311 return connection.done; | 318 return connection.done; |
| 312 } | 319 } |
| 313 | 320 |
| 314 Future interrupt() { | 321 Future interrupt() { |
| 315 return sendCommand(const ProcessDebugInterrupt()); | 322 return sendCommand(const ProcessDebugInterrupt()); |
| 316 } | 323 } |
| 317 | 324 |
| 318 /// Closes the connection to the dartino-vm. It does not wait until it shuts | 325 /// Closes the connection to the dartino-vm. It does not wait until it shuts |
| 319 /// down. | 326 /// down. |
| 320 /// | 327 /// |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 VmCommand reply = await runCommand(const Debugging()); | 409 VmCommand reply = await runCommand(const Debugging()); |
| 403 if (reply == null || reply is! DebuggingReply) { | 410 if (reply == null || reply is! DebuggingReply) { |
| 404 throw new Exception("Expected a reply from the debugging command"); | 411 throw new Exception("Expected a reply from the debugging command"); |
| 405 } | 412 } |
| 406 return reply; | 413 return reply; |
| 407 } | 414 } |
| 408 | 415 |
| 409 Future spawnProcess(List<String> arguments) async { | 416 Future spawnProcess(List<String> arguments) async { |
| 410 await runCommand(new ProcessSpawnForMain(arguments)); | 417 await runCommand(new ProcessSpawnForMain(arguments)); |
| 411 vmState = VmState.spawned; | 418 vmState = VmState.spawned; |
| 419 listeners.forEach((DebugListener listener) { | |
| 420 listener.pauseStart(0); | |
| 421 listener.processRunnable(0); | |
| 422 }); | |
| 412 } | 423 } |
| 413 | 424 |
| 414 /// Returns the [NameOffsetMapping] stored in the '.info.json' adjacent to a | 425 /// Returns the [NameOffsetMapping] stored in the '.info.json' adjacent to a |
| 415 /// snapshot location. | 426 /// snapshot location. |
| 416 Future<NameOffsetMapping> getInfoFromSnapshotLocation(Uri snapshot) async { | 427 Future<NameOffsetMapping> getInfoFromSnapshotLocation(Uri snapshot) async { |
| 417 Uri info = snapshot.replace(path: "${snapshot.path}.info.json"); | 428 Uri info = snapshot.replace(path: "${snapshot.path}.info.json"); |
| 418 File infoFile = new File.fromUri(info); | 429 File infoFile = new File.fromUri(info); |
| 419 | 430 |
| 420 if (!await infoFile.exists()) { | 431 if (!await infoFile.exists()) { |
| 421 await shutdown(); | 432 await shutdown(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 // This method handles the various responses a command can return to indicate | 511 // This method handles the various responses a command can return to indicate |
| 501 // the process has stopped running. | 512 // the process has stopped running. |
| 502 // The session's state is updated to match the current state of the vm. | 513 // The session's state is updated to match the current state of the vm. |
| 503 Future<VmCommand> handleProcessStop(VmCommand response) async { | 514 Future<VmCommand> handleProcessStop(VmCommand response) async { |
| 504 interactiveExitCode = exit_codes.COMPILER_EXITCODE_CRASH; | 515 interactiveExitCode = exit_codes.COMPILER_EXITCODE_CRASH; |
| 505 debugState.reset(); | 516 debugState.reset(); |
| 506 switch (response.code) { | 517 switch (response.code) { |
| 507 case VmCommandCode.UncaughtException: | 518 case VmCommandCode.UncaughtException: |
| 508 interactiveExitCode = exit_codes.DART_VM_EXITCODE_UNCAUGHT_EXCEPTION; | 519 interactiveExitCode = exit_codes.DART_VM_EXITCODE_UNCAUGHT_EXCEPTION; |
| 509 vmState = VmState.terminating; | 520 vmState = VmState.terminating; |
| 521 UncaughtException command = response; | |
| 522 debugState.currentProcess = command.processId; | |
| 523 var function = dartinoSystem.lookupFunctionById(command.functionId); | |
| 524 debugState.topFrame = new BackTraceFrame( | |
| 525 function, command.bytecodeIndex, compiler, debugState); | |
| 526 RemoteObject thrown = await uncaughtException(); | |
| 527 listeners.forEach((DebugListener listener) { | |
| 528 listener.pauseException( | |
| 529 debugState.currentProcess, debugState.topFrame, thrown); | |
| 530 }); | |
| 510 break; | 531 break; |
| 511 | 532 |
| 512 case VmCommandCode.ProcessCompileTimeError: | 533 case VmCommandCode.ProcessCompileTimeError: |
| 534 listeners.forEach((DebugListener listener) { | |
| 535 listener.pauseException(0, null, null); // XXX | |
|
Søren Gjesse
2016/06/13 13:06:30
What is the XXX comment about?
sigurdm
2016/06/14 08:17:21
About passing the right arguments.
Changed to a pr
| |
| 536 }); | |
| 513 interactiveExitCode = exit_codes.DART_VM_EXITCODE_COMPILE_TIME_ERROR; | 537 interactiveExitCode = exit_codes.DART_VM_EXITCODE_COMPILE_TIME_ERROR; |
| 514 vmState = VmState.terminating; | 538 vmState = VmState.terminating; |
| 515 break; | 539 break; |
| 516 | 540 |
| 517 case VmCommandCode.ProcessTerminated: | 541 case VmCommandCode.ProcessTerminated: |
| 518 interactiveExitCode = 0; | 542 interactiveExitCode = 0; |
| 519 vmState = VmState.terminating; | 543 listeners.forEach((DebugListener listener) { |
| 544 listener.processExit(0); // XXX | |
|
Søren Gjesse
2016/06/13 13:06:30
ditto.
sigurdm
2016/06/14 08:17:21
Ditto
| |
| 545 }); | |
| 520 break; | 546 break; |
| 521 | 547 |
| 522 case VmCommandCode.ConnectionError: | 548 case VmCommandCode.ConnectionError: |
| 523 interactiveExitCode = exit_codes.COMPILER_EXITCODE_CONNECTION_ERROR; | 549 interactiveExitCode = exit_codes.COMPILER_EXITCODE_CONNECTION_ERROR; |
| 524 vmState = VmState.terminating; | 550 vmState = VmState.terminating; |
| 525 await shutdown(); | 551 await shutdown(); |
| 552 listeners.forEach((DebugListener listener) { | |
| 553 listener.lostConnection(); | |
| 554 }); | |
| 526 break; | 555 break; |
| 527 | 556 |
| 528 case VmCommandCode.ProcessBreakpoint: | 557 case VmCommandCode.ProcessBreakpoint: |
| 529 interactiveExitCode = 0; | 558 interactiveExitCode = 0; |
| 530 ProcessBreakpoint command = response; | 559 ProcessBreakpoint command = response; |
| 531 debugState.currentProcess = command.processId; | 560 debugState.currentProcess = command.processId; |
| 532 var function = dartinoSystem.lookupFunctionById(command.functionId); | 561 var function = dartinoSystem.lookupFunctionById(command.functionId); |
| 533 debugState.topFrame = new BackTraceFrame( | 562 debugState.topFrame = new BackTraceFrame( |
| 534 function, command.bytecodeIndex, compiler, debugState); | 563 function, command.bytecodeIndex, compiler, debugState); |
| 535 vmState = VmState.paused; | 564 vmState = VmState.paused; |
| 565 Breakpoint bp = debugState.breakpoints[command.breakpointId]; | |
| 566 if (bp == null) { | |
| 567 listeners.forEach((DebugListener listener) { | |
| 568 listener.pauseInterrupted( | |
| 569 command.processId, | |
| 570 debugState.topFrame); | |
| 571 }); | |
| 572 } else { | |
| 573 listeners.forEach((DebugListener listener) { | |
| 574 listener.pauseBreakpoint( | |
| 575 command.processId, | |
| 576 debugState.topFrame, | |
| 577 bp); | |
| 578 }); | |
| 579 } | |
| 536 break; | 580 break; |
| 537 | 581 |
| 538 default: | 582 default: |
| 539 throw new StateError( | 583 throw new StateError( |
| 540 "Unhandled response from Dartino VM connection: ${response.code}"); | 584 "Unhandled response from Dartino VM connection: ${response.code}"); |
| 541 | 585 |
| 542 } | 586 } |
| 543 return response; | 587 return response; |
| 544 } | 588 } |
| 545 | 589 |
| 546 Future<VmCommand> startRunning() async { | 590 Future<VmCommand> startRunning() async { |
| 547 await sendCommand(const ProcessRun()); | 591 await sendCommand(const ProcessRun()); |
| 548 vmState = VmState.running; | 592 vmState = VmState.running; |
| 593 listeners.forEach((DebugListener listener) { | |
| 594 listener.processStart(0); | |
| 595 }); | |
| 596 listeners.forEach((DebugListener listener) { | |
| 597 listener.processRunnable(0); | |
| 598 }); | |
| 599 listeners.forEach((DebugListener listener) { | |
| 600 listener.resume(0); | |
| 601 }); | |
| 549 return handleProcessStop(await readNextCommand()); | 602 return handleProcessStop(await readNextCommand()); |
| 550 } | 603 } |
| 551 | 604 |
| 552 Future setBreakpointHelper(String name, | 605 Future<Breakpoint> setBreakpointHelper(DartinoFunction function, |
| 553 DartinoFunction function, | |
| 554 int bytecodeIndex) async { | 606 int bytecodeIndex) async { |
| 555 ProcessSetBreakpoint response = await runCommands([ | 607 ProcessSetBreakpoint response = await runCommands([ |
| 556 new PushFromMap(MapId.methods, function.functionId), | 608 new PushFromMap(MapId.methods, function.functionId), |
| 557 new ProcessSetBreakpoint(bytecodeIndex), | 609 new ProcessSetBreakpoint(bytecodeIndex), |
| 558 ]); | 610 ]); |
| 559 int breakpointId = response.value; | 611 int breakpointId = response.value; |
| 560 var breakpoint = new Breakpoint(function, bytecodeIndex, breakpointId); | 612 Breakpoint breakpoint = |
| 613 new Breakpoint(function, bytecodeIndex, breakpointId); | |
| 561 debugState.breakpoints[breakpointId] = breakpoint; | 614 debugState.breakpoints[breakpointId] = breakpoint; |
| 615 listeners.forEach( | |
| 616 (DebugListener listener) => listener.breakpointAdded(0, breakpoint)); | |
| 562 return breakpoint; | 617 return breakpoint; |
| 563 } | 618 } |
| 564 | 619 |
| 565 // TODO(ager): Let setBreakpoint return a stream instead and deal with | 620 // TODO(ager): Let setBreakpoint return a stream instead and deal with |
| 566 // error situations such as bytecode indices that are out of bounds for | 621 // error situations such as bytecode indices that are out of bounds for |
| 567 // some of the methods with the given name. | 622 // some of the methods with the given name. |
| 568 Future setBreakpoint({String methodName, int bytecodeIndex}) async { | 623 Future setBreakpoint({String methodName, int bytecodeIndex}) async { |
| 569 Iterable<DartinoFunction> functions = | 624 Iterable<DartinoFunction> functions = |
| 570 dartinoSystem.functionsWhere((f) => f.name == methodName); | 625 dartinoSystem.functionsWhere((f) => f.name == methodName); |
| 571 List<Breakpoint> breakpoints = []; | 626 List<Breakpoint> breakpoints = []; |
| 572 for (DartinoFunction function in functions) { | 627 for (DartinoFunction function in functions) { |
| 573 breakpoints.add( | 628 breakpoints.add( |
| 574 await setBreakpointHelper(methodName, function, bytecodeIndex)); | 629 await setBreakpointHelper(function, bytecodeIndex)); |
| 575 } | 630 } |
| 576 return breakpoints; | 631 return breakpoints; |
| 577 } | 632 } |
| 578 | 633 |
| 579 Future setFileBreakpointFromPosition(String name, | 634 Future<Breakpoint> setFileBreakpointFromPosition(String name, |
| 580 Uri file, | 635 Uri file, |
| 581 int position) async { | 636 int position) async { |
| 582 if (position == null) { | 637 if (position == null) { |
| 583 return null; | 638 return null; |
| 584 } | 639 } |
| 585 DebugInfo debugInfo = compiler.debugInfoForPosition( | 640 DebugInfo debugInfo = compiler.debugInfoForPosition( |
| 586 file, | 641 file, |
| 587 position, | 642 position, |
| 588 dartinoSystem); | 643 dartinoSystem); |
| 589 if (debugInfo == null) { | 644 if (debugInfo == null) { |
| 590 return null; | 645 return null; |
| 591 } | 646 } |
| 592 SourceLocation location = debugInfo.locationForPosition(position); | 647 SourceLocation location = debugInfo.locationForPosition(position); |
| 593 if (location == null) { | 648 if (location == null) { |
| 594 return null; | 649 return null; |
| 595 } | 650 } |
| 596 DartinoFunction function = debugInfo.function; | 651 DartinoFunction function = debugInfo.function; |
| 597 int bytecodeIndex = location.bytecodeIndex; | 652 int bytecodeIndex = location.bytecodeIndex; |
| 598 return setBreakpointHelper(function.name, function, bytecodeIndex); | 653 return setBreakpointHelper(function, bytecodeIndex); |
| 599 } | 654 } |
| 600 | 655 |
| 601 Future setFileBreakpointFromPattern(Uri file, | 656 Future<Breakpoint> setFileBreakpointFromPattern(Uri file, |
| 602 int line, | 657 int line, |
| 603 String pattern) async { | 658 String pattern) async { |
| 604 assert(line > 0); | 659 assert(line > 0); |
| 605 int position = compiler.positionInFileFromPattern(file, line - 1, pattern); | 660 int position = compiler.positionInFileFromPattern(file, line - 1, pattern); |
| 606 return setFileBreakpointFromPosition( | 661 return setFileBreakpointFromPosition( |
| 607 '$file:$line:$pattern', file, position); | 662 '$file:$line:$pattern', file, position); |
| 608 } | 663 } |
| 609 | 664 |
| 610 Future setFileBreakpoint(Uri file, int line, int column) async { | 665 Future<Breakpoint> setFileBreakpoint(Uri file, int line, int column) async { |
| 611 assert(line > 0 && column > 0); | 666 assert(line > 0 && column > 0); |
| 612 int position = compiler.positionInFile(file, line - 1, column - 1); | 667 int position = compiler.positionInFile(file, line - 1, column - 1); |
| 613 return setFileBreakpointFromPosition('$file:$line:$column', file, position); | 668 return setFileBreakpointFromPosition('$file:$line:$column', file, position); |
| 614 } | 669 } |
| 615 | 670 |
| 616 Future doDeleteOneShotBreakpoint(int processId, int breakpointId) async { | 671 Future<Null> doDeleteOneShotBreakpoint( |
| 672 int processId, int breakpointId) async { | |
| 617 ProcessDeleteBreakpoint response = await runCommand( | 673 ProcessDeleteBreakpoint response = await runCommand( |
| 618 new ProcessDeleteOneShotBreakpoint(processId, breakpointId)); | 674 new ProcessDeleteOneShotBreakpoint(processId, breakpointId)); |
| 619 assert(response.id == breakpointId); | 675 assert(response.id == breakpointId); |
| 620 } | 676 } |
| 621 | 677 |
| 622 Future<Breakpoint> deleteBreakpoint(int id) async { | 678 Future<Breakpoint> deleteBreakpoint(int id) async { |
| 679 assert(!isRunning && !isTerminated); | |
| 623 if (!debugState.breakpoints.containsKey(id)) { | 680 if (!debugState.breakpoints.containsKey(id)) { |
| 624 return null; | 681 return null; |
| 625 } | 682 } |
| 626 ProcessDeleteBreakpoint response = | 683 ProcessDeleteBreakpoint response = |
| 627 await runCommand(new ProcessDeleteBreakpoint(id)); | 684 await runCommand(new ProcessDeleteBreakpoint(id)); |
| 628 assert(response.id == id); | 685 assert(response.id == id); |
| 629 return debugState.breakpoints.remove(id); | 686 Breakpoint breakpoint = debugState.breakpoints.remove(id); |
| 687 listeners.forEach((DebugListener listener) { | |
| 688 listener.breakpointRemoved(0, breakpoint); | |
| 689 }); | |
| 690 return breakpoint; | |
| 630 } | 691 } |
| 631 | 692 |
| 632 List<Breakpoint> breakpoints() { | 693 List<Breakpoint> breakpoints() { |
| 633 assert(debugState.breakpoints != null); | 694 assert(debugState.breakpoints != null); |
| 634 return debugState.breakpoints.values.toList(); | 695 return debugState.breakpoints.values.toList(); |
| 635 } | 696 } |
| 636 | 697 |
| 637 Iterable<Uri> findSourceFiles(Pattern pattern) { | 698 Iterable<Uri> findSourceFiles(Pattern pattern) { |
| 638 return compiler.findSourceFiles(pattern); | 699 return compiler.findSourceFiles(pattern); |
| 639 } | 700 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 response.breakpointId == setBreakpoint.value; | 803 response.breakpointId == setBreakpoint.value; |
| 743 if (!success && !isTerminated && setBreakpoint.value != -1) { | 804 if (!success && !isTerminated && setBreakpoint.value != -1) { |
| 744 // Delete the initial one-time breakpoint as it wasn't hit. | 805 // Delete the initial one-time breakpoint as it wasn't hit. |
| 745 await doDeleteOneShotBreakpoint(processId, setBreakpoint.value); | 806 await doDeleteOneShotBreakpoint(processId, setBreakpoint.value); |
| 746 } | 807 } |
| 747 return response; | 808 return response; |
| 748 } | 809 } |
| 749 | 810 |
| 750 Future<VmCommand> cont() async { | 811 Future<VmCommand> cont() async { |
| 751 assert(isPaused); | 812 assert(isPaused); |
| 813 listeners.forEach((DebugListener listener) { | |
| 814 listener.resume(0); | |
| 815 }); | |
| 752 return handleProcessStop(await runCommand(const ProcessContinue())); | 816 return handleProcessStop(await runCommand(const ProcessContinue())); |
| 753 } | 817 } |
| 754 | 818 |
| 755 bool selectFrame(int frame) { | 819 bool selectFrame(int frame) { |
| 756 if (debugState.currentBackTrace == null || | 820 if (debugState.currentBackTrace == null || |
| 757 debugState.currentBackTrace.actualFrameNumber(frame) == -1) { | 821 debugState.currentBackTrace.actualFrameNumber(frame) == -1) { |
| 758 return false; | 822 return false; |
| 759 } | 823 } |
| 760 debugState.currentFrame = frame; | 824 debugState.currentFrame = frame; |
| 761 return true; | 825 return true; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 791 } else { | 855 } else { |
| 792 assert(response is InstanceStructure); | 856 assert(response is InstanceStructure); |
| 793 List<DartValue> fields = await readInstanceStructureFields(response); | 857 List<DartValue> fields = await readInstanceStructureFields(response); |
| 794 debugState.currentUncaughtException = | 858 debugState.currentUncaughtException = |
| 795 new RemoteInstance(response, fields); | 859 new RemoteInstance(response, fields); |
| 796 } | 860 } |
| 797 } | 861 } |
| 798 return debugState.currentUncaughtException; | 862 return debugState.currentUncaughtException; |
| 799 } | 863 } |
| 800 | 864 |
| 801 Future<BackTrace> backTrace() async { | 865 Future<BackTrace> backTrace({int processId}) async { |
| 866 processId ??= debugState.currentProcess; | |
| 802 assert(isSpawned); | 867 assert(isSpawned); |
| 803 if (debugState.currentBackTrace == null) { | 868 if (debugState.currentBackTrace == null) { |
| 804 ProcessBacktrace backtraceResponse = | 869 ProcessBacktrace backtraceResponse = |
| 805 await runCommand( | 870 await runCommand( |
| 806 new ProcessBacktraceRequest(debugState.currentProcess)); | 871 new ProcessBacktraceRequest(processId)); |
| 807 debugState.currentBackTrace = | 872 debugState.currentBackTrace = |
| 808 stackTraceFromBacktraceResponse(backtraceResponse); | 873 stackTraceFromBacktraceResponse(backtraceResponse); |
| 809 } | 874 } |
| 810 return debugState.currentBackTrace; | 875 return debugState.currentBackTrace; |
| 811 } | 876 } |
| 812 | 877 |
| 813 Future<BackTrace> backtraceForFiber(int fiber) async { | 878 Future<BackTrace> backtraceForFiber(int fiber) async { |
| 814 ProcessBacktrace backtraceResponse = | 879 ProcessBacktrace backtraceResponse = |
| 815 await runCommand(new ProcessFiberBacktraceRequest(fiber)); | 880 await runCommand(new ProcessFiberBacktraceRequest(fiber)); |
| 816 return stackTraceFromBacktraceResponse(backtraceResponse); | 881 return stackTraceFromBacktraceResponse(backtraceResponse); |
| 817 } | 882 } |
| 818 | 883 |
| 819 Future<List<BackTrace>> fibers() async { | 884 Future<List<BackTrace>> fibers() async { |
| 820 assert(isRunning || isPaused); | 885 assert(isRunning || isPaused); |
| 821 await runCommand(const NewMap(MapId.fibers)); | 886 await runCommand(const NewMap(MapId.fibers)); |
| 822 ProcessNumberOfStacks response = | 887 ProcessNumberOfStacks response = |
| 823 await runCommand(const ProcessAddFibersToMap()); | 888 await runCommand(const ProcessAddFibersToMap()); |
| 824 int numberOfFibers = response.value; | 889 int numberOfFibers = response.value; |
| 825 List<BackTrace> stacktraces = new List(numberOfFibers); | 890 List<BackTrace> stacktraces = new List(numberOfFibers); |
| 826 for (int i = 0; i < numberOfFibers; i++) { | 891 for (int i = 0; i < numberOfFibers; i++) { |
| 827 stacktraces[i] = await backtraceForFiber(i); | 892 stacktraces[i] = await backtraceForFiber(i); |
| 828 } | 893 } |
| 829 await runCommand(const DeleteMap(MapId.fibers)); | 894 await runCommand(const DeleteMap(MapId.fibers)); |
| 830 return stacktraces; | 895 return stacktraces; |
| 831 } | 896 } |
| 832 | 897 |
| 833 Future<List<int>> processes() async { | 898 Future<List<int>> processes() async { |
| 834 assert(isRunning || isPaused); | 899 assert(isSpawned); |
| 835 ProcessGetProcessIdsResult response = | 900 ProcessGetProcessIdsResult response = |
| 836 await runCommand(const ProcessGetProcessIds()); | 901 await runCommand(const ProcessGetProcessIds()); |
| 837 return response.ids; | 902 return response.ids; |
| 838 } | 903 } |
| 839 | 904 |
| 840 Future<BackTrace> processStack(int processId) async { | 905 Future<BackTrace> processStack(int processId) async { |
| 841 assert(isPaused); | 906 assert(isPaused); |
| 842 ProcessBacktrace backtraceResponse = | 907 ProcessBacktrace backtraceResponse = |
| 843 await runCommand(new ProcessBacktraceRequest(processId)); | 908 await runCommand(new ProcessBacktraceRequest(processId)); |
| 844 return stackTraceFromBacktraceResponse(backtraceResponse); | 909 return stackTraceFromBacktraceResponse(backtraceResponse); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1058 } | 1123 } |
| 1059 | 1124 |
| 1060 bool toggleInternal() { | 1125 bool toggleInternal() { |
| 1061 debugState.showInternalFrames = !debugState.showInternalFrames; | 1126 debugState.showInternalFrames = !debugState.showInternalFrames; |
| 1062 if (debugState.currentBackTrace != null) { | 1127 if (debugState.currentBackTrace != null) { |
| 1063 debugState.currentBackTrace.visibilityChanged(); | 1128 debugState.currentBackTrace.visibilityChanged(); |
| 1064 } | 1129 } |
| 1065 return debugState.showInternalFrames; | 1130 return debugState.showInternalFrames; |
| 1066 } | 1131 } |
| 1067 } | 1132 } |
| OLD | NEW |