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

Lancelot SIX
2023-10-19T11:09:07Z

Hi Simon,

Some other minor NULL -> nullptr possible conversions below.

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/break-catch-load.c b/gdb/break-catch-load.c
> index 94d8b420d327..999de874d5f6 100644
> --- a/gdb/break-catch-load.c
> +++ b/gdb/break-catch-load.c
> @@ -120,7 +120,7 @@ solib_catchpoint::check_status (struct bpstat *bs)
> for (so_list *iter : current_program_space->added_solibs)
> {
> if (!regex
> - || compiled->exec (iter->so_name, 0, NULL, 0) == 0)
> + || compiled->exec (iter->so_name.c_str (), 0, NULL, 0) == 0)

While at touching this line, s/NULL/nullptr.

> return;
> }
> }
> 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')
> continue;
> - if (pattern != NULL && !re_exec (so->so_name))
> + if (pattern != NULL && !re_exec (so->so_name.c_str ()))

Same.

> 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
> @@ -705,9 +708,10 @@ solib_read_symbols (so_list &so, symfile_add_flags flags)
> section_addr_info sap
> = build_section_addr_info_from_section_table (so.sections);
> gdb_bfd_ref_ptr tmp_bfd = so.abfd;
> - so.objfile = symbol_file_add_from_bfd (tmp_bfd, so.so_name,
> - flags, &sap,
> - OBJF_SHARED, NULL);
> + so.objfile = symbol_file_add_from_bfd (tmp_bfd,
> + so.so_name.c_str (),
> + flags, &sap,
> + OBJF_SHARED, NULL);

Same.

> so.objfile->addr_low = so.addr_low;
> }
>

Best,
Lancelot.