Revamp gdb.printing to support upcoming callback-based matching.
Revamp gdb.printing to support upcoming callback-based matching.

- Added logic to handle the new type callbacks in
  register_pretty_printer. We'll need to add a class analogous to
  RegexpCollectionPrettyPrinter to offer a single way to register
  type-callback-based printers that works seamlessly under both
  debuggers.

- Changed how we wrap prettyprinters into a type summary function and a
  child provider class. We were using a fixed dispatcher function and a
  fixed child provider class because we need to register it with lldb by
  name, and we can count on "gdb.printing.type_summary_function" being
  there.

  The new solution is based on adding callbacks dynamically as
  attributes of the `gdb.printing` module object. This way we can
  receive some arbitrary function object, generate a wrapper for it on
  the fly, add the wrapper as the "XXXX" attribute to gdb.printing, and
  pass "gdb.printing.XXXX" as the name for lldb.  And so our callbacks
  get a fixed (during that session) name, even if the original callback
  was something like a lambda.

  As a side benefit, because each callback gets its own wrapper
  function, we can preserve their name so that `type summary list` can
  list "gdb.printing.gala_summary_MyGdbPrinterClass" instead of just
  "gdb.printing.type_summary_function" (and the same goes for child
  providers and type callbacks)

- Added type annotations. Will add type annotations to gdb/__init__.py
  in a later patch.

- Added a ton of comments and docstrings for all methods. This module
  had grown big enough and some tidying up was overdue.

- Added a small optimization to avoid having
  RegexpCollectionPrettyPrinter do its own regex matching: when lldb
  calls into it we already know its a regex match so we can hook the
  right printer to the right lldb regex directly.

sivachandra/gala,sivachandra/gala