Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Matthieu Longo <matthieu.longo@arm.com>
To: <gdb-patches@sourceware.org>
Cc: Tom Tromey <tom@tromey.com>,
	Matthieu Longo <matthieu.longo@arm.com>,
	Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
	Luis Machado <luis.machado.foss@gmail.com>
Subject: [PATCH v4 5/5] gdb/linux-tdep: remove legacy parse_smaps_data overload
Date: Mon, 16 Nov 2026 12:09:36 +0000	[thread overview]
Message-ID: <20261116120936.425082-6-matthieu.longo@arm.com> (raw)
In-Reply-To: <20261116120936.425082-1-matthieu.longo@arm.com>

Now that all callers use the target_file_reader overload of parse_smaps_data,
the legacy interface taking a raw buffer and file path separately is no
longer needed.

Fold its implementation into the target_file_reader version and remove the
obsolete wrapper.  This also simplifies the implementation by using the
target_file_reader accessors directly.

Reviewed-By: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-By: Luis Machado <luis.machado.foss@gmail.com>
Approved-By: Tom Tromey <tom@tromey.com>
---
 gdb/linux-tdep.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index e796cd4f6de..02f133192ca 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -1583,14 +1583,14 @@ 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 returned as a vector.  */
 
 static std::vector<smaps_data>
-parse_smaps_data (gdb::array_view<char> data,
-		  const std::string &maps_filename)
+parse_smaps_data (const target_file_reader<char> &freader)
 {
   std::vector<smaps_data> smaps;
+  auto data = freader.view ();
 
   for (auto it = data.begin (); it != data.end ();)
     {
@@ -1650,8 +1650,9 @@ parse_smaps_data (gdb::array_view<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 '%ps'"),
+		       styled_string (file_name_style.style (),
+				      freader.c_path ()));
 	      break;
 	    }
 
@@ -1665,12 +1666,12 @@ parse_smaps_data (gdb::array_view<char> data,
 	    decode_vmflags (line, &v);
 
 	  if (parse_smaps_key_value (keyword, line, "Rss:",
-				     maps_filename,
+				     freader.path (),
 				     &rss))
 	    continue;
 
 	  if (parse_smaps_key_value (keyword, line, "Swap:",
-				     maps_filename,
+				     freader.path (),
 				     &swap))
 	    continue;
 
@@ -1681,8 +1682,11 @@ parse_smaps_data (gdb::array_view<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 '%ps'"),
+			   keyword,
+			   styled_string (file_name_style.style (),
+					  freader.c_path ()));
 		  break;
 		}
 	      if (number > 0)
@@ -1737,12 +1741,6 @@ parse_smaps_data (gdb::array_view<char> data,
   return smaps;
 }
 
-static std::vector<smaps_data>
-parse_smaps_data (const target_file_reader<char> &freader)
-{
-  return parse_smaps_data (freader.view (), freader.path ());
-}
-
 /* Helper that checks if an address is in a memory tag page for a live
    process.  */
 
-- 
2.56.0


      parent reply	other threads:[~2026-11-16 12:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 12:09 [PATCH v4 0/5] gdb: introduce file_reader_t to read procfs files Matthieu Longo
2026-11-16 12:09 ` [PATCH v4 1/5] gdbsupport: add extract_next_field helper Matthieu Longo
2026-11-16 12:09 ` [PATCH v4 2/5] gdb/linux: refactor /proc mapping parsing to use array_view Matthieu Longo
2026-11-16 12:09 ` [PATCH v4 3/5] gdb: introduce helper class target_file_reader Matthieu Longo
2026-11-16 12:09 ` [PATCH v4 4/5] gdb/linux-tdep: use target_file_reader for procfs parsing Matthieu Longo
2026-11-16 12:09 ` Matthieu Longo [this message]

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=20261116120936.425082-6-matthieu.longo@arm.com \
    --to=matthieu.longo@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado.foss@gmail.com \
    --cc=thiago.bauermann@linaro.org \
    --cc=tom@tromey.com \
    /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