Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Phil Muldoon <pmuldoon@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] [python] Use TRY_CATCH in some functions.
Date: Thu, 20 Oct 2011 13:03:00 -0000	[thread overview]
Message-ID: <m3fwinu8f4.fsf@redhat.com> (raw)
In-Reply-To: <m3hb3fa3bc.fsf@fleche.redhat.com> (Tom Tromey's message of "Tue,	11 Oct 2011 10:41:27 -0600")

Tom Tromey <tromey@redhat.com> writes:

> Phil> @@ -624,20 +625,31 @@ typy_lookup_type (struct demangle_component *demangled,
> [...]
>
> Phil> +      if (except.reason < 0)
> Phil> +	{
> Phil> +	  PyErr_Format (except.reason == RETURN_QUIT
> Phil> +			? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
> Phil> +			"%s", except.message);
> Phil> +	  return NULL;
>
> Why not GDB_PY_HANDLE_EXCEPTION here?
> (And also fix up typy_lookup_typename to do the same.)

Because typy_lookup_typename and typy_lookup_type are helper functions
that return struct type, while GDB_PY_HANDLE_EXCEPTION returns a
PyObject (from gdbpy_convert_exception).  Should we have a macro that
builds an exception without returning one? We should, I think.  But I was not
going to do that in this patch context.

> Phil> @@ -990,8 +1002,16 @@ typy_richcompare (PyObject *self, PyObject *other, int op)
> [...]
> Phil> +	{
> Phil> +	  bcache_xfree (cache);
> Phil> +	  VEC_free (type_equality_entry_d, worklist);
> Phil> +	  GDB_PY_HANDLE_EXCEPTION (except);
>
> I think the freeing should be hoisted above the exception check, to
> consolidate the code.  With the current patch the code is duplicated on
> both branches.

I amended the logic to look like this:

@@ -1007,11 +1007,13 @@
 	{
 	  result = check_types_worklist (&worklist, cache);
 	}
-      if (except.reason < 0)
-	result = Py_NE;
-
+      /* check_types_worklist calls several nested Python helper
+	 functions, some of which can raise a GDB Exception, so we
+	 just check and convert here.  If there is a GDB exception, a
+	 comparison is not capable (or trusted), so exit.  */
       bcache_xfree (cache);
       VEC_free (type_equality_entry_d, worklist);
+      GDB_PY_HANDLE_EXCEPTION (except);
     }
 
   if (op == result)

Cheers,

Phil


  reply	other threads:[~2011-10-20 12:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-11 11:57 Phil Muldoon
2011-10-11 17:30 ` Tom Tromey
2011-10-20 13:03   ` Phil Muldoon [this message]
2011-10-20 14:23     ` Tom Tromey
2011-10-24 13:42       ` Phil Muldoon
2011-10-24 13:59         ` Tom Tromey
2011-10-27 10:17           ` Phil Muldoon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3fwinu8f4.fsf@redhat.com \
    --to=pmuldoon@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox