Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [python] [patch] PR python/13363
@ 2011-11-01 14:26 Phil Muldoon
  2011-11-01 17:53 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Muldoon @ 2011-11-01 14:26 UTC (permalink / raw)
  To: gdb-patches


As part of a previous patch (to fix Python usage around TRY_CATCH
blocks) I introduced a bug.  I missed the fact that in this case, the
functions returns from an exception handler.  Obviously this is wrong.
This patch addresses this.

OK?

Cheers,

Phil

--

2011-11-01  Phil Muldoon  <pmuldoon@redhat.com>

	PR Python/13363

	* python/py-type.c (typy_lookup_type): Do not return a type in
          an exception handler.

--

Index: python/py-type.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-type.c,v
retrieving revision 1.27
diff -u -r1.27 py-type.c
--- python/py-type.c	27 Oct 2011 09:14:27 -0000	1.27
+++ python/py-type.c	1 Nov 2011 11:15:43 -0000
@@ -606,7 +606,7 @@
 typy_lookup_type (struct demangle_component *demangled,
 		  const struct block *block)
 {
-  struct type *type;
+  struct type *type, *rtype = NULL;
   char *type_name = NULL;
   enum demangle_component_type demangled_type;
   volatile struct gdb_exception except;
@@ -626,19 +626,25 @@
 
       TRY_CATCH (except, RETURN_MASK_ALL)
 	{
+	  /* If the demangled_type matches with one of the types
+	     below, run the corresponding function and save the type
+	     to return later.  We cannot just return here as we are in
+	     an exception handler.  */
 	  switch (demangled_type)
 	    {
 	    case DEMANGLE_COMPONENT_REFERENCE:
-	      return lookup_reference_type (type);
+	      rtype =  lookup_reference_type (type);
+	      break;
 	    case DEMANGLE_COMPONENT_POINTER:
-	      return lookup_pointer_type (type);
+	      rtype = lookup_pointer_type (type);
+	      break;
 	    case DEMANGLE_COMPONENT_CONST:
-	      return make_cv_type (1, 0, type, NULL);
+	      rtype = make_cv_type (1, 0, type, NULL);
+	      break;
 	    case DEMANGLE_COMPONENT_VOLATILE:
-	      return make_cv_type (0, 1, type, NULL);
+	      rtype = make_cv_type (0, 1, type, NULL);
+	      break;
 	    }
-
-	  type_name = cp_comp_to_string (demangled, 10);
 	}
       if (except.reason < 0)
 	{
@@ -646,7 +652,14 @@
 	  return NULL;
 	}
     }
-
+  
+  /* If we have a type from the switch statement above, just return
+     that.  */
+  if (rtype)
+    return rtype;
+  
+  /* We don't have a type, so lookup the type.  */
+  type_name = cp_comp_to_string (demangled, 10);
   type = typy_lookup_typename (type_name, block);
   xfree (type_name);
 


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [python] [patch] PR python/13363
  2011-11-01 14:26 [python] [patch] PR python/13363 Phil Muldoon
@ 2011-11-01 17:53 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2011-11-01 17:53 UTC (permalink / raw)
  To: pmuldoon; +Cc: gdb-patches

>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:

Phil> 2011-11-01  Phil Muldoon  <pmuldoon@redhat.com>
Phil> 	PR Python/13363
Phil> 	* python/py-type.c (typy_lookup_type): Do not return a type in
Phil>           an exception handler.

Ok.

Tom


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-01 17:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-01 14:26 [python] [patch] PR python/13363 Phil Muldoon
2011-11-01 17:53 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox