aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib-target.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2023-10-08 01:16:29 +0000
committerSimon Marchi <simon.marchi@efficios.com>2023-10-19 10:57:51 -0400
commit98107b0b17acd9d2c28829cbe93a75b72677d220 (patch)
treefcbc63a8764ed76342d61e040e92cc2f61a8764e /gdb/solib-target.c
parent200b85632a99e749e14d1c026b7e24c15a5e2776 (diff)
downloadfsf-binutils-gdb-98107b0b17acd9d2c28829cbe93a75b72677d220.zip
fsf-binutils-gdb-98107b0b17acd9d2c28829cbe93a75b72677d220.tar.gz
fsf-binutils-gdb-98107b0b17acd9d2c28829cbe93a75b72677d220.tar.bz2
gdb: make so_list::{so_original_name,so_name} std::strings
Change these two fields, simplifying memory management and copying. Change-Id: If2559284c515721e71e1ef56ada8b64667eebe55 Approved-By: Pedro Alves <pedro@palves.net> Reviewed-By: Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Diffstat (limited to 'gdb/solib-target.c')
-rw-r--r--gdb/solib-target.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index cccdfa8..0881d7e 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -250,16 +250,10 @@ solib_target_current_sos (void)
for (lm_info_target_up &info : library_list)
{
so_list *new_solib = new so_list;
- strncpy (new_solib->so_name, info->name.c_str (),
- SO_NAME_MAX_PATH_SIZE - 1);
- new_solib->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
- strncpy (new_solib->so_original_name, info->name.c_str (),
- SO_NAME_MAX_PATH_SIZE - 1);
- new_solib->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
-
- /* We no longer need this copy of the name. */
- info->name.clear ();
+ /* We don't need a copy of the name in INFO anymore. */
+ new_solib->so_name = std::move (info->name);
+ new_solib->so_original_name = new_solib->so_name;
new_solib->lm_info = std::move (info);
/* Add it to the list. */
@@ -310,7 +304,7 @@ solib_target_relocate_section_addresses (so_list &so, target_section *sec)
if (num_alloc_sections != li->section_bases.size ())
warning (_("\
Could not relocate shared library \"%s\": wrong number of ALLOC sections"),
- so.so_name);
+ so.so_name.c_str ());
else
{
int bases_index = 0;
@@ -353,7 +347,7 @@ Could not relocate shared library \"%s\": wrong number of ALLOC sections"),
if (data == NULL)
warning (_("\
-Could not relocate shared library \"%s\": no segments"), so.so_name);
+Could not relocate shared library \"%s\": no segments"), so.so_name.c_str ());
else
{
ULONGEST orig_delta;
@@ -364,7 +358,7 @@ Could not relocate shared library \"%s\": no segments"), so.so_name);
li->segment_bases.size (),
li->segment_bases.data ()))
warning (_("\
-Could not relocate shared library \"%s\": bad offsets"), so.so_name);
+Could not relocate shared library \"%s\": bad offsets"), so.so_name.c_str ());
/* Find the range of addresses to report for this library in
"info sharedlibrary". Report any consecutive segments