* python/py-arch.c (arch_object_type): Use
authorTom Tromey <tromey@redhat.com>
Mon, 20 May 2013 20:09:01 +0000 (20:09 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 20 May 2013 20:09:01 +0000 (20:09 +0000)
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-block.c (block_syms_iterator_object_type):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-bpevent.c (breakpoint_event_object_type):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-cmd.c (cmdpy_object_type): Use
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-continueevent.c (continue_event_object_type):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-event.h (GDBPY_NEW_EVENT_TYPE):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-events.h (thread_event_object_type):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-evtregistry.c (eventregistry_object_type): Use
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-exitedevent.c (exited_event_object_type):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-finishbreakpoint.c (finish_breakpoint_object_type):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-function.c (fnpy_object_type): Use
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-inferior.c (inferior_object_type, membuf_object_type):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-infthread.c (thread_object_type): Use
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-lazy-string.c (lazy_string_object_type):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-newobjfileevent.c (new_objfile_event_object_type):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-objfile.c (objfile_object_type): Use
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-param.c (parmpy_object_type):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-progspace.c (pspace_object_type):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-signalevent.c (signal_event_object_type):
Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-symtab.c (symtab_object_type, sal_object_type): Use
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-type.c (type_object_type, field_object_type)
(type_iterator_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
* python/py-internal.h (CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF): New
define.
(value_object_type, block_object_type, symbol_object_type)
(event_object_type, stop_event_object_type, breakpoint_object_type)
(frame_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.

23 files changed:
gdb/ChangeLog
gdb/python/py-arch.c
gdb/python/py-block.c
gdb/python/py-bpevent.c
gdb/python/py-cmd.c
gdb/python/py-continueevent.c
gdb/python/py-event.h
gdb/python/py-events.h
gdb/python/py-evtregistry.c
gdb/python/py-exitedevent.c
gdb/python/py-finishbreakpoint.c
gdb/python/py-function.c
gdb/python/py-inferior.c
gdb/python/py-infthread.c
gdb/python/py-lazy-string.c
gdb/python/py-newobjfileevent.c
gdb/python/py-objfile.c
gdb/python/py-param.c
gdb/python/py-progspace.c
gdb/python/py-signalevent.c
gdb/python/py-symtab.c
gdb/python/py-type.c
gdb/python/python-internal.h

index 7b77a06025c0cf6ee92a4bf820e3daae7dedb3c7..89504b3b9a993256e7dd03a5fef86e2161c7a047 100644 (file)
@@ -1,3 +1,53 @@
+2013-05-20  Tom Tromey  <tromey@redhat.com>
+
+       * python/py-arch.c (arch_object_type): Use
+       CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-block.c (block_syms_iterator_object_type):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-bpevent.c (breakpoint_event_object_type):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-cmd.c (cmdpy_object_type): Use
+       CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-continueevent.c (continue_event_object_type):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-event.h (GDBPY_NEW_EVENT_TYPE):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-events.h (thread_event_object_type):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-evtregistry.c (eventregistry_object_type): Use
+       CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-exitedevent.c (exited_event_object_type):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-finishbreakpoint.c (finish_breakpoint_object_type):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-function.c (fnpy_object_type): Use
+       CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-inferior.c (inferior_object_type, membuf_object_type):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-infthread.c (thread_object_type): Use
+       CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-lazy-string.c (lazy_string_object_type):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-newobjfileevent.c (new_objfile_event_object_type):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-objfile.c (objfile_object_type): Use
+       CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-param.c (parmpy_object_type):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-progspace.c (pspace_object_type):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-signalevent.c (signal_event_object_type):
+       Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-symtab.c (symtab_object_type, sal_object_type): Use
+       CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-type.c (type_object_type, field_object_type)
+       (type_iterator_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+       * python/py-internal.h (CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF): New
+       define.
+       (value_object_type, block_object_type, symbol_object_type)
+       (event_object_type, stop_event_object_type, breakpoint_object_type)
+       (frame_object_type): Use CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF.
+
 2013-05-20  Andreas Tobler  <andreas@fgznet.ch>
 
        * Makefile.in (ALL_TARGET_OBS): Add ppcfbsd-tdep.o.
index ddfebdb2f7dd9ef92bd588c46bb27eb59c88f6b6..7eb6eea1dcf129b240b06a14bc9bb1c3ef7848e6 100644 (file)
@@ -29,7 +29,9 @@ typedef struct arch_object_type_object {
 } arch_object;
 
 static struct gdbarch_data *arch_object_data = NULL;
-static PyTypeObject arch_object_type;
+
+static PyTypeObject arch_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("arch_object");
 
 /* Associates an arch_object with GDBARCH as gdbarch_data via the gdbarch
    post init registration mechanism (gdbarch_data_register_post_init).  */
index f0b8322270617845835c9159d9d7af4ee19cf6d2..afc8959027e5d655819494cc14b029882fc1b6d8 100644 (file)
@@ -78,7 +78,8 @@ typedef struct {
       }                                                                        \
   } while (0)
 
-static PyTypeObject block_syms_iterator_object_type;
+static PyTypeObject block_syms_iterator_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("block_syms_iterator_object");
 static const struct objfile_data *blpy_objfile_data_key;
 
 static PyObject *
index dad93dc8df4b9c6fe195b83b7ca45aa669283295..5238ad89c237e93d78514a556ae7abc5d070ac7c 100644 (file)
@@ -20,7 +20,8 @@
 #include "defs.h"
 #include "py-stopevent.h"
 
-static PyTypeObject breakpoint_event_object_type;
+static PyTypeObject breakpoint_event_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
 
 /* Create and initialize a BreakpointEvent object.  This acquires new
    references to BREAKPOINT_LIST and FIRST_BP.  */
index 161b4bcdc98bdf3daf1872acfe3159eacbaefe9d..3da9960c58029a4d02083aad0162cdf2e95308bc 100644 (file)
@@ -68,7 +68,8 @@ struct cmdpy_object
 
 typedef struct cmdpy_object cmdpy_object;
 
-static PyTypeObject cmdpy_object_type;
+static PyTypeObject cmdpy_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("cmdpy_object");
 
 /* Constants used by this module.  */
 static PyObject *invoke_cst;
index 6412c01ae75457b4bd85d07b743b3914e95c3512..c1f8f65d8a1f10d8d36d4430381ccd088c79cdf6 100644 (file)
@@ -20,7 +20,8 @@
 #include "defs.h"
 #include "py-event.h"
 
-static PyTypeObject continue_event_object_type;
+static PyTypeObject continue_event_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
 
 static PyObject *
 create_continue_event_object (void)
index 86da97435ec659bb0fbf3826134cc546f461ca6c..970595b33ceed7c2d7361e2ea3886ecb94e4f8c6 100644 (file)
@@ -46,8 +46,9 @@
 
 #define GDBPY_NEW_EVENT_TYPE(name, py_path, py_name, doc, base, qual) \
 \
-    qual PyTypeObject name##_event_object_type = \
-    { \
+    qual PyTypeObject name##_event_object_type \
+        CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object") \
+    = { \
       PyVarObject_HEAD_INIT (NULL, 0)                          \
       py_path,                                    /* tp_name */ \
       sizeof (event_object),                      /* tp_basicsize */ \
index 537bcc9176fe09351a51003cbc5424ab0e35d78f..4ec3832a75313ddf629a93d3f7659b77733deba4 100644 (file)
@@ -24,7 +24,8 @@
 #include "python-internal.h"
 #include "inferior.h"
 
-extern PyTypeObject thread_event_object_type;
+extern PyTypeObject thread_event_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
 
 /* Stores a list of objects to be notified when the event for which this
    registry tracks occurs.  */
index 2e338ccf5be2e0bde7ecfaeb6216f75d7989dde0..c8003af9af7d28d785a7105d81f6469e18b3bdf3 100644 (file)
@@ -23,7 +23,8 @@
 
 events_object gdb_py_events;
 
-static PyTypeObject eventregistry_object_type;
+static PyTypeObject eventregistry_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("eventregistry_object");
 
 /* Implementation of EventRegistry.connect () -> NULL.
    Add FUNCTION to the list of listeners.  */
index 725518bca23cc32c0d2cf009f1a1be1f97388147..49c3100c6588e9d0a2f219684baedf8e63fbdbb4 100644 (file)
@@ -20,7 +20,8 @@
 #include "defs.h"
 #include "py-event.h"
 
-static PyTypeObject exited_event_object_type;
+static PyTypeObject exited_event_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
 
 static PyObject *
 create_exited_event_object (const LONGEST *exit_code, struct inferior *inf)
index 6e095b593fce885d3f4c4ba2d00507f6b5e2e3e4..b52bd7ec5c01065e34d7323723e7cb8bbdc8dfaa 100644 (file)
@@ -31,8 +31,6 @@
 #include "inferior.h"
 #include "block.h"
 
-static PyTypeObject finish_breakpoint_object_type;
-
 /* Function that is called when a Python finish bp is found out of scope.  */
 static char * const outofscope_func = "out_of_scope";
 
@@ -55,6 +53,9 @@ struct finish_breakpoint_object
   PyObject *return_value;
 };
 
+static PyTypeObject finish_breakpoint_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("finish_breakpoint_object");
+
 /* Python function to get the 'return_value' attribute of
    FinishBreakpoint.  */
 
index bd25263da8e77a7caeb4783d48c48cf2dd4e22f6..e2ba19fce39abf1e255433689981f07496e176d2 100644 (file)
@@ -29,7 +29,8 @@
 #include "expression.h"
 #include "language.h"
 
-static PyTypeObject fnpy_object_type;
+static PyTypeObject fnpy_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("PyObject");
 
 \f
 
index cee3a0ded013a642763786a58a042217449c3978..d35d09a39fb95a2c0e99aa70fd4409f85cdd92ca 100644 (file)
@@ -51,7 +51,8 @@ typedef struct
   int nthreads;
 } inferior_object;
 
-static PyTypeObject inferior_object_type;
+static PyTypeObject inferior_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("inferior_object");
 
 static const struct inferior_data *infpy_inf_data_key;
 
@@ -64,7 +65,8 @@ typedef struct {
   CORE_ADDR length;
 } membuf_object;
 
-static PyTypeObject membuf_object_type;
+static PyTypeObject membuf_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("membuf_object");
 
 /* Require that INFERIOR be a valid inferior ID.  */
 #define INFPY_REQUIRE_VALID(Inferior)                          \
index a5a083f2181cc2b5efd50648d87f33dae1daff8d..a0545eca74b4bc7049219bb5ab3e4609a84b6b53 100644 (file)
@@ -23,7 +23,8 @@
 #include "inferior.h"
 #include "python-internal.h"
 
-static PyTypeObject thread_object_type;
+static PyTypeObject thread_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("thread_object");
 
 /* Require that INFERIOR be a valid inferior ID.  */
 #define THPY_REQUIRE_VALID(Thread)                             \
index 68350679b81b008ca0ea93323cf7cfac8831f760..df54cf4a16bcb5b816c66fd41ed7392883958a99 100644 (file)
@@ -47,7 +47,8 @@ typedef struct {
   struct type *type;
 } lazy_string_object;
 
-static PyTypeObject lazy_string_object_type;
+static PyTypeObject lazy_string_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("lazy_string_object");
 
 static PyObject *
 stpy_get_address (PyObject *self, void *closure)
index 538e2d8e2f12617d92768eb351e56b63925790a7..d781e92f95d09624c15c48b32ab618a8e922a252 100644 (file)
@@ -20,7 +20,8 @@
 #include "defs.h"
 #include "py-event.h"
 
-static PyTypeObject new_objfile_event_object_type;
+static PyTypeObject new_objfile_event_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
 
 static PyObject *
 create_new_objfile_event_object (struct objfile *objfile)
index 6fa303561fb764c3fe8d16aa29257b5470a19a38..27f346304944c3bbae62a46ea4f3c760ef3dd53d 100644 (file)
@@ -39,7 +39,8 @@ typedef struct
   PyObject *type_printers;
 } objfile_object;
 
-static PyTypeObject objfile_object_type;
+static PyTypeObject objfile_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("objfile_object");
 
 static const struct objfile_data *objfpy_objfile_data_key;
 
index acb48cd3375cf14b06e30c05ab3a50249abfc765..176bbc2b5de448d9a070f7a70901281e255c7b71 100644 (file)
@@ -89,7 +89,8 @@ struct parmpy_object
 
 typedef struct parmpy_object parmpy_object;
 
-static PyTypeObject parmpy_object_type;
+static PyTypeObject parmpy_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("parmpy_object");
 
 /* Some handy string constants.  */
 static PyObject *set_doc_cst;
index 104b36d1b91285cc25326f6105e39fdfe9b8ebf1..5d4911a778428124d33e43ed593743eefedb2d77 100644 (file)
@@ -41,7 +41,8 @@ typedef struct
   PyObject *type_printers;
 } pspace_object;
 
