I've been messing with this for hours, and I can't seem to figure out how to configure Code::Blocks to do what I want it to. Please don't confuse my lack of going over everything I have tried as not trying; I've just tried too many things at this point to remember them all! :-) Instead, I will just list what I ended up with.
My specific situation: My application (a daemon) has a launcher script that serves as watchdog and some other functions, some of them rather messy on the filesystem. Some of the features also involve the application being restarted. Because of existing features and compatibility with the production environment, there is an existing Makefile.
My goals:
1. Use my existing Makefile.
Complete: I was able to accomplish this.2. When I click Run/Debug, I want the launcher script to be launched, not my executable.
Complete-ish: I worked around the problem using the first method listed in https://stackoverflow.com/questions/22059855/configure-launch-command-in-codeblocks, which relies on an extra virtual target. The fact I need to confirm my target to run each time is kind of annoying, but it is better than nothing. I would love to get rid of that dialog each time, though.3. Have GDB automatically attach to child processes spawned by my launcher script.
Almost zero progress here. I configured gdb's initialization command to go 'set follow-fork-mode child', but unfortunately I am not getting anywhere; a segmentation fault during process start is not picked up on.My current results when trying to 'Start / Continue' (F8, red arrow) look as follows:
Active debugger config: GDB/CDB debugger:Myproject
Building to ensure sources are up-to-date
Selecting target:
startup
Adding source dir: /home/worstje/myproject/
Adding source dir: /home/worstje/myproject/
Adding file: /home/worstje/myproject/src/startup
Changing directory to: /home/worstje/myproject/src
Set variable: LD_LIBRARY_PATH=.:
Starting debugger: /usr/bin/gdb -fullname -quiet -args /home/worstje/myproject/src/startup
done
Setting breakpoints
Debugger name and version: GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Continuing...
Starting the debuggee failed: No executable file specified.
Debugger finished with status 0
Note that it freezes with a blank xterm screen after the 'Setting breakpoints', at which point I tell it to continue. (I guess it is trying to debug the shell script?) Unfortunately, it doesn't pickup anything afterwards, and then completely stops with the message you see below.
Using plain 'Run' (Ctrl+F10, green arrow) has the shell script executing normally, but when it launches my binary it has its segmentation fault.
I hope this information is enough to let you experts direct me to exactly what I need to do to try and make this work.
Thank you for your time and assistance. :-)