Convert char array to std::string in linux_find_memory_regions_full
This is a quick cleanup that removes the use of fixed-length char arrays and uses std::string instead. gdb/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * linux-tdep.c (linux_find_memory_regions_full): Use std::string instead of char arrays.
This commit is contained in:
parent
4601818e8c
commit
93e447c605
@ -1,3 +1,8 @@
|
|||||||
|
2021-03-24 Luis Machado <luis.machado@linaro.org>
|
||||||
|
|
||||||
|
* linux-tdep.c (linux_find_memory_regions_full): Use std::string
|
||||||
|
instead of char arrays.
|
||||||
|
|
||||||
2021-03-24 Luis Machado <luis.machado@linaro.org>
|
2021-03-24 Luis Machado <luis.machado@linaro.org>
|
||||||
|
|
||||||
* Makefile.in (ALL_64_TARGET_OBS): Add arch/aarch64-mte-linux.o.
|
* Makefile.in (ALL_64_TARGET_OBS): Add arch/aarch64-mte-linux.o.
|
||||||
|
@ -1279,8 +1279,6 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch,
|
|||||||
linux_find_memory_region_ftype *func,
|
linux_find_memory_region_ftype *func,
|
||||||
void *obfd)
|
void *obfd)
|
||||||
{
|
{
|
||||||
char mapsfilename[100];
|
|
||||||
char coredumpfilter_name[100];
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
/* Default dump behavior of coredump_filter (0x33), according to
|
/* Default dump behavior of coredump_filter (0x33), according to
|
||||||
Documentation/filesystems/proc.txt from the Linux kernel
|
Documentation/filesystems/proc.txt from the Linux kernel
|
||||||
@ -1298,10 +1296,12 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch,
|
|||||||
|
|
||||||
if (use_coredump_filter)
|
if (use_coredump_filter)
|
||||||
{
|
{
|
||||||
xsnprintf (coredumpfilter_name, sizeof (coredumpfilter_name),
|
std::string core_dump_filter_name
|
||||||
"/proc/%d/coredump_filter", pid);
|
= string_printf ("/proc/%d/coredump_filter", pid);
|
||||||
|
|
||||||
gdb::unique_xmalloc_ptr<char> coredumpfilterdata
|
gdb::unique_xmalloc_ptr<char> coredumpfilterdata
|
||||||
= target_fileio_read_stralloc (NULL, coredumpfilter_name);
|
= target_fileio_read_stralloc (NULL, core_dump_filter_name.c_str ());
|
||||||
|
|
||||||
if (coredumpfilterdata != NULL)
|
if (coredumpfilterdata != NULL)
|
||||||
{
|
{
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
@ -1311,14 +1311,16 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xsnprintf (mapsfilename, sizeof mapsfilename, "/proc/%d/smaps", pid);
|
std::string maps_filename = string_printf ("/proc/%d/smaps", pid);
|
||||||
|
|
||||||
gdb::unique_xmalloc_ptr<char> data
|
gdb::unique_xmalloc_ptr<char> data
|
||||||
= target_fileio_read_stralloc (NULL, mapsfilename);
|
= target_fileio_read_stralloc (NULL, maps_filename.c_str ());
|
||||||
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
{
|
{
|
||||||
/* Older Linux kernels did not support /proc/PID/smaps. */
|
/* Older Linux kernels did not support /proc/PID/smaps. */
|
||||||
xsnprintf (mapsfilename, sizeof mapsfilename, "/proc/%d/maps", pid);
|
maps_filename = string_printf ("/proc/%d/maps", pid);
|
||||||
data = target_fileio_read_stralloc (NULL, mapsfilename);
|
data = target_fileio_read_stralloc (NULL, maps_filename.c_str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
@ -1378,7 +1380,8 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch,
|
|||||||
|
|
||||||
if (sscanf (line, "%64s", keyword) != 1)
|
if (sscanf (line, "%64s", keyword) != 1)
|
||||||
{
|
{
|
||||||
warning (_("Error parsing {s,}maps file '%s'"), mapsfilename);
|
warning (_("Error parsing {s,}maps file '%s'"),
|
||||||
|
maps_filename.c_str ());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1399,7 +1402,7 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch,
|
|||||||
if (sscanf (line, "%*s%lu", &number) != 1)
|
if (sscanf (line, "%*s%lu", &number) != 1)
|
||||||
{
|
{
|
||||||
warning (_("Error parsing {s,}maps file '%s' number"),
|
warning (_("Error parsing {s,}maps file '%s' number"),
|
||||||
mapsfilename);
|
maps_filename.c_str ());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (number > 0)
|
if (number > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user