Re: [RFC 5/9] gdb/python: introduce gdbpy_registry

Tom Tromey
2025-02-20T19:29:24Z

>>>>> "Jan" == Jan Vrany <jan.vrany@labware.com> writes:

Jan> +#include <unordered_set>
Jan> +#include <unordered_map>

Simon recently imported a hash table so we use gdb::unordered_map and
gdb::unordered_set now. You can probably just remove the includes and
change the names and things will keep working.

Jan> + The actuall tracking of "owned" Python objects is handled externally

Small typo, s/actuall/actual/

Jan> + /* Lookup pre-existing Python object for given VAL. Return such object
Jan> + if found, otherwise return NULL. This method always returns new
Jan> + reference. */
Jan> + template <typename O>
Jan> + obj_type *lookup (O *owner, val_type *val) const
Jan> + {

Returning a new reference suggests that perhaps the return type should
be gdbpy_ref<> (or gdbpy_ref<obj_type>).

Jan> + Storage *get_storage(struct objfile* objf) const
Jan> + {
Jan> + return get_storage(objf, m_key_for_objf);

Spaces before "(". There's a few of these around.

Jan> + obj_type *lookup (val_type *val) const
Jan> + {
Jan> + gdb_assert_not_reached ("Should not be used.");
Jan> + }

I wonder if these methods can just be deleted?
Like if the registry's 'lookup' template isn't instantiated, perhaps
this function won't ever be called, and so no error generated?

Same question for the assert in the 'remove' method.

Tom