public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-python:  * python/python-type.c (set_type): Use parent's originator, if it
@ 2008-11-10 19:19 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2008-11-10 19:19 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-python has been updated
       via  97c867eb4023181294200de2f15111dc425ed93b (commit)
       via  577fe00d4c73ca824a1828524dabbbb6216bc5f1 (commit)
       via  d3c70e7d6337ffce1aa94ad7d9ea8fc8f9928a69 (commit)
      from  c4ed512061cf99390a2a8bad418f8b65ab0d10d0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 97c867eb4023181294200de2f15111dc425ed93b
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Nov 10 12:19:12 2008 -0700

    	* python/python-type.c (set_type): Use parent's originator, if it
    	exists.
    	* gdbtypes.c (delete_main_type): New function.
    	(delete_type_recursive): Use it.  Delete the pointer type,
    	reference type, and chain.

commit 577fe00d4c73ca824a1828524dabbbb6216bc5f1
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Nov 10 12:18:28 2008 -0700

    	* gdb.python/Makefile.in (EXECUTABLES): Add python-template.

commit d3c70e7d6337ffce1aa94ad7d9ea8fc8f9928a69
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Nov 10 10:58:13 2008 -0700

    	* cli/cli-cmds.c (source_script): Clean up full_pathname.

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog                        |   12 +++++++
 gdb/cli/cli-cmds.c                   |    6 +++-
 gdb/gdbtypes.c                       |   59 +++++++++++++++++++++++++--------
 gdb/python/python-type.c             |   17 +++++++---
 gdb/testsuite/ChangeLog              |    4 ++
 gdb/testsuite/gdb.python/Makefile.in |    2 +-
 6 files changed, 78 insertions(+), 22 deletions(-)

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f969681..ceaa078 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,17 @@
 2008-11-10  Tom Tromey  <tromey@redhat.com>
 
+	* python/python-type.c (set_type): Use parent's originator, if it
+	exists.
+	* gdbtypes.c (delete_main_type): New function.
+	(delete_type_recursive): Use it.  Delete the pointer type,
+	reference type, and chain.
+
+2008-11-10  Tom Tromey  <tromey@redhat.com>
+
+	* cli/cli-cmds.c (source_script): Clean up full_pathname.
+
+2008-11-10  Tom Tromey  <tromey@redhat.com>
+
 	* python/python-value.c (valpy_type): Update.
 	* python/python-internal.h (type_to_type_object): Update.
 	* python/python-type.c (pyty_type_object) <originator>: New
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 92a59a3..e1dc88a 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -454,6 +454,7 @@ source_script (char *file, int from_tty)
      files.  Put the full location in 'full_pathname'.  */
   fd = openp (source_path, OPF_TRY_CWD_FIRST,
 	      file, O_RDONLY, 0, &full_pathname);
+  make_cleanup (xfree, full_pathname);
 
   /* Use the full path name, if it is found.  */
   if (full_pathname != NULL && fd != -1)
@@ -466,7 +467,10 @@ source_script (char *file, int from_tty)
       if (from_tty)
 	perror_with_name (file);
       else
-	return;
+	{
+	  do_cleanups (old_cleanups);
+	  return;
+	}
     }
 
   is_python = source_python;
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 614f5be..2743c42 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3065,14 +3065,13 @@ create_deleted_types_hash (void)
   return htab_create (1, htab_hash_pointer, htab_eq_pointer, NULL);
 }
 
-/* Recursively delete TYPE and things it references.  TYPE must have
-   been allocated using xmalloc -- not using an objfile.
-   DELETED_TYPES is a hash table, allocated using
-   create_deleted_types_hash, which is used for checking whether a
-   type has already been deleted.  */
+/* A helper for delete_type_recursive which deletes a main_type and
+   the things to which it refers.  TYPE is a type whose main_type we
+   wish to destroy.  DELETED_TYPES is a hash holding already-seen
+   pointers; see delete_type_recursive.  */
 
