Linux gdb debugging a running program

1.  Get the process number of the program you want to debug

2. Use gdb to debug the running program. The command is as follows:
gdb attach 100717

3. To view the currently running threads, the command is as follows:

info threads

As you can see, there are currently 20 threads running

4. Check the basic information of each thread, so that I know which thread my reading directory is running in. The command as follows:
thread apply all bt

Can clearly know that Thread 4 is the thread I want to debug

5. Enter the debugging thread and check the running status, the command is as follows:
t 4

 Is to switch to thread No. 4 ?

bt

Check the stack status of the current thread

It can be seen that the thread is stuck at msisdn.c:920 , and there is a while loop here, so set a breakpoint and let the program run again.

  The key point here is the command c, which allows the program to continue running, because after you gdb, the program has stopped, and then you can use single step and next to check your memory variables.

 

Guess you like

Origin blog.csdn.net/m0_72303088/article/details/131128937