public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-python-checker: add some stolen-reference handling
@ 2012-01-05 15:41 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2012-01-05 15:41 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-python-checker has been updated
       via  abdde5e1813ce5829756649fc60a1f8d8b3f51c2 (commit)
       via  4cb09a6d55f7b49b62fb7952fe266dbc20f224e4 (commit)
       via  4846798bbc3f7e19c4ba65b6ae6b1dadc16f2191 (commit)
       via  22985bd23751b07f244deb259c13ca4c5f82df8b (commit)
       via  7129ad3da36a16ad218b729d08143c2120710b5c (commit)
      from  64c15e338a203c7c6a7ea2126f44f5c241a1c335 (commit)

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

- Log -----------------------------------------------------------------
commit abdde5e1813ce5829756649fc60a1f8d8b3f51c2
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Jan 4 15:03:57 2012 -0700

    add some stolen-reference handling

commit 4cb09a6d55f7b49b62fb7952fe266dbc20f224e4
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Jan 4 15:00:57 2012 -0700

    fix refcount bug found by the checker

commit 4846798bbc3f7e19c4ba65b6ae6b1dadc16f2191
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Jan 4 14:59:59 2012 -0700

    fix error-checking bug found by the checker

commit 22985bd23751b07f244deb259c13ca4c5f82df8b
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Jan 4 14:41:44 2012 -0700

    fix bug found by checker; PyObject_GetAttrString returns a new ref

commit 7129ad3da36a16ad218b729d08143c2120710b5c
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Nov 28 08:29:33 2011 -0700

    first bits of type-object-for-typedef
    unfinished

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

Summary of changes:
 gdb/python/py-cmd.c          |    4 +++-
 gdb/python/py-event.h        |    5 +++--
 gdb/python/py-evtregistry.c  |    5 ++++-
 gdb/python/py-function.c     |   18 ++++++++++++------
 gdb/python/python-internal.h |   14 +++++++++++---
 gdb/python/python.c          |    4 +++-
 6 files changed, 36 insertions(+), 14 deletions(-)

First 500 lines of diff:
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index cfddff8..bbc0d2e 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -1,6 +1,6 @@
 /* gdb commands implemented in Python
 
-   Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -666,6 +666,8 @@ gdbpy_string_to_argv (PyObject *self, PyObject *args)
     return NULL;
 
   py_argv = PyList_New (0);
+  if (py_argv == NULL)
+    return NULL;
 
   /* buildargv uses NULL to represent an empty argument list, but we can't use
      that in Python.  Instead, if ARGS is "" then return an empty list.
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index 716aabd..1880510 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -1,6 +1,6 @@
 /* Python interface to inferior events.
 
-   Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -107,7 +107,8 @@ extern int emit_continue_event (ptid_t ptid);
 extern int emit_exited_event (const LONGEST *exit_code, struct inferior *inf);
 
 extern int evpy_emit_event (PyObject *event,
-                            eventregistry_object *registry);
+                            eventregistry_object *registry)
+  CPYCHECKER_STEALS_REFERENCE_TO_ARG (1);
 
 extern PyObject *create_event_object (PyTypeObject *py_type);
 extern PyObject *create_thread_event_object (PyTypeObject *py_type);
diff --git a/gdb/python/py-evtregistry.c b/gdb/python/py-evtregistry.c
index 67d5715..8782229 100644
--- a/gdb/python/py-evtregistry.c
+++ b/gdb/python/py-evtregistry.c
@@ -88,7 +88,10 @@ create_eventregistry_object (void)
 
   eventregistry_obj->callbacks = PyList_New (0);
   if (!eventregistry_obj->callbacks)
-    return NULL;
+    {
+      Py_DECREF (eventregistry_obj);
+      return NULL;
+    }
 
   return eventregistry_obj;
 }
diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c
index de7e94c..5d0bcdd 100644
--- a/gdb/python/py-function.c
+++ b/gdb/python/py-function.c
@@ -1,6 +1,6 @@
 /* Convenience functions implemented in Python.
 
-   Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -174,14 +174,20 @@ fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
   if (PyObject_HasAttrString (self, "__doc__"))
     {
       PyObject *ds_obj = PyObject_GetAttrString (self, "__doc__");
-      if (ds_obj && gdbpy_is_string (ds_obj))
+      if (ds_obj)
 	{
-	  docstring = python_string_to_host_string (ds_obj);
-	  if (docstring == NULL)
+	  if (gdbpy_is_string (ds_obj))
 	    {
-	      Py_DECREF (self);
-	      return -1;
+	      docstring = python_string_to_host_string (ds_obj);
+	      if (docstring == NULL)
+		{
+		  Py_DECREF (self);
+		  Py_DECREF (ds_obj);
+		  return -1;
+		}
 	    }
+
+	  Py_DECREF (ds_obj);
 	}
     }
   if (! docstring)
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index c6817b8..8ffa69e 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -1,6 +1,6 @@
 /* Gdb/Python header for private use by Python module.
 
-   Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -25,8 +25,14 @@
 #ifdef WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE
 #define CPYCHECKER_RETURNS_BORROWED_REF			\
   __attribute__((cpychecker_returns_borrowed_ref))
+#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG)		\
+  __attribute__((cpychecker_type_object_for_typedef(ARG)))
+#define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) \
+   __attribute__((cpychecker_steals_reference_to_arg(n)))
 #else
 #define CPYCHECKER_RETURNS_BORROWED_REF
+#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG)
+#define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n)
 #endif
 
 #include <stdio.h>
@@ -123,8 +129,10 @@ struct bpstats;
 struct inferior;
 
 extern PyObject *gdb_module;
-extern PyTypeObject value_object_type;
-extern PyTypeObject block_object_type;
+extern PyTypeObject value_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF("value_object");
+extern PyTypeObject block_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF("block_object");
 extern PyTypeObject symbol_object_type;
 extern PyTypeObject event_object_type;
 extern PyTypeObject events_object_type;
diff --git a/gdb/python/python.c b/gdb/python/python.c
index df8e3d5..630354a 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1,6 +1,6 @@
 /* General python/gdb code
 
-   Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -748,6 +748,8 @@ before_prompt_hook (const char *current_gdb_prompt)
       if (hook == NULL)
 	goto fail;
 
+      make_cleanup_py_decref (hook);
+
       if (PyCallable_Check (hook))
 	{
 	  PyObject *result;


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


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

only message in thread, other threads:[~2012-01-05 15:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-05 15:41 [SCM] archer-tromey-python-checker: add some stolen-reference handling 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).