6

I have a program that reads one image file, makes some changes on that image and then stores it.

The program runs like this:

./main file1.pgm file2.pgm

I'm using the -g flag so I can use GDB.

Now when I try to run GDB like this

# gdb main file1.pgm file2.pgm

i'm getting this error:

Excess command line arguments ignored. (file2.pgm)

How can I solve this?

My main needs those two arguments.

Favolas
  • 6,963
  • 29
  • 75
  • 127

3 Answers3

7

From the command line like this:

gdb --args ./main file1.pgm file2.pgm

run at the GDB prompt may be more flexible if you are scripting extensively.

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
1

That's not how you pass arguments to a program to be run; it's taking file1.pgm as the name of a core file.

You want to use, within gdb,

gdb> :run file1.pgm file2.pgm
geekosaur
  • 59,309
  • 11
  • 123
  • 114
1

Populate a .gdbinit with:

set args file1.pgm file2.pgm

then simply

gdb> run
GoZoner
  • 67,920
  • 20
  • 95
  • 145