For breakpoint debugging, you can make a run configuration to attach a remote debugger:
1. Make a copy of your starsector-core/starsector.bat file and call it "debug-starsector.bat" (replace .bat with .sh for linux). This is not strictly necessary but highly recommended in case the bat file gets messed up.
2. Open the bat file and configure Java to start in a new process and open a debugger port. The "suspend=y" arg in there makes the JVM not run until a debugger actually connects.
Windows:
start ..\jre\bin\java.exe -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 <everything that comes after "java.exe" in the original file>
Linux:
..\jre\bin\java.exe -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 <everything that comes after "java.exe" in the original file> &
Don't forget the & at the end, it's what makes the command run in a separate process.
3. Create a run configuration that points to the new bat file, following kazi's original directions. Alternately, you can just change your existing configuration to point to the new file, but this will mess up the console.
4. Create a new remote debugging run configuration.
a) Run -> Edit Configurations -> click "Remote" in the top left -> click "+"
b) Name it "Debug Starsector"
c) In the "Configuration" tab, in the "Before Launch" tab at the bottom, click "+" and add the configuration from step 3. This will make IntelliJ actually start StarSector before trying to connect to it.
d) In the Logs tab, hit "+" in the top right and browse to your starsector.log file (should be in starsector-core). Alias it whatever you want, but "starsector.log" is probably a good idea.
e) Hit "ok" on everything.
5. Set some breakpoints and run the new configuration by clicking the Debug (green bug) button next to the Run button. Easiest way to test if you've done it right is to set a breakpoint in an advance(), init(), or onApplicationLoad() methods in your mod.
Notes:
- You may get a windows firewall popup when you first run the debugger. Click through it. You don't need to open any ports because it's all going through localhost, but windows firewall will still cry about it.
- You'll notice that your normal console just says "Connected to the target VM, address: 'localhost:5005', transport: 'socket'". To see StarSector log output, switch to the starsector.log tab next to the console that should conveniently pop up for you.
- If you see weird cut off logs, there's a drop-down in the top right of that window that lets you pick between "all", "infos","warnings", and "errors". Change to "all" to see the normal log you always see.
- The StarSector process won't close when you disconnect the debugger.