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.
You may start GDB with its arguments, if any, in an environment of your choice. If you are doing native debugging, you may redirect your program's input and output, debug an already running process, or kill a child process. In order to debug a program effectively, you need to generate debugging information when you compile it.
On most systems, GDB has no special support for debugging programs which create additional processes using the fork function. When a program forks, GDB will continue to debug the parent process and the child process will run unimpeded.
When GDB starts, it reads any arguments other than options as specifying an executable file and core file (or process ID). This is the same as if the arguments were specified by the `-se' and `-c' (or `-p' options respectively.
Taking advantage of the second command-line argument requires a fairly complete operating system; when you use GDB as a remote debugger attached to a bare board, there may not be any notion of "process", and there is often no way to get a core dump. GDB will warn you if it is unable to attach or to read core dumps.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With