From 0f767f942b027df6de60c42ed0e4a1dac7d0fd4b Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Fri, 5 Jun 2020 17:52:10 +0100 Subject: gdb/python: Add gdb.Architecture.registers method This commit adds a new method gdb.Architecture.registers that returns an object of the new type gdb.RegisterDescriptorIterator. This iterator returns objects of the new type gdb.RegisterDescriptor. A RegisterDescriptor is not a way to read the value of a register, this is already covered by Frame.read_register, a RegisterDescriptor is simply a way to discover from Python, which registers are available for a given architecture. I did consider just returning a string, the name of each register, instead of a RegisterDescriptor, however, I'm aware that it we don't want to break the existing Python API in any way, so if I return just a string now, but in the future we want more information about a register then we would have to add a second API to get that information. By going straight to a descriptor object now, it is easy to add additional properties in the future should we wish to. Right now the only property of a register that a user can access is the name of the register. In future we might want to be able to ask the register about is register groups, or its type. gdb/ChangeLog: * Makefile.in (SUBDIR_PYTHON_SRCS): Add py-registers.c * python/py-arch.c (archpy_registers): New function. (arch_object_methods): Add 'registers' method. * python/py-registers.c: New file. * python/python-internal.h (gdbpy_new_register_descriptor_iterator): Declare. (gdbpy_initialize_registers): Declare. * python/python.c (do_start_initialization): Call gdbpy_initialize_registers. * NEWS: Mention additions to the Python API. gdb/testsuite/ChangeLog: * gdb.python/py-arch-reg-names.exp: New file. gdb/doc/ChangeLog: * python.texi (Python API): Add new section the menu. (Frames In Python): Add new @anchor. (Architectures In Python): Document new registers method. (Registers In Python): New section. --- gdb/Makefile.in | 1 + 1 file changed, 1 insertion(+) (limited to 'gdb/Makefile.in') diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 9ae9fe2..9d48445 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -401,6 +401,7 @@ SUBDIR_PYTHON_SRCS = \ python/py-record.c \ python/py-record-btrace.c \ python/py-record-full.c \ + python/py-registers.c \ python/py-signalevent.c \ python/py-stopevent.c \ python/py-symbol.c \ -- cgit v1.1