nus-cs2103-AY2425S1 / forum

12 stars 0 forks source link

💡Running GUI on debug mode #298

Closed Feng1231 closed 5 hours ago

Feng1231 commented 3 days ago

I realised that typing /.gradlew run in the CLI will only run the AB3 gui, but not in debug mode. For instance, when I set a breakpoint at the execute method of the ListCommand class, typing list in the GUI input will not result in the application stopping at the method execute.

A workaround to this issue is to go to the Main.java file and press the debug icon (or Shift F9) on the top right corner of the IDE. Then, the application will run in debug mode and stop at the breakpoint that I have set. image

Does anyone have other ways of debugging in gradle? Because ./gradlew --debug will not launch the application in debug mode.

yadobler commented 2 days ago

No easier way.

The traditional way (ie with gdb and vim, or with jdtls) is to first launch the java app with the following args:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005

you're instructing java / Gradle to:

Then on IntelliJ, you must start the remote debugging client, set the port to 5005, and begin


Or you can just press the 🐞 debug icon. Either


If you run Gradle with debugging, you can use nvim with the dap plugin or any client that supports the debugging adaptor protocol to follow along.

And this includes using things like gdb for c debugging or python too.

yadobler commented 2 days ago

I realised that typing /.gradlew run in the CLI will only run the AB3 gui, but not in debug mode. For instance, when I set a breakpoint at the execute method of the ListCommand class, typing list in the GUI input will not result in the application stopping at the method execute.

Sorry can I clarify, are you able to stop at breakpoint before doing GUI? (ie you hit breakpoint and programme pauses when the programme was still CLI mode and you typed list in the CLI)

Expected behavior is that debugging is not enabled when you . /gradlew run.

I feel like I'm misunderstanding something.

Feng1231 commented 5 hours ago

Sorry can I clarify, are you able to stop at breakpoint before doing GUI? (ie you hit breakpoint and programme pauses when the programme was still CLI mode and you typed list in the CLI)

Expected behavior is that debugging is not enabled when you . /gradlew run.

I feel like I'm misunderstanding something.

I didnt try debugging in the CLI version of Duke. The 'CLI' that I was referring to is the terminal in intellij. My bad for being vague 😪.

Anyways, thank you for the very detailed response! I guess I'll stick to clicking the debug icon.