This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC - Python scripting] New methods Symtab.global_block and Symtab.static_block (docs included)
Thank Phil, for taking a look. Comments below.
Phil> We already have gdb.Block.is_static and gdb.Block.is_global. ?I don't
Phil> have an objection to this patch per-se, but wouldn't the user acquire
Phil> the global/static blocks similarly by iterating the blocks in the
Phil> Python code and doing the above tests?
Is there a way to iterate over all blocks of a Symtab right after
loading? If yes, my mistake for having missed it, and this patch is
not necessary. The idea behind most of the patches I am sending is to
have an exploratory path Objfile => Symtab => Block => Symbol. This
part addresses Symtab => Block part but not completely; good enough
for my immediate needs though.
Phil> I don't think GNU Style ChangeLogs allow for a summary line. ?I don't
Phil> have an issue with it, but, check with maintainers. ?Just a nit.
There many examples in ChangeLog with a summary line. There are of
course many others without :-)
>> +static PyObject *
>> +stpy_global_block (PyObject *self, PyObject *args)
>> +{
>> + ?struct symtab *symtab = NULL;
>> > + ?struct block *block = NULL;
>> +
>> + ?STPY_REQUIRE_VALID (self, symtab);
>> +
>> + ?block = symtab->blockvector->block[GLOBAL_BLOCK];
>> + ?return block_to_block_object (block, symtab->objfile);
Phil> I don't think so, but can block ever be NULL here? ?Looking at the
Phil> code, I'm not even sure if it would matter as set_block just stores a
Phil> reference to the passed block. ?However, blpy_get_superblock has a
Phil> NULL block check, so it might be worthwhile checking it out.
As I understand, blpy_get_superblock has a check, as the top most
block will not have a superblock. In which case, returning None is
probably more appropriate (as it is a logically valid situation) than
returning a NULL. However, in the case of this patch, is there a
chance that a symtab->blockvector->nblocks == 0? Similarly, is there
a chance blockvector->nblocks > 0 but blockvector->block[GLOBAL_BLOCK]
(or blockvector->block[STATIC_BLOCK]) is NULL for a logical valid
situation?
Thanks,
Siva Chandra