gdb/debuginfod: Support on-demand debuginfo downloading
At the beginning of a session, gdb may attempt to download debuginfo
for all shared libraries associated with the process or core file
being debugged. This can be a waste of time and storage space when much
of the debuginfo ends up not being used during the session.
To reduce the gdb's startup latency and to download only the debuginfo
that is really needed, this patch adds on-demand, a.k.a lazy, downloading.
When 'set debuginfo enabled lazy' is on, gdb will attempt to download
a .gdb_index for each shared library instead of its full debuginfo.
Each debuginfo download will be deferred until gdb needs to expand symtabs
associated with the debuginfo's index.
Additionally, all separate debug objfiles are placed in objfiles_list
after their parent, instead of before. This ensures that any deferred
debuginfo downloaded during iteration over objfiles_list aren't skipped
by the loop. I also modified objfiles_safe so that it returns a safe
reverse iterator. Reverse iteration prevents iterator invalidation by
ensuring that separate debug objfiles are deleted before their parent objfile.