如何在使用CMake的调试器中设置后续分支模式作为子模块 [英] How set follow-fork-mode as child in debugger using CMake
问题描述
我有Linux系统,而且我正在使用 CMake 编写使用 Clion IDE 的程序。我有一部分是我在程序中的一部分,我希望调试子进程 .. :: EDIT :: .. 我相信这是很好的方法。我认为你的提示很有用,但我有一些下一个问题。在使用你的指令后,我的代码崩溃了。 声明:
我从这个论坛读了几个主题,但我仍然不知道如何或在哪里可以打开这个功能:
pid_t newProcessForClient = fork();
$ b $警告:文件
/lib32/libthread_db-1.0.so自动加载已被您的
`auto自动加载-load safe-path'设置为$ debugdir:$ datadir / auto-load。警告:
无法找到匹配劣质线程库的libthread_db,线程
调试将不可用。 [切换到31667]
继续使用SIGABRT信号。
程序以SIGABRT信号终止,Aborted。程序不再存在
。
调试设置无关与cmake。 CMAKE_CXX_FLAGS_DEBUG表示编译器的调试标志。但是,您需要将设置为follow-fork-mode子给调试器。为此,您需要执行以下步骤:
-
在程序开始处设置一个中断点(即父项程序,而不是子程序)
-
在调试器中启动程序。
- 转到调试器控制台(带有 gdb 标签的标签),并输入 set follow-fork-mode child 和 set auto-load safe-path /
- 继续调试
命令 set auto-load safe-path / 应根据文档切换自动加载限制。gdb。
I have Linux system, and I writing program use Clion IDE which using CMake. I have a part my in program where I would like to debug child process I read a few topic from this forum, but I still doesn't know how or where just I can turn on this function:
gdb debugging child process after fork (follow-fork-mode child configured)
How do I debug the child process after fork() in gdb?
I just have tryed to setup flag CMAKE_CXX_FLAGS_DEBUG
as set follow-fork-mode child
but CMake give me error.
Below screenshot with all flags which are uses to compile and dbug my program.
So what and where I must set this function.
..::EDIT::..
I believe that is good way. I think Your tip was useful, but I have some next problem. After using Your instructions my code is crash on line
pid_t newProcessForClient = fork();
Statement is:
(gdb) set follow-fork-mode child [New process 31667] warning: File "/lib32/libthread_db-1.0.so" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load". warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. [Switching to process 31667] Continuing with signal SIGABRT.
Program terminated with signal SIGABRT, Aborted. The program no longer exists.
The debugging settings have nothing to do with cmake. CMAKE_CXX_FLAGS_DEBUG states the debug flags for the compiler. However, you need to tell set follow-fork-mode child to the debugger. To do this, you need the following steps:
Set a break point at the beginning of your program (ie. the parent program, not the child program)
Start the program in the debugger.
- Go to the debugger console (tab with the label gdb) in clion and enter set follow-fork-mode child and set auto-load safe-path /
- Continue debugging
The command set auto-load safe-path / is supposed to switch of the auto-load restrictions according to the documentation of gdb.
这篇关于如何在使用CMake的调试器中设置后续分支模式作为子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!