I writing program as simply server. In this moment I want to debug child process, but happens something not understand for me, because if I want to debug child space (I set follow-fork-mode child )I always get statement:
[Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". (gdb) set follow-fork-mode child
[New process 24892] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [Switching to Thread 0xf7c61700 (LWP 24892)] Continuing with signal SIGABRT.
Program terminated with signal SIGABRT, Aborted. The program no longer exists.
My program works as well if I just runing him, but if I want to debug not. Here is little part of my program. I want to show main loop server, because I think here is a main problem.
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);
}
}
I read below topic, but I still don't know how ignore this signal, or what can I do so as he dosen't appears.
gdb debugging child process after fork (follow-fork-mode child configured)
EDIT 1
Idea is for each client should be create separate process
EDIT 2
I have install GDB Debian 7.7.1
I run debug just from IDE nothing to write just Shift+F9. debug works as well if I moving into parent space.
Here is screen shot flags for debug
EDIT 3
Statements after command cmake -DCMAKE_BUILD_TYPE=Debug in direcytory with project
-- 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: