From: Matthieu Longo <matthieu.longo@arm.com>
To: <gdb-patches@sourceware.org>
Cc: Luis Machado <luis.machado@amd.com>,
Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
Andrew Burgess <aburgess@redhat.com>,
"Matthieu Longo" <matthieu.longo@arm.com>
Subject: [PATCH] gdb questions: fallback on maps still relevant today ?
Date: Wed, 1 Jul 2026 13:17:02 +0100 [thread overview]
Message-ID: <20260701121706.110679-1-matthieu.longo@arm.com> (raw)
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
next reply other threads:[~2026-07-01 12:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 12:17 Matthieu Longo [this message]
2026-07-01 12:33 ` Luis
2026-07-01 13:34 ` Matthieu Longo
2026-07-21 16:55 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260701121706.110679-1-matthieu.longo@arm.com \
--to=matthieu.longo@arm.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=luis.machado@amd.com \
--cc=thiago.bauermann@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox