Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion to add this line of code to add debug information for lwjgl3 module/app in the gradle build file #157

Open
AnotherCoder1 opened this issue May 15, 2024 · 2 comments

Comments

@AnotherCoder1
Copy link

AnotherCoder1 commented May 15, 2024

I do not know whether there is an exisiting gradle task defined by your program to include debugging information when compiling the source code. But, after asking Artificial Intelligence, I found out it is suggesting, this line of code in the lwjgl3 module.

tasks.withType(JavaCompile).configureEach {
options.debug = true
options.compilerArgs += ["-g"]
}`.

And then, in Intellij Idea Community Edition, I can set up my run/debug configuration, I choose JAR application, and fill up the necessary parameters, and I can then debug my libgdx app.

Because I am getting used to compiling my source code using the command gradlew :lwjgl3:jar. This way, I can compile my code into .class and package them into .jar file.

Initially, I thought, by default, It will include the debug information as well when compiling, but it is not. That is why when I tried to debug my app, it shows weird behaviour such as not stopping program execution at a breakpoint specified in Intellij Idea.

If there is any task that is pre-built in gradlew task that will include debug information, please let me know thank you.

@tommyettinger
Copy link
Member

Normally you don't want to include debugging data in a release JAR, nor do you usually want to go through a JAR build each time you run. That's what :lwjgl3:run is for, though it is a good habit to build JARs periodically and test them. In IDEA, there's a run button next to a debug button, and they should work for any run configuration -- for :lwjgl3:run, using debug allows hitting breakpoints and the like. You probably know this, but the run button is a green triangle, and the debug button is usually next to or near it, as a green bug icon with several legs.

idea64_4yqbz32nSj

If debugging using that button, on the Gradle task for :lwjgl3:run, isn't working, it sounds like a bug or regression in IDEA, since that has worked in the past reliably. I would not be at all surprised if there is some problematic interaction with some recent Android Gradle Plugin version, since that has caused issues before (even in non-Android modules).

If the run task for any module isn't working but jar is, there may be some other issue with how the build is set up, or maybe how IDEA imported it. Normally I recommend running jar tasks early but not necessarily all the time, since checking if a JAR works can help notice issues like mismatched case in filenames. The run task seems to start more quickly, and since it works on your source code, it is able to debug and hit breakpoints. I don't know if there is any performance/memory effect from the -g compiler flag and debug setting.

I'll leave this open for comment; I might add a debugJar task that includes this if there is demand.

@tommyettinger
Copy link
Member

I'm not sure what adding -g and debug would do to a JAR (probably make it a little larger), but for the run task, they don't hurt the performance much, if at all.

I checked this here: tommyettinger/Sonorant@e280c70#diff-740191ccb94660b9e650981359e8034dbc04ce36f512dcf03bc0731239c136d5

That's a GPU-bound application, so if the debug flag has some CPU-side cost, this wouldn't be affected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants