From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2738 invoked by alias); 11 Dec 2013 16:33:32 -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 2729 invoked by uid 89); 11 Dec 2013 16:33:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f176.google.com Received: from Unknown (HELO mail-wi0-f176.google.com) (209.85.212.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 11 Dec 2013 16:33:30 +0000 Received: by mail-wi0-f176.google.com with SMTP id hq4so7329538wib.15 for ; Wed, 11 Dec 2013 08:33:21 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.180.104.42 with SMTP id gb10mr25168714wib.51.1386779601631; Wed, 11 Dec 2013 08:33:21 -0800 (PST) Received: by 10.194.123.4 with HTTP; Wed, 11 Dec 2013 08:33:21 -0800 (PST) In-Reply-To: <52A75A05.60006@redhat.com> References: <5265022F.8060203@mentor.com> <52654A2C.9010202@redhat.com> <529707C7.4040504@mentor.com> <5298AE7C.6020607@redhat.com> <529C80D2.2080608@mentor.com> <529C9B42.20600@redhat.com> <529D62F7.80701@mentor.com> <52A22582.8040509@redhat.com> <52A40015.207@mentor.com> <52A61E86.3020005@redhat.com> <52A750AA.1080807@redhat.com> <52A75A05.60006@redhat.com> Date: Wed, 11 Dec 2013 16:33:00 -0000 Message-ID: Subject: Re: [PATCH] Eliminate UNSUPPORTED_ERROR. From: Doug Evans To: Pedro Alves Cc: Hui Zhu , gdb-patches ml Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00437.txt.bz2 On Tue, Dec 10, 2013 at 10:14 AM, Pedro Alves wrote: > On 12/10/2013 05:34 PM, Pedro Alves wrote: >> On 12/09/2013 09:07 PM, Doug Evans wrote: > >>>>> --- a/gdb/cli/cli-cmds.c >>>>> +++ b/gdb/cli/cli-cmds.c >>>>> @@ -527,24 +527,16 @@ source_script_from_stream (FILE *stream, const char *file) >>>>> { >>>>> volatile struct gdb_exception e; >>>>> >>>>> - TRY_CATCH (e, RETURN_MASK_ERROR) >>>>> - { >>>>> - source_python_script (stream, file); >>>>> - } >>>>> - if (e.reason < 0) >>>>> + if (!source_python_script (stream, file)) >>> If we must change things, I would prefer having a predicate >>> and call that first. >> >> I can try that. > > OK? A few nits, but yep. > > gdb/ > 2013-12-10 Pedro Alves > > * cli/cli-cmds.c (source_script_from_stream) Use have_python > instead of catching UNSUPPORTED_ERROR. > * exceptions.h (UNSUPPORTED_ERROR): Delete. > * python/python.c (source_python_script) [!HAVE_PYTHON]: Internal > error if called. > * python/python.h (have_python): New static inline function. > --- > gdb/cli/cli-cmds.c | 27 ++++++++------------------- > gdb/exceptions.h | 3 --- > gdb/python/python.c | 5 +++-- > gdb/python/python.h | 13 +++++++++++++ > 4 files changed, 24 insertions(+), 24 deletions(-) > > diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c > index 52a6bc9..a0586ff 100644 > --- a/gdb/cli/cli-cmds.c > +++ b/gdb/cli/cli-cmds.c > @@ -525,27 +525,16 @@ source_script_from_stream (FILE *stream, const char *file) > if (script_ext_mode != script_ext_off > && strlen (file) > 3 && !strcmp (&file[strlen (file) - 3], ".py")) > { > - volatile struct gdb_exception e; > - > - TRY_CATCH (e, RETURN_MASK_ERROR) > + if (have_python ()) > + source_python_script (stream, file); > + else if (script_ext_mode == script_ext_soft) > { > - source_python_script (stream, file); > - } > - if (e.reason < 0) > - { > - /* Should we fallback to ye olde GDB script mode? */ > - if (script_ext_mode == script_ext_soft > - && e.reason == RETURN_ERROR && e.error == UNSUPPORTED_ERROR) > - { > - fseek (stream, 0, SEEK_SET); > - script_from_file (stream, (char*) file); > - } > - else > - { > - /* Nope, just punt. */ > - throw_exception (e); > - } > + /* Fallback to GDB script mode. */ > + fseek (stream, 0, SEEK_SET); > + script_from_file (stream, (char*) file); Remove the fseek and cast. [that'll probably require removing the { } too, sigh]