This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Eliminate UNSUPPORTED_ERROR.
- From: Doug Evans <xdje42 at gmail dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Hui Zhu <hui_zhu at mentor dot com>, gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Wed, 11 Dec 2013 08:33:21 -0800
- Subject: Re: [PATCH] Eliminate UNSUPPORTED_ERROR.
- Authentication-results: sourceware.org; auth=none
- References: <5265022F dot 8060203 at mentor dot com> <52654A2C dot 9010202 at redhat dot com> <529707C7 dot 4040504 at mentor dot com> <5298AE7C dot 6020607 at redhat dot com> <529C80D2 dot 2080608 at mentor dot com> <529C9B42 dot 20600 at redhat dot com> <529D62F7 dot 80701 at mentor dot com> <52A22582 dot 8040509 at redhat dot com> <52A40015 dot 207 at mentor dot com> <52A61E86 dot 3020005 at redhat dot com> <m31u1lvimb dot fsf at sspiff dot org> <52A750AA dot 1080807 at redhat dot com> <52A75A05 dot 60006 at redhat dot com>
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]