How do i pass argument to gdb?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashokd001
    New Member
    • Aug 2008
    • 30

    How do i pass argument to gdb?

    Hi

    I want to pass argument to gdb but i don't know to do that.

    Say,

    my executable taking 3 argument.

    <myexe> <arg1> <arg2> <arg3>

    when i try to debug myexe,
    like that

    gdb myexe

    but i dont konw how to pass 3 arguments .


    Please, some suggestion.
    Thanks in advace.
    Ashok
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    When you actually run your program in gdb (by typing run), add your arguments there.

    For instance, if I wanted to run myProg.exe with the command line arguments 1, 2, and eleven, I would type:

    Code:
    gdb myProg.exe
    (setup stuff here, maybe set some breakpoints, then...)
    run 1 2 eleven

    Comment

    • mac11
      Contributor
      • Apr 2007
      • 256

      #3
      you can also use the --args flag on the command line like this:

      > gdb --args myprogram arg1 arg2 arg3

      Comment

      Working...