| OLD | NEW |
| 1 /* Python interface to blocks. | 1 /* Python interface to blocks. |
| 2 | 2 |
| 3 Copyright (C) 2008-2012 Free Software Foundation, Inc. | 3 Copyright (C) 2008-2012 Free Software Foundation, Inc. |
| 4 | 4 |
| 5 This file is part of GDB. | 5 This file is part of GDB. |
| 6 | 6 |
| 7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
| 8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
| 9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
| 10 (at your option) any later version. | 10 (at your option) any later version. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 store a pointer to the object file for later use. */ | 34 store a pointer to the object file for later use. */ |
| 35 struct objfile *objfile; | 35 struct objfile *objfile; |
| 36 /* Keep track of all blocks with a doubly-linked list. Needed for | 36 /* Keep track of all blocks with a doubly-linked list. Needed for |
| 37 block invalidation if the source object file has been freed. */ | 37 block invalidation if the source object file has been freed. */ |
| 38 struct blpy_block_object *prev; | 38 struct blpy_block_object *prev; |
| 39 struct blpy_block_object *next; | 39 struct blpy_block_object *next; |
| 40 } block_object; | 40 } block_object; |
| 41 | 41 |
| 42 typedef struct { | 42 typedef struct { |
| 43 PyObject_HEAD | 43 PyObject_HEAD |
| 44 /* The block dictionary of symbols. */ | 44 /* The block. */ |
| 45 struct dictionary *dict; | 45 const struct block *block; |
| 46 /* The iterator for that dictionary. */ | 46 /* The iterator for that block. */ |
| 47 struct dict_iterator iter; | 47 struct block_iterator iter; |
| 48 /* Has the iterator been initialized flag. */ | 48 /* Has the iterator been initialized flag. */ |
| 49 int initialized_p; | 49 int initialized_p; |
| 50 /* Pointer back to the original source block object. Needed to | 50 /* Pointer back to the original source block object. Needed to |
| 51 check if the block is still valid, and has not been invalidated | 51 check if the block is still valid, and has not been invalidated |
| 52 when an object file has been freed. */ | 52 when an object file has been freed. */ |
| 53 struct blpy_block_object *source; | 53 struct blpy_block_object *source; |
| 54 } block_syms_iterator_object; | 54 } block_syms_iterator_object; |
| 55 | 55 |
| 56 /* Require a valid block. All access to block_object->block should be | 56 /* Require a valid block. All access to block_object->block should be |
| 57 gated by this call. */ | 57 gated by this call. */ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 87 block_syms_iterator_object *block_iter_obj; | 87 block_syms_iterator_object *block_iter_obj; |
| 88 const struct block *block = NULL; | 88 const struct block *block = NULL; |
| 89 | 89 |
| 90 BLPY_REQUIRE_VALID (self, block); | 90 BLPY_REQUIRE_VALID (self, block); |
| 91 | 91 |
| 92 block_iter_obj = PyObject_New (block_syms_iterator_object, | 92 block_iter_obj = PyObject_New (block_syms_iterator_object, |
| 93 &block_syms_iterator_object_type); | 93 &block_syms_iterator_object_type); |
| 94 if (block_iter_obj == NULL) | 94 if (block_iter_obj == NULL) |
| 95 return NULL; | 95 return NULL; |
| 96 | 96 |
| 97 block_iter_obj->dict = BLOCK_DICT (block); | 97 block_iter_obj->block = block; |
| 98 block_iter_obj->initialized_p = 0; | 98 block_iter_obj->initialized_p = 0; |
| 99 Py_INCREF (self); | 99 Py_INCREF (self); |
| 100 block_iter_obj->source = (block_object *) self; | 100 block_iter_obj->source = (block_object *) self; |
| 101 | 101 |
| 102 return (PyObject *) block_iter_obj; | 102 return (PyObject *) block_iter_obj; |
| 103 } | 103 } |
| 104 | 104 |
| 105 static PyObject * | 105 static PyObject * |
| 106 blpy_get_start (PyObject *self, void *closure) | 106 blpy_get_start (PyObject *self, void *closure) |
| 107 { | 107 { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 static PyObject * | 304 static PyObject * |
| 305 blpy_block_syms_iternext (PyObject *self) | 305 blpy_block_syms_iternext (PyObject *self) |
| 306 { | 306 { |
| 307 block_syms_iterator_object *iter_obj = (block_syms_iterator_object *) self; | 307 block_syms_iterator_object *iter_obj = (block_syms_iterator_object *) self; |
| 308 struct symbol *sym; | 308 struct symbol *sym; |
| 309 | 309 |
| 310 BLPY_ITER_REQUIRE_VALID (iter_obj->source); | 310 BLPY_ITER_REQUIRE_VALID (iter_obj->source); |
| 311 | 311 |
| 312 if (!iter_obj->initialized_p) | 312 if (!iter_obj->initialized_p) |
| 313 { | 313 { |
| 314 sym = dict_iterator_first (iter_obj->dict, &(iter_obj->iter)); | 314 sym = block_iterator_first (iter_obj->block, &(iter_obj->iter)); |
| 315 iter_obj->initialized_p = 1; | 315 iter_obj->initialized_p = 1; |
| 316 } | 316 } |
| 317 else | 317 else |
| 318 sym = dict_iterator_next (&(iter_obj->iter)); | 318 sym = block_iterator_next (&(iter_obj->iter)); |
| 319 | 319 |
| 320 if (sym == NULL) | 320 if (sym == NULL) |
| 321 { | 321 { |
| 322 PyErr_SetString (PyExc_StopIteration, _("Symbol is null.")); | 322 PyErr_SetString (PyExc_StopIteration, _("Symbol is null.")); |
| 323 return NULL; | 323 return NULL; |
| 324 } | 324 } |
| 325 | 325 |
| 326 return symbol_to_symbol_object (sym); | 326 return symbol_to_symbol_object (sym); |
| 327 } | 327 } |
| 328 | 328 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/ | 540 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/ |
| 541 "GDB block syms iterator object", /*tp_doc */ | 541 "GDB block syms iterator object", /*tp_doc */ |
| 542 0, /*tp_traverse */ | 542 0, /*tp_traverse */ |
| 543 0, /*tp_clear */ | 543 0, /*tp_clear */ |
| 544 0, /*tp_richcompare */ | 544 0, /*tp_richcompare */ |
| 545 0, /*tp_weaklistoffset */ | 545 0, /*tp_weaklistoffset */ |
| 546 blpy_block_syms_iter, /*tp_iter */ | 546 blpy_block_syms_iter, /*tp_iter */ |
| 547 blpy_block_syms_iternext, /*tp_iternext */ | 547 blpy_block_syms_iternext, /*tp_iternext */ |
| 548 block_iterator_object_methods /*tp_methods */ | 548 block_iterator_object_methods /*tp_methods */ |
| 549 }; | 549 }; |
| OLD | NEW |