diff options
author | Tom Tromey <tom@tromey.com> | 2013-12-26 19:50:05 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-09-16 06:52:37 -0600 |
commit | 8743a9cdd20055e02a20c24c37b5312e3e626691 (patch) | |
tree | 982605dd428a62aff01ce080fbd68221e3f425e1 /gdb/doc | |
parent | 752312ba4e53fea8e77ae240a35a7b508c6ca619 (diff) | |
download | binutils-8743a9cdd20055e02a20c24c37b5312e3e626691.zip binutils-8743a9cdd20055e02a20c24c37b5312e3e626691.tar.gz binutils-8743a9cdd20055e02a20c24c37b5312e3e626691.tar.bz2 |
Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace. This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.
This version has been rebased on the related changes that Simon
recently put in.
Built and regtested on x86-64 Fedora 28.
gdb/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python/lib/gdb/__init__.py (current_progspace, objfiles)
(solib_name, block_for_pc, find_pc_line): New functions.
(execute_unwinders): Update.
* python/py-block.c (gdbpy_block_for_pc): Remove.
* python/py-inferior.c (infpy_get_progspace): New function.
(inferior_object_getset) <progspace>: Add.
* python/py-progspace.c (pspy_objfiles): Rewrite.
(pspy_solib_name, pspy_block_for_pc)
(pspy_find_pc_line, pspy_is_valid): New functions.
(progspace_object_methods): Add entries for solib_name,
block_for_pc, find_pc_line, is_valid.
* python/python-internal.h (gdbpy_block_for_pc)
(build_objfiles_list): Don't declare.
* python/python.c: Don't include solib.h.
(gdbpy_solib_name, gdbpy_find_pc_line)
(gdbpy_get_current_progspace, build_objfiles_list)
(gdbpy_objfiles): Remove.
(GdbMethods) <current_progspace, objfiles, block_for_pc,
solib_name, find_pc_line>: Remove entries.
gdb/doc/ChangeLog
2018-09-16 Tom Tromey <tom@tromey.com>
* python.texi (Basic Python): Update docs for find_pc_line,
solib_name.
(Progspaces In Python): Update docs for current_progspace.
Document block_for_pc, find_pc_line, is_valid, nsolib_name.
Move method documentation before example.
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/doc/python.texi | 59 |
2 files changed, 56 insertions, 11 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 1a5c70b..6d75664 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,11 @@ +2018-09-16 Tom Tromey <tom@tromey.com> + + * python.texi (Basic Python): Update docs for find_pc_line, + solib_name. + (Progspaces In Python): Update docs for current_progspace. + Document block_for_pc, find_pc_line, is_valid, nsolib_name. + Move method documentation before example. + 2018-09-13 Simon Marchi <simon.marchi@ericsson.com> * python.texi (Objfiles In Python): Update gdb.objfiles() doc. diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index aca6ec8..e98178a 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -328,7 +328,9 @@ Return the @code{gdb.Symtab_and_line} object corresponding to the @var{pc} value. @xref{Symbol Tables In Python}. If an invalid value of @var{pc} is passed as an argument, then the @code{symtab} and @code{line} attributes of the returned @code{gdb.Symtab_and_line} object -will be @code{None} and 0 respectively. +will be @code{None} and 0 respectively. This is identical to +@code{gdb.current_progspace().find_pc_line(pc)} and is included for +historical compatibility. @end defun @findex gdb.post_event @@ -448,7 +450,9 @@ never returned. @findex gdb.solib_name @defun gdb.solib_name (address) Return the name of the shared library holding the given @var{address} -as a string, or @code{None}. +as a string, or @code{None}. This is identical to +@code{gdb.current_progspace().solib_name(address)} and is included for +historical compatibility. @end defun @findex gdb.decode_line @@ -4035,6 +4039,45 @@ The @code{frame_filters} attribute is a dictionary of frame filter objects. @xref{Frame Filter API}, for more information. @end defvar +A program space has the following methods: + +@findex Progspace.block_for_pc +@defun Progspace.block_for_pc (pc) +Return the innermost @code{gdb.Block} containing the given @var{pc} +value. If the block cannot be found for the @var{pc} value specified, +the function will return @code{None}. +@end defun + +@findex Progspace.find_pc_line +@defun Progspace.find_pc_line (pc) +Return the @code{gdb.Symtab_and_line} object corresponding to the +@var{pc} value. @xref{Symbol Tables In Python}. If an invalid value +of @var{pc} is passed as an argument, then the @code{symtab} and +@code{line} attributes of the returned @code{gdb.Symtab_and_line} +object will be @code{None} and 0 respectively. +@end defun + +@findex Progspace.is_valid +@defun Progspace.is_valid () +Returns @code{True} if the @code{gdb.Progspace} object is valid, +@code{False} if not. A @code{gdb.Progspace} object can become invalid +if the program space file it refers to is not referenced by any +inferior. All other @code{gdb.Progspace} methods will throw an +exception if it is invalid at the time the method is called. +@end defun + +@findex Progspace.objfiles +@defun Progspace.objfiles () +Return a sequence of all the objfiles referenced by this program +space. @xref{Objfiles In Python}. +@end defun + +@findex Progspace.solib_name +@defun Progspace.solib_name (address) +Return the name of the shared library holding the given @var{address} +as a string, or @code{None}. +@end defun + One may add arbitrary attributes to @code{gdb.Progspace} objects in the usual Python way. This is useful if, for example, one needs to do some extra record keeping @@ -4079,14 +4122,6 @@ Hello. [Inferior 1 (process 4242) exited normally] @end smallexample -A @code{gdb.Progspace} object has the following methods: - -@findex Progspace.objfiles -@defun Progspace.objfiles () -Return a sequence of all the objfiles referenced by this program -space. @xref{Objfiles In Python}. -@end defun - @node Objfiles In Python @subsubsection Objfiles In Python @@ -4515,7 +4550,9 @@ module: @defun gdb.block_for_pc (pc) Return the innermost @code{gdb.Block} containing the given @var{pc} value. If the block cannot be found for the @var{pc} value specified, -the function will return @code{None}. +the function will return @code{None}. This is identical to +@code{gdb.current_progspace().block_for_pc(pc)} and is included for +historical compatibility. @end defun A @code{gdb.Block} object has the following methods: |