Start a debugging session. Builds the sketch and launches a VM to run it. VM starts suspended. Should produce a VMStartEvent.
()
| 161 | * VM starts suspended. Should produce a VMStartEvent. |
| 162 | */ |
| 163 | public synchronized void startDebug() { |
| 164 | //stopDebug(); // stop any running sessions |
| 165 | if (isStarted()) { |
| 166 | return; // do nothing |
| 167 | } |
| 168 | |
| 169 | // we are busy now |
| 170 | editor.statusBusy(); |
| 171 | |
| 172 | // clear console |
| 173 | editor.clearConsole(); |
| 174 | |
| 175 | // clear variable inspector (also resets expanded states) |
| 176 | editor.variableInspector().reset(); |
| 177 | |
| 178 | // load edits into sketch obj, etc... |
| 179 | editor.prepareRun(); |
| 180 | |
| 181 | // after prepareRun, since this removes highlights |
| 182 | editor.activateDebug(); |
| 183 | |
| 184 | try { |
| 185 | Sketch sketch = editor.getSketch(); |
| 186 | JavaBuild build = new JavaBuild(sketch); |
| 187 | |
| 188 | log("building sketch: " + sketch.getName()); |
| 189 | //LineMapping.addLineNumbers(sketch); // annotate |
| 190 | // mainClassName = build.build(false); |
| 191 | mainClassName = build.build(true); |
| 192 | //LineMapping.removeLineNumbers(sketch); // annotate |
| 193 | log("class: " + mainClassName); |
| 194 | |
| 195 | // folder with assembled/preprocessed src |
| 196 | srcPath = build.getSrcFolder().getPath(); |
| 197 | log("build src: " + srcPath); |
| 198 | // folder with compiled code (.class files) |
| 199 | log("build bin: " + build.getBinFolder().getPath()); |
| 200 | |
| 201 | if (mainClassName != null) { |
| 202 | // generate the source line mapping |
| 203 | //lineMap = LineMapping.generateMapping(srcPath + File.separator + mainClassName + ".java"); |
| 204 | |
| 205 | log("launching debuggee runtime"); |
| 206 | runtime = new Runner(build, new RunnerListenerEdtAdapter(editor)); |
| 207 | VirtualMachine vm = runtime.debug(null); // non-blocking |
| 208 | if (vm == null) { |
| 209 | loge("error 37: launch failed", null); |
| 210 | } |
| 211 | |
| 212 | // start receiving vm events |
| 213 | VMEventReader eventThread = new VMEventReader(vm.eventQueue(), vmEventListener); |
| 214 | eventThread.start(); |
| 215 | |
| 216 | startTrackingLineChanges(); |
| 217 | editor.statusBusy(); |
| 218 | } |
| 219 | } catch (Exception e) { |
| 220 | editor.statusError(e); |
no test coverage detected