]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: pass std::string from linux_find_memory_regions_full
authorAndrew Burgess <aburgess@redhat.com>
Wed, 7 May 2025 10:00:13 +0000 (11:00 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Mon, 12 May 2025 15:27:23 +0000 (16:27 +0100)
Update linux_find_memory_region_ftype to take 'const std::string &'
instead of 'const char *', update the two functions which are passed
as callbacks to linux_find_memory_regions_full.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/linux-tdep.c

index c4d3d4d8009b9cef899b4454d6b10a7b948872c5..0b08e1290c2bfaf93bb0354786da84affdcc645b 100644 (file)
@@ -1327,7 +1327,7 @@ typedef int linux_find_memory_region_ftype (ULONGEST vaddr, ULONGEST size,
                                            int read, int write,
                                            int exec, int modified,
                                            bool memory_tagged,
-                                           const char *filename,
+                                           const std::string &filename,
                                            void *data);
 
 typedef bool linux_dump_mapping_p_ftype (filter_flags filterflags,
@@ -1601,7 +1601,7 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch,
                1, /* MODIFIED is true because we want to dump
                      the mapping.  */
                map.vmflags.memory_tagging != 0,
-               map.filename.c_str (), obfd);
+               map.filename, obfd);
        }
     }
 
@@ -1630,7 +1630,7 @@ linux_find_memory_regions_thunk (ULONGEST vaddr, ULONGEST size,
                                 ULONGEST offset,
                                 int read, int write, int exec, int modified,
                                 bool memory_tagged,
-                                const char *filename, void *arg)
+                                const std::string &filename, void *arg)
 {
   struct linux_find_memory_regions_data *data
     = (struct linux_find_memory_regions_data *) arg;
@@ -1687,13 +1687,13 @@ linux_make_mappings_callback (ULONGEST vaddr, ULONGEST size,
                              ULONGEST offset,
                              int read, int write, int exec, int modified,
                              bool memory_tagged,
-                             const char *filename, void *data)
+                             const std::string &filename, void *data)
 {
   struct linux_make_mappings_data *map_data
     = (struct linux_make_mappings_data *) data;
   gdb_byte buf[sizeof (ULONGEST)];
 
-  gdb_assert (filename != nullptr && *filename != '\0');
+  gdb_assert (filename.length () > 0);
 
   ++map_data->file_count;
 
@@ -1704,7 +1704,7 @@ linux_make_mappings_callback (ULONGEST vaddr, ULONGEST size,
   pack_long (buf, map_data->long_type, offset);
   obstack_grow (map_data->data_obstack, buf, map_data->long_type->length ());
 
-  obstack_grow_str0 (map_data->filename_obstack, filename);
+  obstack_grow_str0 (map_data->filename_obstack, filename.c_str ());
 
   return 0;
 }