Re: [PATCH 20/24] gdb: make so_list::{so_original_name, so_name} std::strings

Lancelot SIX
2023-10-13T22:28:54Z

Hi Simon,

On Tue, Oct 10, 2023 at 04:40:15PM -0400, Simon Marchi wrote:
> Change these two fields, simplifying memory management and copying.
>
> Change-Id: If2559284c515721e71e1ef56ada8b64667eebe55
> ---
> gdb/break-catch-load.c | 2 +-
> gdb/breakpoint.c | 2 +-
> gdb/bsd-uthread.c | 8 +++----
> gdb/mi/mi-cmd-file.c | 2 +-
> gdb/solib-aix.c | 8 +++----
> gdb/solib-darwin.c | 5 ++---
> gdb/solib-dsbt.c | 5 ++---
> gdb/solib-frv.c | 6 ++----
> gdb/solib-rocm.c | 8 ++-----
> gdb/solib-svr4.c | 25 ++++++++++------------
> gdb/solib-target.c | 18 ++++++----------
> gdb/solib.c | 47 +++++++++++++++++++++++-------------------
> gdb/solist.h | 4 ++--
> 13 files changed, 63 insertions(+), 77 deletions(-)
>
> diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c
> index 822d3df40005..5f63ce4494cb 100644
> --- a/gdb/mi/mi-cmd-file.c
> +++ b/gdb/mi/mi-cmd-file.c
> @@ -167,7 +167,7 @@ mi_cmd_file_list_shared_libraries (const char *command,
> {
> if (so->so_name[0] == '\0')

I think this should become "so->so_name.empty ()".

> continue;
> - if (pattern != NULL && !re_exec (so->so_name))
> + if (pattern != NULL && !re_exec (so->so_name.c_str ()))
> continue;
>
> ui_out_emit_tuple tuple_emitter (uiout, NULL);
> diff --git a/gdb/solib.c b/gdb/solib.c
> index 6b7f0da0498d..1815b0910208 100644
> --- a/gdb/solib.c
> +++ b/gdb/solib.c
> @@ -1088,7 +1093,7 @@ info_sharedlibrary_command (const char *pattern, int from_tty)
> {
> if (so->so_name[0])

Similar here.

> {
> - if (pattern && ! re_exec (so->so_name))
> + if (pattern && ! re_exec (so->so_name.c_str ()))
> continue;
> ++nr_libs;
> }
> @@ -1109,7 +1114,7 @@ info_sharedlibrary_command (const char *pattern, int from_tty)
> {
> if (! so->so_name[0])

And here it should be "!so->empty ()".

> continue;
> - if (pattern && ! re_exec (so->so_name))
> + if (pattern && ! re_exec (so->so_name.c_str ()))
> continue;
>
> ui_out_emit_tuple tuple_emitter (uiout, "lib");

I might have missed other patterns, I'll need to get back to it with
fresher eyes.

Best,
Lancelot.