Tuesday, May 21, 2013

Passing arguments to program when using GDB command line

If you have a program that takes input parameters on start and you want to debug it using GDB in the command line, here is how to pass parameters to the program:
  1. Start GDB with given program
    gdb myProgram.a
  2. Set break points etc. 
  3.  Start debugging and give parameters you would usually give to program here
    run param1 param2 
Alternatively you can specify arguments directly when calling gdb with --args flag:
gdb --args myProgram.a param1 param2

Cheatsheet for GDB command line: http://www.yolinux.com/TUTORIALS/GDB-Commands.html

Source: http://bytes.com/topic/c/answers/833755-how-do-i-pass-argument-gdb

No comments:

Post a Comment