From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2776 invoked by alias); 26 Aug 2013 16:01:01 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 2762 invoked by uid 89); 26 Aug 2013 16:01:01 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Aug 2013 16:01:01 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.8 required=5.0 tests=ALL_TRUSTED,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7QG0s78001091 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 26 Aug 2013 12:00:54 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r7QG0qoK025454; Mon, 26 Aug 2013 12:00:53 -0400 Message-ID: <521B7BB4.4080407@redhat.com> Date: Mon, 26 Aug 2013 16:01:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Yao Qi CC: "Agovic, Sanimir" , "gdb-patches@sourceware.org" Subject: Re: [PATCH 1/2] Use mi_getopt_silent References: <51FA557F.5@redhat.com> <1377402123-3740-1-git-send-email-yao@codesourcery.com> <1377402123-3740-2-git-send-email-yao@codesourcery.com> <0377C58828D86C4588AEEC42FC3B85A71764DC1D@IRSMSX105.ger.corp.intel.com> <521B2B1B.7040309@codesourcery.com> In-Reply-To: <521B2B1B.7040309@codesourcery.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-08/txt/msg00749.txt.bz2 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