gdb如何启动作为输入传递给它的另一个程序
How does gdb start another program passed to it as input
我已经阅读了 gdb attaches
如何从这个 link:
到另一个 运行ning 进程
How does a debugger peek into another process' memory?
但是直接用它启动一个程序怎么样:
gdb ./my_program
gdb fork
和 运行 my_program
是否使用它并像上面解释的那样附加到它 link (即 ptrace
在 linux), 还是过程完全不同?
or the process is entirely different?
否:过程相同 -- fork
、parent 调用 PTRACE_ATTACH
、child 调用 PTRACE_TRACEME
。最后一点保证 GDB 可以从第一条指令开始调试 child 进程。
还有一个复杂的问题:GDB 使用 $SHELL
来处理输入/输出重定向,所以有 fork
-> exec shell
(在 child ) -> exec program
.
我已经阅读了 gdb attaches
如何从这个 link:
How does a debugger peek into another process' memory?
但是直接用它启动一个程序怎么样:
gdb ./my_program
gdb fork
和 运行 my_program
是否使用它并像上面解释的那样附加到它 link (即 ptrace
在 linux), 还是过程完全不同?
or the process is entirely different?
否:过程相同 -- fork
、parent 调用 PTRACE_ATTACH
、child 调用 PTRACE_TRACEME
。最后一点保证 GDB 可以从第一条指令开始调试 child 进程。
还有一个复杂的问题:GDB 使用 $SHELL
来处理输入/输出重定向,所以有 fork
-> exec shell
(在 child ) -> exec program
.