]> Git Repo - binutils.git/blobdiff - gdb/python/py-block.c
gdb/gdbsupport: make xstrprintf and xstrvprintf return a unique_ptr
[binutils.git] / gdb / python / py-block.c
index 26d59e102a37860ebc5a2f3c836b76aea5e22cc5..fe0efd62d46a69683d6d5428ed8e60a0c25f383d 100644 (file)
@@ -1,6 +1,6 @@
 /* Python interface to blocks.
 
-   Copyright (C) 2008-2020 Free Software Foundation, Inc.
+   Copyright (C) 2008-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -24,7 +24,7 @@
 #include "python-internal.h"
 #include "objfiles.h"
 
-typedef struct blpy_block_object {
+struct block_object {
   PyObject_HEAD
   /* The GDB block structure that represents a frame's code block.  */
   const struct block *block;
@@ -34,11 +34,11 @@ typedef struct blpy_block_object {
   struct objfile *objfile;
   /* Keep track of all blocks with a doubly-linked list.  Needed for
      block invalidation if the source object file has been freed.  */
-  struct blpy_block_object *prev;
-  struct blpy_block_object *next;
-} block_object;
+  block_object *prev;
+  block_object *next;
+};
 
-typedef struct {
+struct block_syms_iterator_object {
   PyObject_HEAD
   /* The block.  */
   const struct block *block;
@@ -49,8 +49,8 @@ typedef struct {
   /* Pointer back to the original source block object.  Needed to
      check if the block is still valid, and has not been invalidated
      when an object file has been freed.  */
-  struct blpy_block_object *source;
-} block_syms_iterator_object;
+  block_object *source;
+};
 
 /* Require a valid block.  All access to block_object->block should be
    gated by this call.  */
@@ -293,7 +293,7 @@ set_block (block_object *obj, const struct block *block,
   if (objfile)
     {
       obj->objfile = objfile;
-      obj->next = ((struct blpy_block_object *)
+      obj->next = ((block_object *)
                   objfile_data (objfile, blpy_objfile_data_key));
       if (obj->next)
        obj->next->prev = obj;
@@ -427,6 +427,17 @@ del_objfile_blocks (struct objfile *objfile, void *datum)
     }
 }
 
+void _initialize_py_block ();
+void
+_initialize_py_block ()
+{
+  /* Register an objfile "free" callback so we can properly
+     invalidate blocks when an object file is about to be
+     deleted.  */
+  blpy_objfile_data_key
+    = register_objfile_data_with_cleanup (NULL, del_objfile_blocks);
+}
+
 int
 gdbpy_initialize_blocks (void)
 {
@@ -438,12 +449,6 @@ gdbpy_initialize_blocks (void)
   if (PyType_Ready (&block_syms_iterator_object_type) < 0)
     return -1;
 
-  /* Register an objfile "free" callback so we can properly
-     invalidate blocks when an object file is about to be
-     deleted.  */
-  blpy_objfile_data_key
-    = register_objfile_data_with_cleanup (NULL, del_objfile_blocks);
-
   if (gdb_pymodule_addobject (gdb_module, "Block",
                              (PyObject *) &block_object_type) < 0)
     return -1;
@@ -505,7 +510,7 @@ PyTypeObject block_object_type = {
   0,                             /*tp_getattro*/
   0,                             /*tp_setattro*/
   0,                             /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER,  /*tp_flags*/
+  Py_TPFLAGS_DEFAULT,            /*tp_flags*/
   "GDB block object",            /* tp_doc */
   0,                             /* tp_traverse */
   0,                             /* tp_clear */
@@ -545,7 +550,7 @@ PyTypeObject block_syms_iterator_object_type = {
   0,                             /*tp_getattro*/
   0,                             /*tp_setattro*/
   0,                             /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER,  /*tp_flags*/
+  Py_TPFLAGS_DEFAULT,            /*tp_flags*/
   "GDB block syms iterator object",          /*tp_doc */
   0,                             /*tp_traverse */
   0,                             /*tp_clear */
This page took 0.036946 seconds and 4 git commands to generate.