-static PyTypeObject pspace_object_type;
+static PyTypeObject pspace_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("pspace_object");
 
 static const struct program_space_data *pspy_pspace_data_key;
 
index 3d649367696d1eca7e06362a01151435ba1cd857..1d723f0ff29c58b684070f7d14bf62dd54cae862 100644 (file)
@@ -20,7 +20,8 @@
 #include "defs.h"
 #include "py-stopevent.h"
 
-static PyTypeObject signal_event_object_type;
+static PyTypeObject signal_event_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
 
 PyObject *
 create_signal_event_object (enum gdb_signal stop_signal)
index 6fa8ecb8f0759ed4fdfa3c3f5f3143cdb07b32d4..94c05be90a2a6170e6ce1f0867fd3de1273d871d 100644 (file)
@@ -37,7 +37,8 @@ typedef struct stpy_symtab_object {
   struct stpy_symtab_object *next;
 } symtab_object;
 
-static PyTypeObject symtab_object_type;
+static PyTypeObject symtab_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("symtab_object");
 static const struct objfile_data *stpy_objfile_data_key;
 
 /* Require a valid symbol table.  All access to symtab_object->symtab
@@ -67,7 +68,8 @@ typedef struct salpy_sal_object {
   struct salpy_sal_object *next;
 } sal_object;
 
-static PyTypeObject sal_object_type;
+static PyTypeObject sal_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("sal_object");
 static const struct objfile_data *salpy_objfile_data_key;
 
 /* Require a valid symbol table and line object.  All access to
index 051cff07f13f5801de8342365d37eb94f344cad4..7cc89ca70b283ef06905d3507767b923372baee5 100644 (file)
@@ -44,7 +44,8 @@ typedef struct pyty_type_object
   struct pyty_type_object *next;
 } type_object;
 
-static PyTypeObject type_object_type;
+static PyTypeObject type_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("type_object");
 
 /* A Field object.  */
 typedef struct pyty_field_object
