Re: [PATCH v1 3/6] gdb: introduce helper class file_reader_t
Thiago Jung Bauermann <[email protected]> Mon, 03 Aug 2026 05:00:25 +0000
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
Matthieu Longo <[email protected]> writes: > Wrap all the boilerplate code required to read a file in a new helper > class: file_reader_t. The class owns the file contents together with > the file path, and provides convenient accessors for the data, size and > typed views. It supports both null-terminated text files and binary files. > > This helper eliminates repeated calls to target_fileio_read_stralloc > and target_fileio_read_alloc, remove explicit memory management with > gdb::unique_xmalloc_ptr, and simplifies the casting logic when working > with binary data. > > The patch converts some of the existing Linux, AMD64, and SPARC code that > reads files from /proc to use file_reader_t. > --- > gdb/amd64-linux-tdep.c | 12 ++--- > gdb/linux-tdep.c | 109 ++++++++++++++++++----------------------- > gdb/sparc64-tdep.c | 13 +++-- > gdb/target.h | 79 +++++++++++++++++++++++++++++ > 4 files changed, 137 insertions(+), 76 deletions(-) Thank you for adding the comments I requested. You addressed Christina's remarks about keeping the current behaviour when reading empty files in the case of the task maps file and also in the case of the SPARC-specific adi/maps file. I don't know whether this is enough to resolve her concerns. Assuming it is: Reviewed-by: Thiago Jung Bauermann <[email protected]> -- Thiago (he/him)