-
Notifications
You must be signed in to change notification settings - Fork 171
Signal Behaviour
Programs will use signals to communicate with itself and even with the Operating System through the kernel. Sometimes the OS will also send signals to the program, especially if the program is misbehaving and must be stopped (like SIGSEGV).
This can be annoying sometimes, especially if GDB's default signal handling options cause the program to stop very frequently.
Because of this, you can change GDB's signal handling in Settings->Debug->Handle Signals:
- Signal: The name of all available Linux signals. Note that the list is generic and not all signals will be used by the target process.
- Stop & Print: Controls whether this signal will cause GDB to stop the process and print the signal to log output.
- Pass to Program: Controls whether GDB will let the process know that this signal was emitted.
Still confused? You basically have 4 possible option pairs that will behave as following:
-
Both unchecked: The signal will be thrown into the void. When the signal is emitted, GDB will not stop the program, not print it and it won't be passed to the process so it won't even know it was emitted in the first place.
- This is useful for when you want GDB and the program to completely ignore a signal.
-
Only Stop & Print checked: GDB will stop the process and print the signal to the log output but will not pass it to the program.
- This is useful to analyze what signals and why they're emitted without causing the program to run its signal handling.
-
Only Pass to Program checked: GDB will not stop and print the signal and will automatically pass the signal to the process.
- This is the normal behaviour when GDB is not attached to a process.
-
Both checked: GDB will stop the process and print the signal to the log output. The signal will then be sent to the process upon resume.
- This is useful to analyze the program when a signal happens and then forward the signal to the program so it can do its usual signal handling routine.
Generally if a signal is spammed and annoys you by constantly pausing the program, especially the SIGUSR1, SIGUSR2 and SIGXX signals, you want to have only Pass to Program checked for them.
If you're unsure which signal is causing you issues, you can always check GDB output to see what signal is being caught and use the above instructions to handle it according to your preference.
To find the problematic signal:
- Make sure that either GDB file logging or GDB output async is on. More info here.
- When the signal stops your program, you should be able to check either the GDB file log or terminal output (depending on what you chose at step 1) for a message similar to this:
~"1 \"process_name\" received signal SIGNAME, info about the signal
-
SIGNAMEwill be the name of your problematic signal so you can now follow the instructions above to customize this signal's behaviour.