From: Matthieu Longo <matthieu.longo@arm.com>
To: <gdb-patches@sourceware.org>
Cc: Luis Machado <luis.machado@amd.com>,
Luis Machado <luis.machado.foss@gmail.com>,
Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
Simon Marchi <simark@simark.ca>,
"Kevin Buettner" <kevinb@redhat.com>,
Christina Schimpe <christina.schimpe@intel.com>,
Christina Joos <christina.joos@intel.com>,
Matthieu Longo <matthieu.longo@arm.com>
Subject: [PATCH v1 6/6] gdb/linux-tdep: remove legacy parse_smaps_data overload
Date: Tue, 28 Jul 2026 16:17:00 +0100 [thread overview]
Message-ID: <20260728151700.253720-7-matthieu.longo@arm.com> (raw)
In-Reply-To: <20260728151700.253720-1-matthieu.longo@arm.com>
Now that all callers use the file_reader_t overload of parse_smaps_data,
the legacy interface taking a raw buffer and filename separately is no
longer needed.
Fold its implementation into the file_reader_t version and remove the
obsolete wrapper. This also simplifies the implementation by using the
file_reader_t accessors directly.
Reviewed-By: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-By: Luis Machado <luis.machado.foss@gmail.com>
---
gdb/linux-tdep.c | 30 ++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 628f73969d3..2e9cb14d5bf 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -1582,18 +1582,17 @@ parse_smaps_key_value (const char *keyword, const char *line,
/* Helper function to parse the contents of /proc/<pid>/smaps into a data
structure, for easy access.
- DATA is the contents of the smaps file. The parsed contents are stored
- into the SMAPS vector. */
+ FREADER is a wrapper around the contents of the smaps file.
+ The parsed contents are stored into the SMAPS vector. */
static std::vector<struct smaps_data>
-parse_smaps_data (const char *data,
- const std::string &maps_filename)
+parse_smaps_data (const file_reader_t<char> &freader)
{
char *line, *t;
- gdb_assert (data != nullptr);
+ gdb_assert (freader);
- line = strtok_r ((char *) data, "\n", &t);
+ line = strtok_r (freader.data (), "\n", &t);
std::vector<struct smaps_data> smaps;
@@ -1649,8 +1648,8 @@ parse_smaps_data (const char *data,
if (sscanf (line, "%64s", keyword) != 1)
{
- warning (_("Error parsing {s,}maps file '%s'"),
- maps_filename.c_str ());
+ warning (_("Error parsing keyword in {s,}maps file '%s'"),
+ freader.c_filepath ());
break;
}
@@ -1664,12 +1663,12 @@ parse_smaps_data (const char *data,
decode_vmflags (line, &v);
if (parse_smaps_key_value (keyword, line, "Rss:",
- maps_filename,
+ freader.filepath (),
&rss))
continue;
if (parse_smaps_key_value (keyword, line, "Swap:",
- maps_filename,
+ freader.filepath (),
&swap))
continue;
@@ -1680,8 +1679,9 @@ parse_smaps_data (const char *data,
if (sscanf (line, "%*s%lu", &number) != 1)
{
- warning (_("Error parsing {s,}maps file '%s' number"),
- maps_filename.c_str ());
+ warning (_("Error parsing numeric value associated with "
+ "key '%s' in {s,}maps file '%s'"),
+ keyword, freader.c_filepath ());
break;
}
if (number > 0)
@@ -1731,12 +1731,6 @@ parse_smaps_data (const char *data,
return smaps;
}
-static std::vector<struct smaps_data>
-parse_smaps_data (const file_reader_t<char> &freader)
-{
- return parse_smaps_data (freader.data (), freader.filepath ());
-}
-
/* Helper that checks if an address is in a memory tag page for a live
process. */
--
2.55.0
next prev parent reply other threads:[~2026-07-28 15:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 15:16 [PATCH v1 0/6] gdb: introduce file_reader_t to read procfs files Matthieu Longo
2026-07-28 15:16 ` [PATCH v1 1/6] target_fileio_read_stralloc: add an optional length parameter Matthieu Longo
2026-07-28 15:16 ` [PATCH v1 2/6] gdb support: add gdb::ranges::replace algorithm Matthieu Longo
2026-07-28 15:16 ` [PATCH v1 3/6] gdb: introduce helper class file_reader_t Matthieu Longo
2026-07-28 15:16 ` [PATCH v1 4/6] gdb/linux-tdep: migrate linux_info_proc to file_reader_t Matthieu Longo
2026-07-28 15:16 ` [PATCH v1 5/6] gdb/linux-tdep: migrate linux_find_memory_regions_full " Matthieu Longo
2026-07-28 15:17 ` Matthieu Longo [this message]
2026-07-28 15:43 ` [PATCH v1 0/6] gdb: introduce file_reader_t to read procfs files Joos, Christina
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=20260728151700.253720-7-matthieu.longo@arm.com \
--to=matthieu.longo@arm.com \
--cc=christina.joos@intel.com \
--cc=christina.schimpe@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=kevinb@redhat.com \
--cc=luis.machado.foss@gmail.com \
--cc=luis.machado@amd.com \
--cc=simark@simark.ca \
--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