4 * Copyright (c) 2023 Linaro Ltd
6 * SPDX-License-Identifier: LGPL-2.0+
12 /* For gdb file i/o remote protocol open flags. */
13 #define GDB_O_RDONLY 0
14 #define GDB_O_WRONLY 1
16 #define GDB_O_APPEND 8
17 #define GDB_O_CREAT 0x200
18 #define GDB_O_TRUNC 0x400
19 #define GDB_O_EXCL 0x800
21 /* For gdb file i/o remote protocol errno values */
31 #define GDB_ENOTDIR 20
40 #define GDB_ENAMETOOLONG 91
41 #define GDB_EUNKNOWN 9999
43 /* For gdb file i/o remote protocol lseek whence. */
44 #define GDB_SEEK_SET 0
45 #define GDB_SEEK_CUR 1
46 #define GDB_SEEK_END 2
48 /* For gdb file i/o stat/fstat. */
49 typedef uint32_t gdb_mode_t
;
50 typedef uint32_t gdb_time_t
;
53 uint32_t gdb_st_dev
; /* device */
54 uint32_t gdb_st_ino
; /* inode */
55 gdb_mode_t gdb_st_mode
; /* protection */
56 uint32_t gdb_st_nlink
; /* number of hard links */
57 uint32_t gdb_st_uid
; /* user ID of owner */
58 uint32_t gdb_st_gid
; /* group ID of owner */
59 uint32_t gdb_st_rdev
; /* device type (if inode device) */
60 uint64_t gdb_st_size
; /* total size, in bytes */
61 uint64_t gdb_st_blksize
; /* blocksize for filesystem I/O */
62 uint64_t gdb_st_blocks
; /* number of blocks allocated */
63 gdb_time_t gdb_st_atime
; /* time of last access */
64 gdb_time_t gdb_st_mtime
; /* time of last modification */
65 gdb_time_t gdb_st_ctime
; /* time of last change */
69 gdb_time_t tv_sec
; /* second */
70 uint64_t tv_usec
; /* microsecond */
73 typedef void (*gdb_syscall_complete_cb
)(CPUState
*cpu
, uint64_t ret
, int err
);
77 * @cb: function to call when the system call has completed
78 * @fmt: gdb syscall format string
79 * ...: list of arguments to interpolate into @fmt
81 * Send a GDB syscall request. This function will return immediately;
82 * the callback function will be called later when the remote system
85 * @fmt should be in the 'call-id,parameter,parameter...' format documented
86 * for the F request packet in the GDB remote protocol. A limited set of
87 * printf-style format specifiers is supported:
88 * %x - target_ulong argument printed in hex
89 * %lx - 64-bit argument printed in hex
90 * %s - string pointer (target_ulong) and length (int) pair
92 void gdb_do_syscall(gdb_syscall_complete_cb cb
, const char *fmt
, ...);
95 * use_gdb_syscalls() - report if GDB should be used for syscalls
97 * This is mostly driven by the semihosting mode the user configures
98 * but assuming GDB is allowed by that we report true if GDB is
99 * connected to the stub.
101 int use_gdb_syscalls(void);
104 * gdb_exit: exit gdb session, reporting inferior status
105 * @code: exit code reported
107 * This closes the session and sends a final packet to GDB reporting
108 * the exit status of the program. It also cleans up any connections
109 * detritus before returning.
111 void gdb_exit(int code
);
114 * gdb_qemu_exit: ask qemu to exit
115 * @code: exit code reported
117 * This requests qemu to exit. This function is allowed to return as
118 * the exit request might be processed asynchronously by qemu backend.
120 void gdb_qemu_exit(int code
);
122 #endif /* _SYSCALLS_H_ */