Bug 13831 - gdb cli to be parsed for option "--args" instead of "--arg".
Summary: gdb cli to be parsed for option "--args" instead of "--arg".
Status: RESOLVED INVALID
Alias: None
Product: gdb
Classification: Unclassified
Component: cli (show other bugs)
Version: 7.4
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-11 15:00 UTC by jb.1234abcd
Modified: 2012-03-12 17:52 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jb.1234abcd 2012-03-11 15:00:38 UTC
gdb cli to be parsed for option "--args" instead of "--arg".

$ gdb -v    
GNU gdb (GDB) 7.4 [GDB v7.4 for FreeBSD]
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-portbld-freebsd9.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.

$ gdb --help
This is the GNU debugger.  Usage:

    gdb [options] [executable-file [core-file or process-id]]
    gdb [options] --args executable-file [inferior-arguments ...]

Options:

  --args             Arguments after executable-file are passed to inferior

$ gdb --arg prog1 1 2
GNU gdb (GDB) 7.4 [GDB v7.4 for FreeBSD]
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-portbld-freebsd9.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/home/jb/prog1...done.
(gdb) b main
Breakpoint 1 at 0x8048474: file prog1.c, line 13.
(gdb) r
Starting program: /usr/home/jb/prog1 1 2

Breakpoint 1, main (argc=3, argv=0xbfbfea50) at prog1.c:13
13	  printf("argc=%d\n",argc);
(gdb) c
Continuing.
argc=3
argv[0]=/usr/home/jb/prog1
argv[1]=1
argv[2]=2
[Inferior 1 (process 14899) exited normally]
(gdb)
Comment 1 Pedro Alves 2012-03-12 16:50:02 UTC
I'm afraid I don't understand what you're claiming is wrong.  Can you please clarify?
Comment 2 jb.1234abcd 2012-03-12 17:33:34 UTC
(In reply to comment #1)
> I'm afraid I don't understand what you're claiming is wrong.  Can you please
> clarify?

Well, the format of gdb entry contains option keyword "--args", not "--arg".
It is important to parse any input properly. The entry should be rejected with
error msg like "Invalid format: --arg option".
I documented it for you.
Comment 3 Pedro Alves 2012-03-12 17:52:15 UTC
That's not a bug, it's a feature.

For long options (--foo), GNU getopt figures out what you wanted as long as its not ambiguous.  E.g., try "ls --hel".