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: Andrew Burgess <aburgess@redhat.com>, Tom Tromey <tom@tromey.com>,
	Matthieu Longo <matthieu.longo@arm.com>
Subject: [PATCH v3 0/8] gdb: introduce file_reader_t to read procfs files
Date: Tue, 22 Sep 2026 14:50:42 +0100	[thread overview]
Message-ID: <20260922135050.236941-1-matthieu.longo@arm.com> (raw)

This series introduces target_file_reader, a helper class for reading target files, and migrates existing /proc file handling to use it. It also refactors the /proc mapping parser to operate on bounded views rather than NUL-terminated strings.

The series is organized as follows:
- Patch 1 adds gdb::ranges::replace, a C++17-compatible replacement for std::ranges::replace.
- Patches 2 and 3 contain small cleanups identified during review: removing redundant struct prefixes and styling /proc filenames in warning messages.
- Patch 4 adds extract_next_field, a helper for extracting separator-delimited views from a buffer.
- Patch 5 refactors /proc mapping parsing to use gdb::array_view<char> and extract_view_from_buffer, removing the dependency on NUL-terminated strings and strtok_r.
- Patch 6 introduces target_file_reader, which encapsulates the contents and path of a target file and provides convenient accessors and typed views.
- Patches 7 and 8 migrate existing procfs parsing to target_file_reader and remove the now-obsolete parse_smaps_data interface.

== Review status ==
Most of the patches have been already reviewed once by Andrew Burgess in v2, and others reviewers in v1.
However, for clarity:
- Patches 2 and 3 are new but based on comments from Andrew Burgess in v2.
- Patch 5 contains new or substantially changed code and require more attention. This rework was triggered by the discovery of a bug in patch 4/6 in v2.


== Changes since v2 ==

v2: https://inbox.sourceware.org/gdb-patches/20260825100912.514232-1-matthieu.longo@arm.com/
- Renamed extract_view_from_buffer to extract_next_field, and add unit tests in selftests.
- Refactored /proc mapping parsing to operate on gdb::array_view<char> instead of NUL-terminated strings. read_mapping now parses bounded ranges and diagnoses malformed mapping fields.
- Split the cleanup removing redundant struct prefixes from smaps_data, as suggested by Christina Joos and Andrew Burgess.
- Added filename styling to /proc warning messages, as suggested by Andrew Burgess.


This series depends on: https://inbox.sourceware.org/gdb-patches/20260917201755.589524-1-simon.marchi@efficios.com/

Regards,
Matthieu


Matthieu Longo (8):
  gdb support: add gdb::ranges::replace algorithm
  gdb/linux: remove redundant struct prefixes from smaps_data
  gdb/linux: style filenames in /proc warning messages
  gdbsupport: add extract_next_field helper
  gdb/linux: refactor /proc mapping parsing to use array_view
  gdb: introduce helper class target_file_reader
  gdb/linux-tdep: use target_file_reader for procfs parsing
  gdb/linux-tdep: remove legacy parse_smaps_data overload

 gdb/Makefile.in                        |   1 +
 gdb/amd64-linux-tdep.c                 |  12 +-
 gdb/linux-tdep.c                       | 406 +++++++++++++------------
 gdb/sparc64-tdep.c                     |  17 +-
 gdb/target.h                           | 116 +++++++
 gdb/unittests/common-utils-selftests.c |  32 ++
 gdb/unittests/ranges-selftests.c       |  63 ++++
 gdbsupport/common-utils.h              |  50 +++
 gdbsupport/ranges.h                    |  39 +++
 9 files changed, 530 insertions(+), 206 deletions(-)
 create mode 100644 gdb/unittests/ranges-selftests.c
 create mode 100644 gdbsupport/ranges.h

-- 
2.55.0


             reply	other threads:[~2026-09-22 13:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 13:50 Matthieu Longo [this message]
2026-09-22 13:50 ` [PATCH v3 1/8] gdb support: add gdb::ranges::replace algorithm Matthieu Longo
2026-09-22 13:50 ` [PATCH v3 2/8] gdb/linux: remove redundant struct prefixes from smaps_data Matthieu Longo
2026-09-22 13:50 ` [PATCH v3 3/8] gdb/linux: style filenames in /proc warning messages Matthieu Longo
2026-09-22 13:50 ` [PATCH v3 4/8] gdbsupport: add extract_next_field helper Matthieu Longo
2026-09-22 13:50 ` [PATCH v3 5/8] gdb/linux: refactor /proc mapping parsing to use array_view Matthieu Longo
2026-09-22 13:50 ` [PATCH v3 6/8] gdb: introduce helper class target_file_reader Matthieu Longo
2026-09-22 13:50 ` [PATCH v3 7/8] gdb/linux-tdep: use target_file_reader for procfs parsing Matthieu Longo
2026-09-22 13:50 ` [PATCH v3 8/8] gdb/linux-tdep: remove legacy parse_smaps_data overload Matthieu Longo

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=20260922135050.236941-1-matthieu.longo@arm.com \
    --to=matthieu.longo@arm.com \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.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