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

后端 未结 8 2087
半阙折子戏
半阙折子戏 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:54

    Much too late, but here is a method that works during gdb session.

    gdb

    then

    (gdb) apropos argument

    This will return lots of matches, the useful one is set args.

    set args -- Set argument list to give program being debugged when it is started.
    

    set args arg1 arg2 ...

    then

    r

    This will run the program, passing to main(argc, argv) the arguments and the argument count.

提交回复
热议问题