This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Eliminate UNSUPPORTED_ERROR.


On Tue, Dec 10, 2013 at 10:14 AM, Pedro Alves <palves@redhat.com> 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  <palves@redhat.com>
>
>         * 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]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]