I've recently found that on my system (Ubuntu 16.04, Linux 4.4.0, gcc 5.3.1, gdb 7.11.1), if I try to debug a program using popen_noshell() calls, gdb misses breakpoints after the subprocess creation.
I've found that this can be worked around by adding either CLONE_UNTRACED or CLONE_VFORK as an extra flag to the clone() system call (as far as I understand, the first option explicitly forces gdb not to follow the newly created process, while I have no idea how the second one works).
I'm not sure if it's a bug in gdb or expected but undocumented behavior; I don't remember exactly, but it's very probable that previous gdb versions did not have this problem, but I don't have easy access to any right now to test this.
I've submitted a bug to the gdb developers which includes a minimal test case as well here https://sourceware.org/bugzilla/show_bug.cgi?id=20322 -- given the large number of bugs they have there, I decided to post here as well for better reference in case someone runs into the same problem
I've recently found that on my system (Ubuntu 16.04, Linux 4.4.0, gcc 5.3.1, gdb 7.11.1), if I try to debug a program using popen_noshell() calls, gdb misses breakpoints after the subprocess creation.
I've found that this can be worked around by adding either CLONE_UNTRACED or CLONE_VFORK as an extra flag to the clone() system call (as far as I understand, the first option explicitly forces gdb not to follow the newly created process, while I have no idea how the second one works).
I'm not sure if it's a bug in gdb or expected but undocumented behavior; I don't remember exactly, but it's very probable that previous gdb versions did not have this problem, but I don't have easy access to any right now to test this.
I've submitted a bug to the gdb developers which includes a minimal test case as well here https://sourceware.org/bugzilla/show_bug.cgi?id=20322 -- given the large number of bugs they have there, I decided to post here as well for better reference in case someone runs into the same problem