Re: [PATCH 3/5] gdb/python: Add gdb.Architecture.registers method

Tom Tromey
2020-06-18T21:24:47Z

>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Thanks for doing this.

Andrew> This commit adds a new method gdb.Architecture.registers that returns
Andrew> an object of the new type gdb.RegisterDescriptorIterator. This
Andrew> iterator returns objects of the new type gdb.RegisterDescriptor.

Andrew> A RegisterDescriptor is not a way to read the value of a register,
Andrew> this is already covered by Frame.read_register, a RegisterDescriptor
Andrew> is simply a way to discover from Python, which registers are
Andrew> available for a given architecture.

Andrew> I did consider just returning a string, the name of each register,
Andrew> instead of a RegisterDescriptor, however, I'm aware that it we don't
Andrew> want to break the existing Python API in any way, so if I return just
Andrew> a string now, but in the future we want more information about a
Andrew> register then we would have to add a second API to get that
Andrew> information. By going straight to a descriptor object now, it is easy
Andrew> to add additional properties in the future should we wish to.

Andrew> Right now the only property of a register that a user can access is
Andrew> the name of the register.

Andrew> In future we might want to be able to ask the register about is
Andrew> register groups, or its type.

This all seems reasonable.

Andrew> +int
Andrew> +gdbpy_initialize_registers (void)

No need for "void" here in new code.
Same in the .h.

Looks good to me with those nits fixed.

Tom