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

后端 未结 8 2060
半阙折子戏
半阙折子戏 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条回答
  •  -上瘾入骨i
    2020-11-28 00:31

    Another way to do this, which I personally find slightly more convenient and intuitive (without having to remember the --args parameter), is to compile normally, and use r arg1 arg2 arg3 directly from within gdb, like so:

    $ gcc -g *.c *.h
    $ gdb ./a.out
    (gdb) r arg1 arg2 arg3
    

提交回复
热议问题