Go to file
Andrew Burgess 43d5901ded gdb/python: make more use of RegisterDescriptors
This commit unifies all of the Python register lookup code (used by
Frame.read_register, PendingFrame.read_register, and
gdb.UnwindInfo.add_saved_register), and adds support for using a
gdb.RegisterDescriptor for register lookup.

Currently the register unwind code (PendingFrame and UnwindInfo) allow
registers to be looked up either by name, or by GDB's internal
number.  I suspect the number was added for performance reasons, when
unwinding we don't want to repeatedly map from name to number for
every unwind.  However, this kind-of sucks, it means Python scripts
could include GDB's internal register numbers, and if we ever change
this numbering in the future users scripts will break in unexpected
ways.

Meanwhile, the Frame.read_register method only supports accessing
registers using a string, the register name.

This commit unifies all of the register to register-number lookup code
in our Python bindings, and adds a third choice into the mix, the use
of gdb.RegisterDescriptor.

The register descriptors can be looked up by name, but once looked up,
they contain GDB's register number, and so provide all of the
performance benefits of using a register number directly.  However, as
they are looked up by name we are no longer tightly binding the Python
API to GDB's internal numbering scheme.

As we may already have scripts in the wild that are using the register
numbers directly I have kept support for this in the API, but I have
listed this method last in the manual, and I have tried to stress that
this is NOT a good method to use and that users should use either a
string or register descriptor approach.

After this commit all existing Python code should function as before,
but users now have new options for how to identify registers.

gdb/ChangeLog:

	* python/py-frame.c: Remove 'user-regs.h' include.
	(frapy_read_register): Rewrite to make use of
	gdbpy_parse_register_id.
	* python/py-registers.c (gdbpy_parse_register_id): New function,
	moved here from python/py-unwind.c.  Updated the return type, and
	also accepts register descriptor objects.
	* python/py-unwind.c: Remove 'user-regs.h' include.
	(pyuw_parse_register_id): Moved to python/py-registers.c.
	(unwind_infopy_add_saved_register): Update to use
	gdbpy_parse_register_id.
	(pending_framepy_read_register): Likewise.
	* python/python-internal.h (gdbpy_parse_register_id): Declare.

gdb/testsuite/ChangeLog:

	* gdb.python/py-unwind.py: Update to make use of a register
	descriptor.

gdb/doc/ChangeLog:

	* python.texi (Unwinding Frames in Python): Update descriptions
	for PendingFrame.read_register and
	gdb.UnwindInfo.add_saved_register.
	(Frames In Python): Update description of Frame.read_register.
2020-07-28 10:27:54 +01:00
bfd PR25022 testcase segfault for generic ELF linker targets 2020-07-28 16:56:14 +09:30
binutils Prevent strange "section mentioned in a -j option but not found" 2020-07-27 22:31:37 +09:30
config config/debuginfod.m4: Use PKG_CHECK_MODULES 2020-07-24 15:16:20 -04:00
contrib contrib: Update dg-extract-results.* from gcc 2020-05-15 11:41:22 +01:00
cpu Add markers for binutils 2.35 branch 2020-07-04 10:16:22 +01:00
elfcpp Add markers for binutils 2.35 branch 2020-07-04 10:16:22 +01:00
etc
gas doc: Replace preceeded with preceded 2020-07-27 05:52:14 -07:00
gdb gdb/python: make more use of RegisterDescriptors 2020-07-28 10:27:54 +01:00
gdbserver Don't unnecessarily redefine 'socklen_t' type in MinGW builds. 2020-07-26 19:35:48 +03:00
gdbsupport gdb/riscv: delete target descriptions when gdb exits 2020-07-17 21:15:32 +01:00
gnulib
gold [GOLD] Power10 stub selection 2020-07-27 22:31:37 +09:30
gprof Update Turkish translation in the gprof sub-directory 2020-07-09 14:25:11 +01:00
include libctf, link: tie in the deduplicating linker 2020-07-22 18:02:19 +01:00
intl
ld More just-syms changes 2020-07-28 13:09:20 +09:30
libctf libctf: compilation failure on MinGW due to missing errno values 2020-07-26 16:11:36 -07:00
libdecnumber
libiberty Sync config, include and libiberty with GCC 2020-06-24 16:52:48 -07:00
opcodes Updated German translation for the opcodes sub-directory 2020-07-24 10:14:22 +01:00
readline Update readline/README to mention patchlevel 2020-06-30 15:17:07 -06:00
sim sim/igen: Fix linker error with -fno-common 2020-07-03 21:03:47 +02:00
texinfo
zlib
.cvsignore
.gitattributes
.gitignore
ar-lib
ChangeLog config/debuginfod.m4: Use PKG_CHECK_MODULES 2020-07-24 15:16:20 -04:00
compile
config-ml.in
config.guess
config.rpath
config.sub
configure config/debuginfod.m4: Use PKG_CHECK_MODULES 2020-07-24 15:16:20 -04:00
configure.ac config/debuginfod.m4: Use PKG_CHECK_MODULES 2020-07-24 15:16:20 -04:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
depcomp
djunpack.bat
install-sh
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def Change gdbserver to use existing gdbsupport 2020-03-12 13:32:16 -06:00
Makefile.in Change gdbserver to use existing gdbsupport 2020-03-12 13:32:16 -06:00
Makefile.tpl
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
README-maintainer-mode
setup.com
src-release.sh
symlink-tree
test-driver
ylwrap

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.