Invoke gdb to automatically pass arguments to the program being debugged

前端 未结 8 1957

I\'d like to write a script that (under certain conditions) will execute gdb and automatically run some program X with some set of arguments Y. Once the program has finishe

8条回答
  •  忘掉有多难
    2020-12-23 00:22

    If you want to run some commands through GDB and then have it exit or run to completion, just do

    echo commands | gdb X
    

    If you want to leave it at the command prompt after running those commands, you can do

    (echo commands; cat) | gdb X
    

    This results in echoing the commands to GDB, and then you type into the cat process, which copies its stdin to stdout, which is piped into GDB.

提交回复
热议问题