@@ -55,7 +56,8 @@ typedef struct pyty_field_object
   PyObject *dict;
 } field_object;
 
-static PyTypeObject field_object_type;
+static PyTypeObject field_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("field_object");
 
 /* A type iterator object.  */
 typedef struct {
@@ -68,7 +70,8 @@ typedef struct {
   struct pyty_type_object *source;
 } typy_iterator_object;
 
-static PyTypeObject type_iterator_object_type;
+static PyTypeObject type_iterator_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("typy_iterator_object");
 
 /* This is used to initialize various gdb.TYPE_ constants.  */
 struct pyty_code
index 7337bffc380d2038ef56369162003d87bb985a97..b6a2e7606d48babe3d5b0e10d0744d4be69a0417 100644 (file)
 #ifndef GDB_PYTHON_INTERNAL_H
 #define GDB_PYTHON_INTERNAL_H
 
+/* These WITH_* macros are defined by the CPython API checker that
+   comes with the Python plugin for GCC.  See:
+   https://gcc-python-plugin.readthedocs.org/en/latest/cpychecker.html
+   The checker defines a WITH_ macro for each attribute it
+   exposes.  */
+
+#ifdef WITH_CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF_ATTRIBUTE
+#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG)                \
+  __attribute__ ((cpychecker_type_object_for_typedef (ARG)))
+#else
+#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG)
+#endif
+
 #include <stdio.h>
 
 /* Python 2.4 doesn't include stdint.h soon enough to get {u,}intptr_t
@@ -151,14 +164,21 @@ struct inferior;
 
 extern PyObject *gdb_module;
 extern PyObject *gdb_python_module;
-extern PyTypeObject value_object_type;
-extern PyTypeObject block_object_type;
-extern PyTypeObject symbol_object_type;
-extern PyTypeObject event_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
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("symbol_object");
+extern PyTypeObject event_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
 extern PyTypeObject events_object_type;
-extern PyTypeObject stop_event_object_type;
-extern PyTypeObject breakpoint_object_type;
-extern PyTypeObject frame_object_type;
+extern PyTypeObject stop_event_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object");
+extern PyTypeObject breakpoint_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("breakpoint_object");
+extern PyTypeObject frame_object_type
+    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("frame_object");
 
 typedef struct breakpoint_object
 {