Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb detaching after fork from child process - disable?

Tags:

fork

gdb

Getting this message inside gdb. I know its not an error or anything. I also did pagination so thats not an issue.

Is there any way to suppress this message?

like image 202
Jack Avatar asked Oct 28 '09 13:10

Jack


People also ask

How do I detach a process in GDB?

When you have finished debugging the attached process, you can use the detach command to release it from GDB control. Detaching the process continues its execution. After the detach command, that process and GDB become completely independent once more, and you are ready to attach another process or start one with run .

What do you need to do to tell GDB to follow the child process after typing next?

By default, when a program forks, GDB will continue to debug the parent process and the child process will run unimpeded. If you want to follow the child process instead of the parent process, use the command set follow-fork-mode . Set the debugger response to a program call of fork or vfork .

What is follow fork mode?

Controls the behavior of GDB when the debugged program calls fork() or vfork()

How do you debug a child process?

There is an alternative way of debugging the child process. After fork() is executed, put a sleep() call in the code where the child executes, get the PID of the child using the ps utility, then attach the PID. Now, you can debug the child process, like any other process.


1 Answers

I was curious to see that this question was unanswered...

I obtained the GDB manual, and it says (in part - p33 of the PDF 'Ninth Edition, for gdb version 7.0.50.20091228'):

To be notified when inferiors are started or exit under gdb’s control use set print inferior-events:

set print inferior-events
set print inferior-events on
set print inferior-events off

The set print inferior-events command allows you to enable or disable printing of messages when gdb notices that new inferiors have started or that inferiors have exited or have been detached. By default, these messages will not be printed.

show print inferior-events

Show whether messages will be printed when gdb detects that inferiors have started, exited or have been detached.

The only concern I have about this is that it implies that you should not be seeing the messages by default. Just make sure that your settings match the default and do not override them.

Section 4.11 'Debugging Forks' (pp38-40) looks relevant to you, too.

like image 110
Jonathan Leffler Avatar answered Jan 02 '23 21:01

Jonathan Leffler