我把程序写成简单的服务器。在这一刻我想调试子进程,但发生了一些我不理解的事情,因为如果我想调试子空间(我设置 follow-fork-mode child )我总是得到声明:
[使用libthread_db启用线程调试]使用主机libthread_db 库“/lib/x86_64-linux-gnu/libthread_db.so.1”。 (gdb)设置 跟岔式儿童
[新进程24892] [使用libthread_db启用的线程调试] 使用主机libthread_db库 “/lib/x86_64-linux-gnu/libthread_db.so.1”。 [切换到线程 0xf7c61700(LWP 24892)]继续信号SIGABRT。
程序终止,信号SIGABRT,Aborted。该计划不再 存在。
如果我只是跑他,我的程序也可以正常工作,但如果我想调试不行。这是我的计划的一小部分。我想展示主循环服务器,因为我认为这是一个主要问题。
while (loopFlag) {
sin_size = sizeof infoAboutClientAddress;
if ((newDS = accept(serverFileDescriptor, (struct sockaddr *) &infoAboutClient,
&sin_size)) == -1) {
// can not accept connection
continue;
}
pid_t newProcessForClient = fork();
if (!newProcessForClient) {
// here a want to debug but always get above statement
printf("Hello here is child");
} else if (newProcessForClient < 0) {
// something is wrong with new proces
close(newDS);
} else if (newProcessForClient > 0) {
// code for parent
close(newDS);
}
}
我在下面阅读了主题,但我仍然不知道如何忽略这个信号,或者我什么不能这样做,因为他没有出现。
gdb debugging child process after fork (follow-fork-mode child configured)
编辑1
理念是每个客户应该创建单独的流程
编辑2
我已经安装了GDB Debian 7.7.1
我只是从IDE运行调试,只写Shift + F9。如果我进入父空间,调试也会起作用。
这是调试的屏幕截图标志
编辑3
命令中的语句 cmake -DCMAKE_BUILD_TYPE = Debug 在direcytory中与项目
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: