Visualizzazione post con etichetta debug. Mostra tutti i post
Visualizzazione post con etichetta debug. Mostra tutti i post

martedì 26 gennaio 2010

How to start a java application for remote debugging

In order to allow remote debugging for a java application the command line should be customized with the following arguments:
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n MyClass
-Xdebug enables debugging mode;
-Xrunjdwp configures Java Debug Wire Protocol with sub-options; like the communication mode between jvm and debugger, the listening port, whether wait until the debugger connection or not, etc. See links for further details

See also:
-Xrunjdwp sub-options
Remote Debugging with Eclipse

venerdì 23 ottobre 2009

Fare il debug dei test avviati con maven

Nel caso in cui si presenti la necessità di fare il debug di test avviati tramite maven è sufficiente aggiungere il flag -Dmaven.surefire.debug.
Da console:
mvn test -Dmaven.surefire.debug
questo fa in modo che i test, subito dopo l'avvio, si mettano in pausa in attesa che un debugger remoto si colleghi alla porta 5005 (valore di default eventualmente modificabile).

Se volessimo connettere Eclipse in debug non dovremmo fare altro che creare una nuova Debug Configuration (menù Run > Debug Configuration...), selezionare il tipo "Remote Java Application" e impostare nel campo Port il valore 5005. Cliccando su Debug, Eclipse si collegherà ai test, precedentemente entrati in pausa, facendoli immediatamente ripartire. L'esecuzione si fermerà su tutti breakpoint che avremo impostato permettendo il normale debug all'interno di Eclipse.

Vedi anche:
Maven Surefire Plugin > Examples > Debugging Tests