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: Yao Qi <yao at codesourcery dot com>
- To: "Agovic, Sanimir" <sanimir dot agovic at intel dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Mon, 26 Aug 2013 18:16:59 +0800
- 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>
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.
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.
--
Yao (éå)