Right now there is no clean way to discover that a block is a global or static block from python. There should be a method or two for this.
Notes for Phil Muldoon which are more general and may not be specific for this Bug: http://sourceware.org/ml/gdb-patches/2011-04/msg00143.html # There is still gdbpy_block_for_pc (unaffected by this patch at all) which # works as described but it may be confusing as it does not behave well with # inlined functions when used as is. I do not see block_for_pc to be used in the .py scripts shipped in GDB but any such use should be reviewed wrt inlined functions correctness. One should always derive block from its frame by get_frame_block. Relying on any PC there may produce incorrect results. Which should be already done fine by frapy_block. frapy_block should never need to return GLOBAL_BLOC or STATIC_BLOCK so there should not be a problem the current code does not allow it. Maybe everything is correct and nothing needs to be changed now, thanks.
(In reply to comment #1) > frapy_block should never need to return GLOBAL_BLOC or STATIC_BLOCK so there > should not be a problem the current code does not allow it. > > Maybe everything is correct and nothing needs to be changed now, thanks. The return values are correct; but the problem in this bug is that you can look upwards using Block.superblock -- but then you have no good way to know when to stop searching upward.
CVSROOT: /cvs/src Module name: src Changes by: pmuldoon@sourceware.org 2011-10-20 12:31:30 Modified files: gdb : ChangeLog NEWS blockframe.c frame.h valops.c value.h gdb/doc : ChangeLog gdb.texinfo gdb/python : py-block.c py-frame.c py-symbol.c py-type.c python-internal.h gdb/testsuite : ChangeLog gdb/testsuite/gdb.python: py-block.exp Log message: 2011-10-20 Phil Muldoon <pmuldoon@redhat.com> PR python/12656 * python/py-frame.c (frapy_read_var): Use const struct *block. * python/py-type.c (typy_lookup_typename): Likewise. (typy_lookup_type): Likewise. (typy_legacy_template_argument): Likewise. (typy_template_argument): Likewise. (gdbpy_lookup_type): Likewise. * python/py-symbol.c (gdbpy_lookup_symbol): Likewise. * python/py-block.c (blpy_block_object): Likewise. (blpy_iter): Likewise. (blpy_get_start): Likewise. (blpy_get_end): Likewise. (blpy_get_function): Likewise. (blpy_get_superblock): Likewise. (set_block): Likewise. (block_to_block_object): Likewise. (block_object_to_block): Likewise. (blpy_is_valid): Likewise. (blpy_get_global_block): New function. (blpy_get_static_block): New function. (blpy_is_global): New function. (blpy_is_static): New function. * blockframe.c (block_innermost_frame): Likewise. * valops.c (value_of_variable): Likewise. * frame.h: Update prototypes. * python/python-internal.h: Likewise. * value.h: Likewise. 2011-10-20 Phil Muldoon <pmuldoon@redhat.com> PR python/12656 * gdb.texinfo (Blocks In Python): Document is_static, is_global, global_block, static_block function. 2011-10-20 Phil Muldoon <pmuldoon@redhat.com> PR python/12656 * gdb.python/py-block.exp: Add is_global, is_static, static_block, global_block tests. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13444&r2=1.13445 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/NEWS.diff?cvsroot=src&r1=1.459&r2=1.460 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/blockframe.c.diff?cvsroot=src&r1=1.133&r2=1.134 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/frame.h.diff?cvsroot=src&r1=1.197&r2=1.198 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/valops.c.diff?cvsroot=src&r1=1.288&r2=1.289 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/value.h.diff?cvsroot=src&r1=1.188&r2=1.189 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/doc/ChangeLog.diff?cvsroot=src&r1=1.1230&r2=1.1231 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/doc/gdb.texinfo.diff?cvsroot=src&r1=1.879&r2=1.880 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-block.c.diff?cvsroot=src&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-frame.c.diff?cvsroot=src&r1=1.19&r2=1.20 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-symbol.c.diff?cvsroot=src&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/py-type.c.diff?cvsroot=src&r1=1.25&r2=1.26 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/python/python-internal.h.diff?cvsroot=src&r1=1.50&r2=1.51 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2904&r2=1.2905 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.python/py-block.exp.diff?cvsroot=src&r1=1.7&r2=1.8
Fixed as committed.