Re: [PATCH v5 03/15] gdb, gdbserver: support dlmopen()

Kevin Buettner via Gdb-patches
2022-06-30T22:36:27Z

On Mon, 27 Jun 2022 12:55:57 +0000
"Metzger, Markus T" <markus.t.metzger@intel.com> wrote:

> Thanks for your review, Kevin,
[...]
> >I was puzzled for a while by the uses of std:swap() in the above
> >snippets of code. I checked the rest of the GDB sources and found
> >that (at least in GDB) this is not a common idiom. I'd appreciate
> >it if you could add a few lines of explanation for at least one
> >of them.
>
> Do those comments help?

Yes! Thanks for adding them.

Kevin

>
> diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
> index 1f2abcf16ef..b231888b001 100644
> --- a/gdb/solib-svr4.c
> +++ b/gdb/solib-svr4.c
> @@ -1346,6 +1346,10 @@ svr4_current_sos_direct (struct svr4_info *info)
> && (library_list.solib_lists[0] == nullptr))
> library_list.solib_lists.erase (0);
>
> + /* Replace the (empty) solib_lists in INFO with the one generated
> + from the target. We don't want to copy it on assignment and then
> + delete the original afterwards, so let's just swap the
> + internals. */
> std::swap (info->solib_lists, library_list.solib_lists);
> return;
> }
> @@ -1872,7 +1876,11 @@ solist_update_incremental (svr4_info *info, CORE_ADDR debug_base,
> if (!svr4_current_sos_via_xfer_libraries (&library_list, annex))
> return 0;
>
> - /* We expect gdbserver to provide updates for the namespace that
> + /* Get the so list from the target. We replace the list in the
> + target response so we can easily check that the response only
> + covers one namespace.
> +
> + We expect gdbserver to provide updates for the namespace that
> contains LM, which whould be this namespace... */
> so_list *sos = nullptr;
> if (library_list.solib_lists.find (debug_base)