In the following commits I added the target_fileio_stat function, and
the target_ops::fileio_stat member function:
*
08a115cc1c4 gdb: add target_fileio_stat, but no implementations yet
*
3055e3d2f13 gdb: add GDB side target_ops::fileio_stat implementation
*
6d45af96ea5 gdbserver: add gdbserver support for vFile::stat packet
*
22836ca8859 gdb: check for multiple matching build-id files
Unfortunately, I messed up when adding this API. The actual
underlying call is lstat, not stat.
This commit tries to clear up some of the confusion by renaming things
to target_fileio_lstat and target_ops::fileio_lstat.
After this change the function names now match the underlying
implementation.
One problem remains though. In order to support target_fileio_stat
for remote target the above patches added the vFile:stat packet to GDB
and gdbserver. The implementation of this packet still does an lstat
though, which is a bit of a shame. I'm going to try and fix that in
later commits.
This commit is just a rename within GDB, there should be no user
visible changes.
Approved-By: Tom Tromey <tom@tromey.com>
if (supports_target_stat != TRIBOOL_FALSE)
{
struct stat sb;
- int res = target_fileio_stat (nullptr, link_on_target, &sb,
- &target_errno);
+ int res = target_fileio_lstat (nullptr, link_on_target, &sb,
+ &target_errno);
if (res != 0 && target_errno != FILEIO_ENOSYS)
{
return ret;
}
-/* Implementation of to_fileio_stat. */
+/* Implementation of to_fileio_lstat. */
int
-inf_child_target::fileio_stat (struct inferior *inf, const char *filename,
- struct stat *sb, fileio_error *target_errno)
+inf_child_target::fileio_lstat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno)
{
int ret;
int fileio_pread (int fd, gdb_byte *read_buf, int len,
ULONGEST offset, fileio_error *target_errno) override;
int fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno) override;
- int fileio_stat (struct inferior *inf, const char *filename,
- struct stat *sb, fileio_error *target_errno) override;
+ int fileio_lstat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno) override;
int fileio_close (int fd, fileio_error *target_errno) override;
int fileio_unlink (struct inferior *inf,
const char *filename,
int fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno) override;
- int fileio_stat (struct inferior *inf, const char *filename,
- struct stat *sb, fileio_error *target_errno) override;
+ int fileio_lstat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno) override;
int fileio_close (int fd, fileio_error *target_errno) override;
return ret;
}
-/* Helper function to handle ::fileio_fstat and ::fileio_stat result
+/* Helper function to handle ::fileio_fstat and ::fileio_lstat result
processing. When this function is called the remote syscall has been
performed and we know we didn't get an error back.
data) is to be placed in ST. */
static int
-fileio_process_fstat_and_stat_reply (const char *attachment,
- int attachment_len,
- int expected_len,
- struct stat *st)
+fileio_process_fstat_and_lstat_reply (const char *attachment,
+ int attachment_len,
+ int expected_len,
+ struct stat *st)
{
struct fio_stat fst;
return 0;
}
- return fileio_process_fstat_and_stat_reply (attachment, attachment_len,
- ret, st);
+ return fileio_process_fstat_and_lstat_reply (attachment, attachment_len,
+ ret, st);
}
-/* Implementation of to_fileio_stat. */
+/* Implementation of to_fileio_lstat. */
int
-remote_target::fileio_stat (struct inferior *inf, const char *filename,
- struct stat *st, fileio_error *remote_errno)
+remote_target::fileio_lstat (struct inferior *inf, const char *filename,
+ struct stat *st, fileio_error *remote_errno)
{
struct remote_state *rs = get_remote_state ();
char *p = rs->buf.data ();
if (ret < 0)
return ret;
- return fileio_process_fstat_and_stat_reply (attachment, attachment_len,
- ret, st);
+ return fileio_process_fstat_and_lstat_reply (attachment, attachment_len,
+ ret, st);
}
/* Implementation of to_filesystem_is_local. */
}
int
-target_ops::fileio_stat (struct inferior *inf, const char *filename,
- struct stat *sb, fileio_error *target_errno)
+target_ops::fileio_lstat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno)
{
*target_errno = FILEIO_ENOSYS;
return -1;
/* See target.h. */
int
-target_fileio_stat (struct inferior *inf, const char *filename,
- struct stat *sb, fileio_error *target_errno)
+target_fileio_lstat (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);
+ int ret = t->fileio_lstat (inf, filename, sb, target_errno);
if (ret == -1 && *target_errno == FILEIO_ENOSYS)
continue;
- target_debug_printf_nofunc ("target_fileio_stat (%s) = %d (%d)",
+ target_debug_printf_nofunc ("target_fileio_lstat (%s) = %d (%d)",
filename, ret,
ret != -1 ? 0 : *target_errno);
return ret;
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);
+ virtual int fileio_lstat (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). */
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);
+extern int target_fileio_lstat (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). */