| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Library used by debugger wire protocol tests (standalone VM debugging). | 5 // Library used by debugger wire protocol tests (standalone VM debugging). |
| 6 | 6 |
| 7 library DartDebugger; | 7 library DartDebugger; |
| 8 | 8 |
| 9 import "dart:async"; | 9 import "dart:async"; |
| 10 import "dart:convert"; | 10 import "dart:convert"; |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 print("Matched locals ${locals.keys}"); | 331 print("Matched locals ${locals.keys}"); |
| 332 } | 332 } |
| 333 } | 333 } |
| 334 | 334 |
| 335 | 335 |
| 336 MatchLocals(Map localValues) { | 336 MatchLocals(Map localValues) { |
| 337 return new LocalsMatcher(localValues); | 337 return new LocalsMatcher(localValues); |
| 338 } | 338 } |
| 339 | 339 |
| 340 | 340 |
| 341 // Used to check if local variables are visible. |
| 342 class AssertLocalsNotVisibleMatcher extends Command { |
| 343 List<String> locals; |
| 344 int frame_index; |
| 345 |
| 346 AssertLocalsNotVisibleMatcher(this.locals, this.frame_index) { |
| 347 template = {"id": 0, "command": "getStackTrace", "params": {"isolateId": 0}}
; |
| 348 } |
| 349 |
| 350 void matchResponse(Debugger debugger) { |
| 351 super.matchResponse(debugger); |
| 352 |
| 353 List frames = getJsonValue(debugger.currentMessage, "result:callFrames"); |
| 354 assert(frames != null); |
| 355 |
| 356 String functionName = frames[frame_index]['functionName']; |
| 357 List localsList = frames[frame_index]['locals']; |
| 358 Map reportedLocals = {}; |
| 359 localsList.forEach((local) => reportedLocals[local['name']] = local['value']
); |
| 360 for (String key in locals) { |
| 361 if (reportedLocals[key] != null) { |
| 362 debugger.error("Error in $functionName(): local variable $key not " |
| 363 "expected in scope (reported value " |
| 364 "${reportedLocals[key]['text']})"); |
| 365 return; |
| 366 } |
| 367 } |
| 368 print("Matched locals $locals"); |
| 369 } |
| 370 } |
| 371 |
| 372 |
| 373 AssertLocalsNotVisible(List<String> locals, [int frame_index = 0]) { |
| 374 return new AssertLocalsNotVisibleMatcher(locals, frame_index); |
| 375 } |
| 376 |
| 377 |
| 341 class EventMatcher { | 378 class EventMatcher { |
| 342 String eventName; | 379 String eventName; |
| 343 Map params; | 380 Map params; |
| 344 | 381 |
| 345 EventMatcher(this.eventName, this.params); | 382 EventMatcher(this.eventName, this.params); |
| 346 | 383 |
| 347 void matchEvent(Debugger debugger) { | 384 void matchEvent(Debugger debugger) { |
| 348 for (Event event in debugger.events) { | 385 for (Event event in debugger.events) { |
| 349 if (event.name == eventName) { | 386 if (event.name == eventName) { |
| 350 if (params == null || matchMaps(params, event.params)) { | 387 if (params == null || matchMaps(params, event.params)) { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 targetOpts.add("--debuggee"); | 740 targetOpts.add("--debuggee"); |
| 704 print('args: ${targetOpts.join(" ")}'); | 741 print('args: ${targetOpts.join(" ")}'); |
| 705 | 742 |
| 706 Process.start(Platform.executable, targetOpts).then((Process process) { | 743 Process.start(Platform.executable, targetOpts).then((Process process) { |
| 707 print("Debug target process started, pid ${process.pid}."); | 744 print("Debug target process started, pid ${process.pid}."); |
| 708 process.stdin.close(); | 745 process.stdin.close(); |
| 709 var debugger = new Debugger(process, new DebugScript(script)); | 746 var debugger = new Debugger(process, new DebugScript(script)); |
| 710 }); | 747 }); |
| 711 return true; | 748 return true; |
| 712 } | 749 } |
| OLD | NEW |