Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb questions: fallback on maps still relevant today ?
@ 2026-07-01 12:17 Matthieu Longo
  2026-07-01 12:33 ` Luis
  0 siblings, 1 reply; 4+ messages in thread
From: Matthieu Longo @ 2026-07-01 12:17 UTC (permalink / raw)
  To: gdb-patches
  Cc: Luis Machado, Thiago Jung Bauermann, Andrew Burgess, Matthieu Longo

I am wondering whether the fallback on maps when reading smaps is still
relevant nowadays. /proc/$PID/smaps has been around since 2005. I doubt
that anyone using an older Linux kernel version out there would use the
latest version of GDB.
I propose to remove this fallback logic in linux_find_memory_regions_full.

Additionnally, reading from smaps file is tested against NULL. Why ?
Is there such a valid case where the result of target_fileio_read_stralloc()
could be null, and at the same time, GDB is attached to a process, local
or remote via gdbserver, or while reading a coredump ?
In my understanding, all those cases ensures that the smaps file is always
present and so, I propose to replace this check with a gdb_assert instead.

Why do I care about the above ?
I would like to wrap the reading and parsing code in a class to avoid
the duplication of all the boiler plates in different places.
Please let me know your thoughts ?
---
 gdb/linux-tdep.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 6af01fc0e26..2903e853890 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -1667,6 +1667,7 @@ linux_process_address_in_memtag_page (CORE_ADDR address)
   gdb::unique_xmalloc_ptr<char> data
     = target_fileio_read_stralloc (NULL, smaps_file.c_str ());
 
+  // Why would the data be suddenly unavailable ? Should this be an assert instead ?
   if (data == nullptr)
     return false;
 
@@ -1759,10 +1760,15 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch,
 
   if (data == NULL)
     {
-      /* Older Linux kernels did not support /proc/PID/smaps.  */
+      /* Older Linux kernels did not support /proc/PID/smaps.
+	 /proc/<pid>/smaps was introduced in Linux 2.6.14, released on 27
+	 October 2005 (see proc_pid_smaps(5) — Linux manual page).
+	 Should we really care about this very very old version ?
+	 Does this fallback really make sense nowadays ?  */
       maps_filename = string_printf ("/proc/%d/maps", pid);
       data = target_fileio_read_stralloc (NULL, maps_filename.c_str ());
 
+      // Should this check be an assert instead ?
       if (data == nullptr)
 	return false;
     }
@@ -3183,6 +3189,7 @@ linux_address_in_shadow_stack_mem_range
   gdb::unique_xmalloc_ptr<char> data
     = target_fileio_read_stralloc (nullptr, smaps_file.c_str ());
 
+  // Should this check be an assert instead ?
   if (data == nullptr)
     return false;
 
-- 
2.55.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-21 16:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-01 12:17 [PATCH] gdb questions: fallback on maps still relevant today ? Matthieu Longo
2026-07-01 12:33 ` Luis
2026-07-01 13:34   ` Matthieu Longo
2026-07-21 16:55     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox