gdb_syscall.h
Go to the documentation of this file.
11 * An API is defined for communicating with GDB using the 'file-I/O protocol', but the name is misleading
12 * as it can also perform functions not related to file (or console) I/O. The functions are generally
13 * POSIX compatible so for further details consult the appropriate reference for your operating system.
16 * While a request is in progress GDB will not respond to any notifications from the target - including debug output.
18 * All functions are implemented with an optional callback routine, which is essential when reading the
23 * @see https://sourceware.org/gdb/current/onlinedocs/gdb/File_002dI_002fO-Remote-Protocol-Extension.html
191 static inline int gdb_syscall_open(const char* filename, int flags, int mode, gdb_syscall_callback_t callback = nullptr,
209 static inline int gdb_syscall_close(int fd, gdb_syscall_callback_t callback = nullptr, void* param = nullptr)
226 static inline int gdb_syscall_read(int fd, void* buffer, size_t bufSize, gdb_syscall_callback_t callback = nullptr,
246 static inline int gdb_syscall_write(int fd, const void* buffer, size_t count, gdb_syscall_callback_t callback = nullptr,
266 static inline int gdb_syscall_lseek(int fd, long offset, int whence, gdb_syscall_callback_t callback = nullptr,
302 static inline int gdb_syscall_unlink(const char* pathname, gdb_syscall_callback_t callback = nullptr,
319 static inline int gdb_syscall_stat(const char* pathname, gdb_stat_t* buf, gdb_syscall_callback_t callback = nullptr,
337 static inline int gdb_syscall_fstat(int fd, struct gdb_stat_t* buf, gdb_syscall_callback_t callback = nullptr,
355 static inline int gdb_syscall_gettimeofday(gdb_timeval_t* tv, void* tz, gdb_syscall_callback_t callback = nullptr,
372 static inline int gdb_syscall_isatty(int fd, gdb_syscall_callback_t callback = nullptr, void* param = nullptr)
388 static inline int gdb_syscall_system(const char* command, gdb_syscall_callback_t callback = nullptr,
406 static inline int gdb_console_read(void* buffer, size_t bufSize, gdb_syscall_callback_t callback = nullptr,
420 static inline int gdb_console_write(const void* buffer, size_t count, gdb_syscall_callback_t callback = nullptr,
GDB uses a specific version of the timeval structure, 12 bytes in size (manual says 8...
Definition: gdb_syscall.h:69
struct GdbSyscallInfo::@3::@10 rename
static int gdb_syscall_unlink(const char *pathname, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Unlink/remove/delete a host file.
Definition: gdb_syscall.h:302
static int gdb_syscall_write(int fd, const void *buffer, size_t count, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Write data from a host file.
Definition: gdb_syscall.h:246
static int gdb_syscall_close(int fd, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Close a host file.
Definition: gdb_syscall.h:209
Definition: gdb_syscall.h:85
Definition: gdb_syscall.h:93
Definition: gdb_syscall.h:84
Definition: gdb_syscall.h:89
static int gdb_syscall_fstat(int fd, struct gdb_stat_t *buf, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Obtain information about a host file given its file handle.
Definition: gdb_syscall.h:337
struct GdbSyscallInfo::@3::@13 fstat
struct GdbSyscallInfo::@3::@16 system
static int gdb_syscall_rename(const char *oldpath, const char *newpath, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Rename a host file.
Definition: gdb_syscall.h:285
static int gdb_syscall_system(const char *command, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Invoke the 'system' command on the host.
Definition: gdb_syscall.h:388
struct GdbSyscallInfo::@3::@12 stat
struct GdbSyscallInfo::@3::@15 isatty
Definition: gdb_syscall.h:90
struct GdbSyscallInfo::@3::@14 gettimeofday
Definition: gdb_syscall.h:83
void * param
User-supplied parameter for callback.
Definition: gdb_syscall.h:110
int gdb_syscall(const GdbSyscallInfo &info)
Stub function to perform a syscall. Implemented by GDB stub.
void(* gdb_syscall_callback_t)(const GdbSyscallInfo &info)
GDB Syscall completion callback function.
Definition: gdb_syscall.h:102
Definition: gdb_syscall.h:91
struct GdbSyscallInfo::@3::@5 open
static int gdb_syscall_open(const char *filename, int flags, int mode, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Open a file on the host.
Definition: gdb_syscall.h:191
struct GdbSyscallInfo::@3::@9 lseek
static int gdb_syscall_isatty(int fd, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Determine if the given file handle refers to a console/tty.
Definition: gdb_syscall.h:372
GDB uses a specific version of the stat structure, 64 bytes in size.
Definition: gdb_syscall.h:50
static int gdb_syscall_read(int fd, void *buffer, size_t bufSize, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Read data from a host file.
Definition: gdb_syscall.h:226
struct GdbSyscallInfo::@3::@8 write
static int gdb_console_write(const void *buffer, size_t count, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Write text to the GDB console.
Definition: gdb_syscall.h:420
Definition: gdb_syscall.h:92
struct GdbSyscallInfo::@3::@6 close
struct GdbSyscallInfo::@3::@11 unlink
struct GdbSyscallInfo::@3::@7 read
static int gdb_console_read(void *buffer, size_t bufSize, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Read a line of text from the GDB console.
Definition: gdb_syscall.h:406
GdbSyscallCommand
Enumeration defining available commands.
Definition: gdb_syscall.h:81
Definition: gdb_syscall.h:82
gdb_syscall_callback_t callback
User-supplied callback (if any)
Definition: gdb_syscall.h:109
Definition: gdb_syscall.h:87
static int gdb_syscall_stat(const char *pathname, gdb_stat_t *buf, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Obtain information about a host file given its name/path.
Definition: gdb_syscall.h:319
Definition: gdb_syscall.h:86
static int gdb_syscall_gettimeofday(gdb_timeval_t *tv, void *tz, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Get current time of day from host, in UTC.
Definition: gdb_syscall.h:355
Definition: gdb_syscall.h:88
static int gdb_syscall_lseek(int fd, long offset, int whence, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Get/set current file pointer position in a host file.
Definition: gdb_syscall.h:266