This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/2] Use mi_getopt_silent
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <yao at codesourcery dot com>
- Cc: "Agovic, Sanimir" <sanimir dot agovic at intel dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Mon, 26 Aug 2013 17:00:52 +0100
- Subject: Re: [PATCH 1/2] Use mi_getopt_silent
- Authentication-results: sourceware.org; auth=none
- References: <51FA557F dot 5 at redhat dot com> <1377402123-3740-1-git-send-email-yao at codesourcery dot com> <1377402123-3740-2-git-send-email-yao at codesourcery dot com> <0377C58828D86C4588AEEC42FC3B85A71764DC1D at IRSMSX105 dot ger dot corp dot intel dot com> <521B2B1B dot 7040309 at codesourcery dot com>
On 08/26/2013 11:16 AM, Yao Qi wrote:
> On 08/26/2013 04:58 PM, Agovic, Sanimir wrote:
>> I`d rather catch the exception in mi_cmd_stack_list_args to prevent the
>> error to bubble up to upper layers. This requires the use of
>> throw_error (NOT_FOUND_ERROR, ...) instead of error (...) in mi_getopt
>> to catch the right exception (*) and re-throw otherwise.
>
> Sanimir, thanks for your comments.
>
> I am not inclined to use exception here because exception handling in
> GDB is poor. On the other hand, I don't like using exception to
> control the program flow. In some commands, there is no unknown
> options, and in other commands, there may be unknown options. Both of
> them are expected. In the former, GDB can throw an error, and in the
> later, GDB can silently return -1.
Agreed. Sometimes it's hard to avoid going the throw + swallow-error
route, but in this case it's trivial.
>> Due to the poor exception handling in gdb this may lead to some boilerplate
>> code. On the other side it keeps the interface simple & consistent
>> e.g. (*) in the patch below mi_getopt_silent may still be verbose/throw.
>
> Yes, mi_getopt_silent may throw error when the argument of an option is
> missing, because it is wrong. "silent" here is only for unknown
> options, which is expected in some commands.
Maybe it's just "silent" that's the confusing term to use. Maybe
mi_getopt_unknown or even something longer would make it less
confusing.
--
Pedro Alves