gdb break when entering child process

后端 未结 2 1507
太阳男子
太阳男子 2021-01-03 06:56

I\'m having a tough time figuring this one out; I have a program, iverilog that executes a system() call to invoke another program, ivl

相关标签:
2条回答
  • 2021-01-03 07:49

    This answer provides one way to achieve what you want.

    In theory, set follow-fork-mode child should work.

    In practice, the iverilog is likely itself a shell script that runs (forks) multiple commands, so at every fork you will need to decide whether you want to continue debugging the parent or the child. One wrong decision and you've lost control of the process that will eventually execute your program. This very likely explains why it didn't work for you.

    0 讨论(0)
  • 2021-01-03 07:53

    Normally GDB only debugs one process at a time- if your program forks then you will debug the parent or the child, but not both simultaneously. By default, GDB continues debugging the parent after a fork, but you can change this behavior if you so desire with the following command:

    set follow-fork-mode child

    Alternately, you can tell GDB to keep both the parent and the child under its control. By default GDB only follows one process, but you can tell it to follow all child processes with this command:

    set detach-on-fork off

    GDB refers to each debugged process as an "inferior". When debugging multiple processes you can examine and interact each process with the "inferiors" command similar to how you would use "threads" to examine or interact with multiple threads.

    See more documentation here:

    https://sourceware.org/gdb/onlinedocs/gdb/Forks.html

    0 讨论(0)
提交回复
热议问题