Start a debugging session. Builds the sketch and launches a VM to run it. VM starts suspended. Should produce a VMStartEvent.
()
| 306 | * VM starts suspended. Should produce a VMStartEvent. |
| 307 | */ |
| 308 | public synchronized void startDebug() { |
| 309 | //stopDebug(); // stop any running sessions |
| 310 | if (isStarted()) { |
| 311 | return; // do nothing |
| 312 | } |
| 313 | |
| 314 | // we are busy now |
| 315 | editor.statusBusy(); |
| 316 | |
| 317 | // clear console |
| 318 | editor.clearConsole(); |
| 319 | |
| 320 | // clear variable inspector (also resets expanded states) |
| 321 | inspector.reset(); |
| 322 | |
| 323 | // load edits into sketch obj, etc... |
| 324 | editor.prepareRun(); |
| 325 | |
| 326 | // after prepareRun, since this removes highlights |
| 327 | //editor.activateDebug(); |
| 328 | editor.activateRun(); |
| 329 | |
| 330 | try { |
| 331 | Sketch sketch = editor.getSketch(); |
| 332 | JavaBuild build = new JavaBuild(sketch); |
| 333 | |
| 334 | log("building sketch: " + sketch.getName()); |
| 335 | //LineMapping.addLineNumbers(sketch); // annotate |
| 336 | // mainClassName = build.build(false); |
| 337 | mainClassName = build.build(true); |
| 338 | //LineMapping.removeLineNumbers(sketch); // annotate |
| 339 | log("class: " + mainClassName); |
| 340 | |
| 341 | // folder with assembled/preprocessed src |
| 342 | srcPath = build.getSrcFolder().getPath(); |
| 343 | log("build src: " + srcPath); |
| 344 | // folder with compiled code (.class files) |
| 345 | log("build bin: " + build.getBinFolder().getPath()); |
| 346 | |
| 347 | if (mainClassName != null) { |
| 348 | // generate the source line mapping |
| 349 | //lineMap = LineMapping.generateMapping(srcPath + File.separator + mainClassName + ".java"); |
| 350 | |
| 351 | log("launching debuggee runtime"); |
| 352 | runtime = new Runner(build, new RunnerListenerEdtAdapter(editor)); |
| 353 | VirtualMachine vm = runtime.debug(null); // non-blocking |
| 354 | if (vm == null) { |
| 355 | loge("error 37: launch failed", null); |
| 356 | } |
| 357 | |
| 358 | // start receiving vm events |
| 359 | VMEventReader eventThread = new VMEventReader(vm.eventQueue(), vmEventListener); |
| 360 | eventThread.start(); |
| 361 | |
| 362 | startTrackingLineChanges(); |
| 363 | editor.statusBusy(); |
| 364 | } |
| 365 | } catch (Exception e) { |
no test coverage detected