This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Add -verify option to load command
On 2017-01-06 14:32, Luis Machado wrote:
From what I understand it is possible to use load without specifying
FILE, which will load the executable currently loaded in gdb. So I
think all these forms should be valid:
I notice the current way load works is slightly off. For example, you
can't do "load <offset>" without a symbol file. GDB will complain
about not finding file <offset>. Sounds like that is another
improvement.
Indeed, perhaps it should have been an option "-offset <offset>".
(gdb) load -verify
(gdb) load myfile
(gdb) load -verify myfile
(gdb) load myfile myoffset
(gdb) load -verify myfile myoffset
Ideally, we should be able to place the "dash" arguments anywhere,
just
like with any good command line tool. Since we don't have that, I
think
that having between the command and the positional arguments makes
more
sense. That's my opinion though, I'm curious to hear what others
think.
I'm fine with whatever positioning is deemed appropriate. Personally,
i like the -verify at the end. :-)
The problem with at the end is that it's harder to handle when you also
have a variable number of positional arguments.
For example, if you had:
mycommand [-foo|-bar|-baz] ALPHA [BETA] [GAMMA]
where you can have one or more of -foo/-bar-baz, one required argument
ALPHA and two optional positional arguments BETA and GAMMA. With this
form, it's easy to take care of -foo/-bar/-baz. As soon as you have an
argument that doesn't match those, the rest of argv is the positional
arguments (possibly with -- if you wanted to be able to pass -foo as the
ALPHA parameter).
If they were at the end like so:
mycommand ALPHA [BETA] [GAMMA] [-foo|-bar|-baz]
it becomes difficult to determine whether the argument that follows
ALPHA is BETA or one of -foo/-bar/-baz...
Anyway, the real solution would be to use an appropriate argument
parsing library, so we wouldn't have to reinvent the wheel for every
command, and maybe have some automatically generated help message.
Crazy stuff :).
Thanks,
Simon