-void
-delete_type_recursive (struct type *type, htab_t deleted_types)
+static void
+delete_main_type (struct type *type, htab_t deleted_types)
 {
   int i;
   void **slot;
@@ -3080,17 +3079,19 @@ delete_type_recursive (struct type *type, htab_t deleted_types)
   if (!type)
     return;
 
-  slot = htab_find_slot (deleted_types, type, INSERT);
+  /* Multiple types might share a single main_type.  So, we must
+     check to make sure this is not happening.  */
+  slot = htab_find_slot (deleted_types, TYPE_MAIN_TYPE (type), INSERT);
   if (*slot != NULL)
     return;
-
-  gdb_assert (!TYPE_OBJFILE (type));
-
-  *slot = type;
+  *slot = TYPE_MAIN_TYPE (type);
 
   xfree (TYPE_NAME (type));
   xfree (TYPE_TAG_NAME (type));
 
+  delete_type_recursive (TYPE_TARGET_TYPE (type), deleted_types);
+  delete_type_recursive (TYPE_VPTR_BASETYPE (type), deleted_types);
+
   for (i = 0; i < TYPE_NFIELDS (type); ++i)
     {
       delete_type_recursive (TYPE_FIELD_TYPE (type, i), deleted_types);
@@ -3102,14 +3103,42 @@ delete_type_recursive (struct type *type, htab_t deleted_types)
     }
   xfree (TYPE_FIELDS (type));
 
-  delete_type_recursive (TYPE_TARGET_TYPE (type), deleted_types);
-  delete_type_recursive (TYPE_VPTR_BASETYPE (type), deleted_types);
-
   /* Strangely, HAVE_CPLUS_STRUCT will return true when there isn't
      one at all.  */
   gdb_assert (!HAVE_CPLUS_STRUCT (type) || !TYPE_CPLUS_SPECIFIC (type));
 
   xfree (TYPE_MAIN_TYPE (type));
+}
+
+/* Recursively delete TYPE and things it references.  TYPE must have
+   been allocated using xmalloc -- not using an objfile.
+   DELETED_TYPES is a hash table, allocated using
+   create_deleted_types_hash, which is used for checking whether a
+   type has already been deleted.  */
+
+void
+delete_type_recursive (struct type *type, htab_t deleted_types)
+{
+  void **slot;
+
+  if (!type)
+    return;
+
+  slot = htab_find_slot (deleted_types, type, INSERT);
+  if (*slot != NULL)
+    return;
+  gdb_assert (!TYPE_OBJFILE (type));
+  *slot = type;
+
+  delete_main_type (type, deleted_types);
+  delete_type_recursive (TYPE_POINTER_TYPE (type), deleted_types);
+  delete_type_recursive (TYPE_REFERENCE_TYPE (type), deleted_types);
+
+  /* It is somewhat inefficient to free the chain recursively.
+     However, the list is typically short, and this avoid duplicating
+     the deletion checking code.  */
+  delete_type_recursive (TYPE_CHAIN (type), deleted_types);
+
   xfree (type);
 }
 
diff --git a/gdb/python/python-type.c b/gdb/python/python-type.c
index 3a1074c..e0821d7 100644
--- a/gdb/python/python-type.c
+++ b/gdb/python/python-type.c
@@ -335,13 +335,20 @@ set_type (type_object *obj, struct type *type, type_object *parent)
   else
     obj->next = NULL;
 
-  if (type && parent && parent->owned)
+  obj->originator = NULL;
+  if (type && parent)
     {
-      Py_INCREF (parent);
-      obj->originator = (PyObject *) parent;
+      if (parent->owned)
+	{
+	  Py_INCREF (parent);
+	  obj->originator = (PyObject *) parent;
+	}
+      else if (parent->originator)
+	{
+	  Py_INCREF (parent->originator);
+	  obj->originator = parent->originator;
+	}
     }
-  else
-    obj->originator = NULL;
 }
 
 static PyObject *
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 2ee4513..feeeb51 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 2008-11-10  Tom Tromey  <tromey@redhat.com>
 
+	* gdb.python/Makefile.in (EXECUTABLES): Add python-template.
+
+2008-11-10  Tom Tromey  <tromey@redhat.com>
+
 	* gdb.base/commands.exp (redefine_backtrace_test): New proc.
 	Call it.
 
diff --git a/gdb/testsuite/gdb.python/Makefile.in b/gdb/testsuite/gdb.python/Makefile.in
index 7cf532e..976b7f8 100644
--- a/gdb/testsuite/gdb.python/Makefile.in
+++ b/gdb/testsuite/gdb.python/Makefile.in
@@ -1,7 +1,7 @@
 VPATH = @srcdir@
 srcdir = @srcdir@
 
-EXECUTABLES = python-value python-prettyprint
+EXECUTABLES = python-value python-prettyprint python-template
 
 all info install-info dvi install uninstall installcheck check:
 	@echo "Nothing to be done for $@..."


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-10 19:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-10 19:19 [SCM] archer-tromey-python: * python/python-type.c (set_type): Use parent's originator, if it tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).