This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: GDB aborts on missing command args. Which way to fix?
On Fri, Sep 19, 2008 at 03:50:03PM -0600, Tom Tromey wrote:
> >>>>> "Paul" == Paul Pluzhnikov <ppluzhnikov@google.com> writes:
>
> Paul> There are many instances of calls to buildargv() which aren't
> Paul> protected by 'if (args != NULL)', and cause gdb to abort.
> [...]
> Paul> I can fix this by adding the 'if (args != NULL)' checks everywhere,
> Paul> or by switching to 'buildargv_not_null(args, "appropriate missing
> Paul> argument error")'
>
> Paul> Which way is preferred? (I prefer the second way).
>
> That seems reasonable to me.
>
> I think you might as well make it call nomem if the result is NULL,
> too.
I don't like passing error messages to functions that might fail; I
find it very confusing. If you want to give usage errors, why not
combine it with the existing checks for wrong arguments?
Tom's got a good point about nomem, though.
--
Daniel Jacobowitz
CodeSourcery