使用GDB,调试多线程,多进程

线程(thread) 进程(process)
fork后,如何决定是进入父进程还是子进程 - set follow-fork-mode child|parent
让其他进程/线程挂起,只单步执行当前的进程/线程 set scheduler-locking on set detach-on-fork off
查看上面的状态 show scheduler-locking show detach-on-fork
显示所有的进程/线程的编号 info threads info inferiors
切到某个进程/线程去单步调试 thread 线程编号 inferior 进程编号
让挂起的进程执行 - detach inferiors 进程编号
  • set scheduler-locking off|on|step:在使用step或者continue命令调试当前被调试线程的时候,其他线程也是同时执行的,怎么只让被调试程序执行呢?通过这个命令就可以实现这个需求。
    • off 不锁定任何线程,也就是所有线程都执行。
    • on 只有当前被调试程序会执行。
    • step 在单步的时候,除了next过一个函数的情况(熟悉情况的人可能知道,这其实是一个设置断点然后continue的行为)以外,只有当前线程会执行。
  • 查看:show xxx

  • 设置:set xxx

# c/c++ 学习互助QQ群:877684253 # 本人微信:xiaoshitou5854

posted @ 2020-03-27 15:33  小石王  阅读(373)  评论(0编辑  收藏  举报