Scenario:
There is a complicated piece of software that annoys manual startup. What I did was create a python script to run the executable and connect gdb for debugging.
Running the script process:
- sets the environment variable.
- provides the addition of a local assembly directory to the environment variable
LD_LIBRARY_PATH . - changes the current working directory to the object that the executable is waiting for (not my design)
- runs an executable file with a configuration file with only a command line parameter
- outputs the output from the executable to the second logging process
- remembers the PID of the executable file, then launches and attaches gdb to the executable executable file.
The script works with one caveat. ctrl-c does not interrupt control of debuge and return in gdb. Therefore, if I โcontinueโ without active control points, I can never stop the process again, it needs to be killed / aborted from another shell, BTW, run โkill -s SIGINT <pid>โ where <pid> is the debuggee pid, which brings me back to the gdb hint ... but it is really annoying to do something this way.
At first I thought that Python captures the SIGINT signal, but it doesn't seem to be that way, as I set up signal handlers by passing the signal to the debut, and this does not fix the problem.
I tried various configurations for a python script (calling os.spawn * instead of a subprocess, etc.) It seems that any way I do it if python starts a child process, SIGINT (ctrl-c) SHOULD NOT be redirected to gdb or child process.
Current line of thinking
- This may be due to the need for a separate process group identifier for debut and gdb ... any trust in this?
- Possible error with SELinux?
Information:
- gdb 6.8
- Python 2.5.2 (the problem is present with Python 2.6.1)
- SELinux environment (error signaling processes?)
Alternatives I reviewed:
- Setting the .gdbinit file to do the same thing the script does, environment variables and the current working directory are a problem with this approach.
- Running the executable and installing gdb manually (yuck)
Question: How to automate the launch / debugging of large-scale projects?
Update: I tried the Nicholas Riley examples below, on my Macintosh at home they all allow cntl-c to work to varying degrees, on the production of boxen (which I suppose SELinux can work), they donโt ...
source share