From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 5/8] gdb: add target_fileio_stat, but no implementations yet
Date: Wed, 5 Jun 2024 14:15:12 +0100 [thread overview]
Message-ID: <870a4b66180f7f00ff50ae0dc26c0bfbbd8976c0.1717592684.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1717592683.git.aburgess@redhat.com>
In a later commit I want target_fileio_stat, that is a call that
operates on a filename rather than an open file descriptor as
target_fileio_fstat does.
This commit adds the initial framework for target_fileio_stat, I've
added the top level target function and the virtual target_ops methods
in the target_ops base class.
At this point no actual targets override target_ops::fileio_stat, so
any attempts to call this function will return ENOSYS error code.
---
gdb/target.c | 31 +++++++++++++++++++++++++++++++
gdb/target.h | 16 ++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/gdb/target.c b/gdb/target.c
index 276e215945e..37c907830d6 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3198,6 +3198,14 @@ target_ops::fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno)
return -1;
}
+int
+target_ops::fileio_stat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno)
+{
+ *target_errno = FILEIO_ENOSYS;
+ return -1;
+}
+
int
target_ops::fileio_close (int fd, fileio_error *target_errno)
{
@@ -3317,6 +3325,29 @@ target_fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno)
/* See target.h. */
+int
+target_fileio_stat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno)
+{
+ for (target_ops *t = default_fileio_target (); t != NULL; t = t->beneath ())
+ {
+ int ret = t->fileio_stat (inf, filename, sb, target_errno);
+
+ if (ret == -1 && *target_errno == FILEIO_ENOSYS)
+ continue;
+
+ target_debug_printf_nofunc ("target_fileio_stat (%s) = %d (%d)",
+ filename, ret,
+ ret != -1 ? 0 : *target_errno);
+ return ret;
+ }
+
+ *target_errno = FILEIO_ENOSYS;
+ return -1;
+}
+
+/* See target.h. */
+
int
target_fileio_close (int fd, fileio_error *target_errno)
{
diff --git a/gdb/target.h b/gdb/target.h
index 81de4a678c3..f754f4abd53 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1011,6 +1011,14 @@ struct target_ops
*TARGET_ERRNO). */
virtual int fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno);
+ /* Get information about the file FILENAME and put it in SB. Look for
+ FILENAME in the filesystem as seen by INF. If INF is NULL, use the
+ filesystem seen by the debugger (GDB or, for remote targets, the
+ remote stub). Return 0 on success, or -1 if an error occurs (and
+ set *TARGET_ERRNO). */
+ virtual int fileio_stat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno);
+
/* Close FD on the target. Return 0, or -1 if an error occurs
(and set *TARGET_ERRNO). */
virtual int fileio_close (int fd, fileio_error *target_errno);
@@ -2220,6 +2228,14 @@ extern int target_fileio_pread (int fd, gdb_byte *read_buf, int len,
extern int target_fileio_fstat (int fd, struct stat *sb,
fileio_error *target_errno);
+/* Get information about the file at FILENAME on the target and put it in
+ SB. Look in the filesystem as seen by INF. If INF is NULL, use the
+ filesystem seen by the debugger (GDB or, for remote targets, the remote
+ stub). Return 0 on success, or -1 if an error occurs (and set
+ *TARGET_ERRNO). */
+extern int target_fileio_stat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno);
+
/* Close FD on the target. Return 0, or -1 if an error occurs
(and set *TARGET_ERRNO). */
extern int target_fileio_close (int fd, fileio_error *target_errno);
--
2.25.4
next prev parent reply other threads:[~2024-06-05 13:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 13:15 [PATCH 0/8] Extension for looking up debug info by build-id Andrew Burgess
2024-06-05 13:15 ` [PATCH 1/8] gdb/fileio: fix errno for packets where an attachment is expected Andrew Burgess
2024-06-06 16:49 ` Tom Tromey
2024-06-11 19:52 ` Andrew Burgess
2024-06-05 13:15 ` [PATCH 2/8] gdb: avoid duplicate search in build_id_to_bfd_suffix Andrew Burgess
2024-06-06 16:49 ` Tom Tromey
2024-06-11 19:52 ` Andrew Burgess
2024-06-05 13:15 ` [PATCH 3/8] gdb: warn of slow remote file reading only after a successful open Andrew Burgess
2024-06-06 16:58 ` Tom Tromey
2024-06-11 19:52 ` Andrew Burgess
2024-06-05 13:15 ` [PATCH 4/8] gdb: convert separate-debug-file to new(ish) debug scheme Andrew Burgess
2024-06-06 16:54 ` Tom Tromey
2024-06-11 19:52 ` Andrew Burgess
2024-06-05 13:15 ` Andrew Burgess [this message]
2024-06-05 13:15 ` [PATCH 6/8] gdb: add GDB side target_ops::fileio_stat implementation Andrew Burgess
2024-06-05 14:21 ` Eli Zaretskii
2024-06-05 13:15 ` [PATCH 7/8] gdbserver: add gdbserver support for vFile::stat packet Andrew Burgess
2024-06-05 13:15 ` [PATCH 8/8] gdb: check for multiple matching build-id files Andrew Burgess
2024-06-13 10:29 ` [PATCH 0/8] Extension for looking up debug info by build-id Andrew Burgess
2024-06-13 10:29 ` [PATCHv2 1/4] gdb: add target_fileio_stat, but no implementations yet Andrew Burgess
2024-06-13 10:29 ` [PATCHv2 2/4] gdb: add GDB side target_ops::fileio_stat implementation Andrew Burgess
2024-06-13 10:29 ` [PATCHv2 3/4] gdbserver: add gdbserver support for vFile::stat packet Andrew Burgess
2024-06-13 10:29 ` [PATCHv2 4/4] gdb: check for multiple matching build-id files Andrew Burgess
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=870a4b66180f7f00ff50ae0dc26c0bfbbd8976c0.1717592684.git.aburgess@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).