MCPcopy Index your code
hub / github.com/benfry/processing4 / generateTrace

Method generateTrace

java/src/processing/mode/java/runner/Runner.java:581–675  ·  view source on GitHub ↗

Generate the trace. Enable events, start thread to display events, start threads to forward remote error and output streams, resume the remote VM, wait for the final event, and shutdown.

()

Source from the content-addressed store, hash-verified

579 * resume the remote VM, wait for the final event, and shutdown.
580 */
581 protected void generateTrace() {
582 //vm.setDebugTraceMode(debugTraceMode);
583// vm.setDebugTraceMode(VirtualMachine.TRACE_ALL);
584// vm.setDebugTraceMode(VirtualMachine.TRACE_NONE); // formerly, seems to have no effect
585 try {
586 // Calling this seems to set something internally to make the
587 // Eclipse JDI wake up. Without it, an ObjectCollectedException
588 // is thrown on excReq.enable(). No idea why this works,
589 // but at least exception handling has returned. (Suspect that it may
590 // block until all or at least some threads are available, meaning
591 // that the app has launched and we have legit objects to talk to).
592 vm.allThreads();
593 // The bug may not have been noticed because the test suite waits for
594 // a thread to be available, and queries it by calling allThreads().
595 // See org.eclipse.debug.jdi.tests.AbstractJDITest for the example.
596
597 EventRequestManager mgr = vm.eventRequestManager();
598 // get only the uncaught exceptions
599 ExceptionRequest excReq = mgr.createExceptionRequest(null, false, true);
600 // this version reports all exceptions, caught or uncaught
601 // suspend so we can step
602 excReq.setSuspendPolicy(EventRequest.SUSPEND_ALL);
603 excReq.enable();
604 } catch (VMDisconnectedException ignore) {
605 return;
606 }
607
608 Thread eventThread = new Thread(() -> {
609 try {
610 boolean connected = true;
611 while (connected) {
612 EventQueue eventQueue = vm.eventQueue();
613 // remove() blocks until event(s) available
614 EventSet eventSet = eventQueue.remove();
615// listener.vmEvent(eventSet);
616
617 for (Event event : eventSet) {
618// System.out.println("EventThread.handleEvent -> " + event);
619 if (event instanceof VMStartEvent) {
620 vm.resume();
621 } else if (event instanceof ExceptionEvent) {
622// for (ThreadReference thread : vm.allThreads()) {
623// System.out.println("thread : " + thread);
624//// thread.suspend();
625// }
626 exceptionEvent((ExceptionEvent) event);
627 } else if (event instanceof VMDisconnectEvent) {
628 connected = false;
629 }
630 }
631 }
632// } catch (VMDisconnectedException e) {
633// Logger.getLogger(VMEventReader.class.getName()).log(Level.INFO, "VMEventReader quit on VM disconnect");
634 } catch (Exception e) {
635 System.err.println("crashed in event thread due to " + e.getMessage());
636// Logger.getLogger(VMEventReader.class.getName()).log(Level.SEVERE, "VMEventReader quit", e);
637 e.printStackTrace();
638 }

Callers 2

launchMethod · 0.95
presentMethod · 0.95

Calls 11

exceptionEventMethod · 0.95
resumeMethod · 0.80
getThreadMethod · 0.80
onRunnerExitingMethod · 0.80
getMessageMethod · 0.65
enableMethod · 0.45
removeMethod · 0.45
printlnMethod · 0.45
printStackTraceMethod · 0.45
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected