'why Ctrl-c in gdb terminal dose not send STOP signal to gdb process
To break loop in gdb we need to Ctrl -c in gdb terminal , but some time Ctrl-c not working, is there a way to break the loop? ( excepted sending SIGSTOP or SIGTRAP to gdb process from another window)
The source code is something like that:
main() {
Initialize ():
...
while (true) //the main region of the program
{
ret = getmsg (fd, &ctrl, &data, &flags);
Process (data);
...
}
Solution 1:[1]
Could you post some more specifics about the problem? Also why are trying to use ctrl-c to break inside of a loop instead of setting a break point?
To set a break point in gdb its as simple as running:
b <a line number in the loop>
here's some resources:
running this in gdb: help break
https://sourceware.org/gdb/current/onlinedocs/gdb/Breakpoints.html#Breakpoints
Solution 2:[2]
Not sure of the requirement, but you could place a conditional breakpoint in the loop body if you don't want to break every time.
Now for your specific question, you can send the signal from within the gdb prompt, simply type :
signal SIGINT
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Liam Warfield |
Solution 2 | zhenguoli |