[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/60] include/exec: Move gdb_stat and gdb_timeval to gdbstub.h
From: |
Richard Henderson |
Subject: |
[PULL 17/60] include/exec: Move gdb_stat and gdb_timeval to gdbstub.h |
Date: |
Tue, 28 Jun 2022 10:23:20 +0530 |
We have two copies of these structures, and require them
in semihosting/ going forward.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/exec/gdbstub.h | 25 +++++++++++++++++++++++++
target/m68k/m68k-semi.c | 32 +++++---------------------------
target/nios2/nios2-semi.c | 30 +++---------------------------
3 files changed, 33 insertions(+), 54 deletions(-)
diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index 603e22ae80..7413ffeba2 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -19,6 +19,31 @@
#define GDB_O_TRUNC 0x400
#define GDB_O_EXCL 0x800
+/* For gdb file i/o stat/fstat. */
+typedef uint32_t gdb_mode_t;
+typedef uint32_t gdb_time_t;
+
+struct gdb_stat {
+ uint32_t gdb_st_dev; /* device */
+ uint32_t gdb_st_ino; /* inode */
+ gdb_mode_t gdb_st_mode; /* protection */
+ uint32_t gdb_st_nlink; /* number of hard links */
+ uint32_t gdb_st_uid; /* user ID of owner */
+ uint32_t gdb_st_gid; /* group ID of owner */
+ uint32_t gdb_st_rdev; /* device type (if inode device) */
+ uint64_t gdb_st_size; /* total size, in bytes */
+ uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */
+ uint64_t gdb_st_blocks; /* number of blocks allocated */
+ gdb_time_t gdb_st_atime; /* time of last access */
+ gdb_time_t gdb_st_mtime; /* time of last modification */
+ gdb_time_t gdb_st_ctime; /* time of last change */
+} QEMU_PACKED;
+
+struct gdb_timeval {
+ gdb_time_t tv_sec; /* second */
+ uint64_t tv_usec; /* microsecond */
+} QEMU_PACKED;
+
#ifdef NEED_CPU_H
#include "cpu.h"
diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c
index 475a6b13b7..b886ebf714 100644
--- a/target/m68k/m68k-semi.c
+++ b/target/m68k/m68k-semi.c
@@ -45,30 +45,6 @@
#define HOSTED_ISATTY 12
#define HOSTED_SYSTEM 13
-typedef uint32_t gdb_mode_t;
-typedef uint32_t gdb_time_t;
-
-struct m68k_gdb_stat {
- uint32_t gdb_st_dev; /* device */
- uint32_t gdb_st_ino; /* inode */
- gdb_mode_t gdb_st_mode; /* protection */
- uint32_t gdb_st_nlink; /* number of hard links */
- uint32_t gdb_st_uid; /* user ID of owner */
- uint32_t gdb_st_gid; /* group ID of owner */
- uint32_t gdb_st_rdev; /* device type (if inode device) */
- uint64_t gdb_st_size; /* total size, in bytes */
- uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */
- uint64_t gdb_st_blocks; /* number of blocks allocated */
- gdb_time_t gdb_st_atime; /* time of last access */
- gdb_time_t gdb_st_mtime; /* time of last modification */
- gdb_time_t gdb_st_ctime; /* time of last change */
-} QEMU_PACKED;
-
-struct gdb_timeval {
- gdb_time_t tv_sec; /* second */
- uint64_t tv_usec; /* microsecond */
-} QEMU_PACKED;
-
static int translate_openflags(int flags)
{
int hf;
@@ -90,11 +66,13 @@ static int translate_openflags(int flags)
static void translate_stat(CPUM68KState *env, target_ulong addr, struct stat
*s)
{
- struct m68k_gdb_stat *p;
+ struct gdb_stat *p;
- if (!(p = lock_user(VERIFY_WRITE, addr, sizeof(struct m68k_gdb_stat), 0)))
+ p = lock_user(VERIFY_WRITE, addr, sizeof(struct gdb_stat), 0);
+ if (!p) {
/* FIXME - should this return an error code? */
return;
+ }
p->gdb_st_dev = cpu_to_be32(s->st_dev);
p->gdb_st_ino = cpu_to_be32(s->st_ino);
p->gdb_st_mode = cpu_to_be32(s->st_mode);
@@ -114,7 +92,7 @@ static void translate_stat(CPUM68KState *env, target_ulong
addr, struct stat *s)
p->gdb_st_atime = cpu_to_be32(s->st_atime);
p->gdb_st_mtime = cpu_to_be32(s->st_mtime);
p->gdb_st_ctime = cpu_to_be32(s->st_ctime);
- unlock_user(p, addr, sizeof(struct m68k_gdb_stat));
+ unlock_user(p, addr, sizeof(struct gdb_stat));
}
static void m68k_semi_return_u32(CPUM68KState *env, uint32_t ret, uint32_t err)
diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c
index 0eec1f9a1c..3e504a6c5f 100644
--- a/target/nios2/nios2-semi.c
+++ b/target/nios2/nios2-semi.c
@@ -47,30 +47,6 @@
#define HOSTED_ISATTY 12
#define HOSTED_SYSTEM 13
-typedef uint32_t gdb_mode_t;
-typedef uint32_t gdb_time_t;
-
-struct nios2_gdb_stat {
- uint32_t gdb_st_dev; /* device */
- uint32_t gdb_st_ino; /* inode */
- gdb_mode_t gdb_st_mode; /* protection */
- uint32_t gdb_st_nlink; /* number of hard links */
- uint32_t gdb_st_uid; /* user ID of owner */
- uint32_t gdb_st_gid; /* group ID of owner */
- uint32_t gdb_st_rdev; /* device type (if inode device) */
- uint64_t gdb_st_size; /* total size, in bytes */
- uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */
- uint64_t gdb_st_blocks; /* number of blocks allocated */
- gdb_time_t gdb_st_atime; /* time of last access */
- gdb_time_t gdb_st_mtime; /* time of last modification */
- gdb_time_t gdb_st_ctime; /* time of last change */
-} QEMU_PACKED;
-
-struct gdb_timeval {
- gdb_time_t tv_sec; /* second */
- uint64_t tv_usec; /* microsecond */
-} QEMU_PACKED;
-
static int translate_openflags(int flags)
{
int hf;
@@ -102,9 +78,9 @@ static int translate_openflags(int flags)
static bool translate_stat(CPUNios2State *env, target_ulong addr,
struct stat *s)
{
- struct nios2_gdb_stat *p;
+ struct gdb_stat *p;
- p = lock_user(VERIFY_WRITE, addr, sizeof(struct nios2_gdb_stat), 0);
+ p = lock_user(VERIFY_WRITE, addr, sizeof(struct gdb_stat), 0);
if (!p) {
return false;
@@ -128,7 +104,7 @@ static bool translate_stat(CPUNios2State *env, target_ulong
addr,
p->gdb_st_atime = cpu_to_be32(s->st_atime);
p->gdb_st_mtime = cpu_to_be32(s->st_mtime);
p->gdb_st_ctime = cpu_to_be32(s->st_ctime);
- unlock_user(p, addr, sizeof(struct nios2_gdb_stat));
+ unlock_user(p, addr, sizeof(struct gdb_stat));
return true;
}
--
2.34.1
- [PULL 07/60] semihosting: Simplify softmmu_lock_user_string, (continued)
- [PULL 07/60] semihosting: Simplify softmmu_lock_user_string, Richard Henderson, 2022/06/28
- [PULL 08/60] semihosting: Split out guestfd.c, Richard Henderson, 2022/06/28
- [PULL 09/60] semihosting: Inline set_swi_errno into common_semi_cb, Richard Henderson, 2022/06/28
- [PULL 10/60] semihosting: Adjust error checking in common_semi_cb, Richard Henderson, 2022/06/28
- [PULL 11/60] semihosting: Clean up common_semi_flen_cb, Richard Henderson, 2022/06/28
- [PULL 12/60] semihosting: Clean up common_semi_open_cb, Richard Henderson, 2022/06/28
- [PULL 13/60] semihosting: Return void from do_common_semihosting, Richard Henderson, 2022/06/28
- [PULL 14/60] semihosting: Move common-semi.h to include/semihosting/, Richard Henderson, 2022/06/28
- [PULL 15/60] semihosting: Remove GDB_O_BINARY, Richard Henderson, 2022/06/28
- [PULL 16/60] include/exec: Move gdb open flags to gdbstub.h, Richard Henderson, 2022/06/28
- [PULL 17/60] include/exec: Move gdb_stat and gdb_timeval to gdbstub.h,
Richard Henderson <=
- [PULL 19/60] gdbstub: Convert GDB error numbers to host error numbers, Richard Henderson, 2022/06/28
- [PULL 22/60] semihosting: Split common_semi_flen_buf per target, Richard Henderson, 2022/06/28
- [PULL 18/60] include/exec: Define errno values in gdbstub.h, Richard Henderson, 2022/06/28
- [PULL 20/60] semihosting: Use struct gdb_stat in common_semi_flen_cb, Richard Henderson, 2022/06/28
- [PULL 24/60] semihosting: Split out common-semi-target.h, Richard Henderson, 2022/06/28
- [PULL 26/60] semihosting: Move GET_ARG/SET_ARG earlier in the file, Richard Henderson, 2022/06/28
- [PULL 25/60] semihosting: Use env more often in do_common_semihosting, Richard Henderson, 2022/06/28
- [PULL 29/60] semihosting: Split out semihost_sys_read, Richard Henderson, 2022/06/28
- [PULL 21/60] semihosting: Split is_64bit_semihosting per target, Richard Henderson, 2022/06/28
- [PULL 32/60] semihosting: Split out semihost_sys_lseek, Richard Henderson, 2022/06/28