gdb/python: New method to access list of register groups
Add a new method gdb.Architecture.register_groups which returns a new object of type gdb.RegisterGroupsIterator. This new iterator then returns objects of type gdb.RegisterGroup. Each gdb.RegisterGroup object just wraps a single reggroup pointer, and (currently) has just one read-only property 'name' that is a string, the name of the register group. As with the previous commit (adding gdb.RegisterDescriptor) I made gdb.RegisterGroup an object rather than just a string in case we want to add additional properties in the future. gdb/ChangeLog: * NEWS: Mention additions to Python API. * python/py-arch.c (archpy_register_groups): New function. (arch_object_methods): Add 'register_groups' method. * python/py-registers.c (reggroup_iterator_object): New struct. (reggroup_object): New struct. (gdbpy_new_reggroup): New function. (gdbpy_reggroup_to_string): New function. (gdbpy_reggroup_name): New function. (gdbpy_reggroup_iter): New function. (gdbpy_reggroup_iter_next): New function. (gdbpy_new_reggroup_iterator): New function (gdbpy_initialize_registers): Register new types. (reggroup_iterator_object_type): Define new Python type. (gdbpy_reggroup_getset): New static global. (reggroup_object_type): Define new Python type. * python/python-internal.h gdb/testsuite/ChangeLog: * gdb.python/py-arch-reg-groups.exp: New file. gdb/doc/ChangeLog: * gdb.texi (Registers): Add @anchor for 'info registers <reggroup>' command. * python.texi (Architectures In Python): Document new register_groups method. (Registers In Python): Document two new object types related to register groups.
This commit is contained in:
parent
0f767f942b
commit
64cb3757a9
10 changed files with 371 additions and 0 deletions
|
@ -248,6 +248,20 @@ archpy_registers (PyObject *self, PyObject *args, PyObject *kw)
|
|||
return gdbpy_new_register_descriptor_iterator (gdbarch, group_name);
|
||||
}
|
||||
|
||||
/* Implementation of gdb.Architecture.register_groups (self) -> Iterator.
|
||||
Returns an iterator that will give up all valid register groups in the
|
||||
architecture SELF. */
|
||||
|
||||
static PyObject *
|
||||
archpy_register_groups (PyObject *self, PyObject *args)
|
||||
{
|
||||
struct gdbarch *gdbarch = NULL;
|
||||
|
||||
/* Extract the gdbarch from the self object. */
|
||||
ARCHPY_REQUIRE_VALID (self, gdbarch);
|
||||
return gdbpy_new_reggroup_iterator (gdbarch);
|
||||
}
|
||||
|
||||
/* Initializes the Architecture class in the gdb module. */
|
||||
|
||||
int
|
||||
|
@ -276,6 +290,10 @@ END_PC." },
|
|||
"registers ([ group-name ]) -> Iterator.\n\
|
||||
Return an iterator of register descriptors for the registers in register\n\
|
||||
group GROUP-NAME." },
|
||||
{ "register_groups", archpy_register_groups,
|
||||
METH_NOARGS,
|
||||
"register_groups () -> Iterator.\n\
|
||||
Return an iterator over all of the register groups in this architecture." },
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue