How do I run a program with commandline arguments using GDB within a Bash script?

后端 未结 8 2066
半阙折子戏
半阙折子戏 2020-11-27 23:52

When running a program on GDB, usually, the arguments for the program are given at the run command. Is there a way to run the program using GDB and as well as g

8条回答
  •  粉色の甜心
    2020-11-28 00:43

    gdb -ex=r --args myprogram arg1 arg2
    

    -ex=r is short for -ex=run and tells gdb to run your program immediately, rather than wait for you to type "run" at the prompt. Then --args says that everything that follows is the command and arguments, just as you'd normally type them at the commandline prompt.

提交回复
热议问题