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
192 static inline int gdb_syscall_open(const char* filename, int flags, int mode, gdb_syscall_callback_t callback = nullptr,
210 static inline int gdb_syscall_close(int fd, gdb_syscall_callback_t callback = nullptr, void* param = nullptr)
227 static inline int gdb_syscall_read(int fd, void* buffer, size_t bufSize, gdb_syscall_callback_t callback = nullptr,
247 static inline int gdb_syscall_write(int fd, const void* buffer, size_t count, gdb_syscall_callback_t callback = nullptr,
267 static inline int gdb_syscall_lseek(int fd, long offset, int whence, gdb_syscall_callback_t callback = nullptr,
303 static inline int gdb_syscall_unlink(const char* pathname, gdb_syscall_callback_t callback = nullptr,
320 static inline int gdb_syscall_stat(const char* pathname, gdb_stat_t* buf, gdb_syscall_callback_t callback = nullptr,
338 static inline int gdb_syscall_fstat(int fd, struct gdb_stat_t* buf, gdb_syscall_callback_t callback = nullptr,
356 static inline int gdb_syscall_gettimeofday(gdb_timeval_t* tv, void* tz, gdb_syscall_callback_t callback = nullptr,
373 static inline int gdb_syscall_isatty(int fd, gdb_syscall_callback_t callback = nullptr, void* param = nullptr)
389 static inline int gdb_syscall_system(const char* command, gdb_syscall_callback_t callback = nullptr,
407 static inline int gdb_console_read(void* buffer, size_t bufSize, gdb_syscall_callback_t callback = nullptr,
421 static inline int gdb_console_write(const void* buffer, size_t count, gdb_syscall_callback_t callback = nullptr,
int gdb_syscall(const GdbSyscallInfo &info)
Stub function to perform a syscall. Implemented by GDB stub.
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:286
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:421
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:320
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:373
GdbSyscallCommand
Enumeration defining available commands.
Definition: gdb_syscall.h:82
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:267
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:192
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:407
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:247
static int gdb_syscall_close(int fd, gdb_syscall_callback_t callback=nullptr, void *param=nullptr)
Close a host file.
Definition: gdb_syscall.h:210
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:303
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:389
void(*)(const GdbSyscallInfo &info) gdb_syscall_callback_t
GDB Syscall completion callback function.
Definition: gdb_syscall.h:103
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:356
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:338
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:227
struct GdbSyscallInfo::@4::@9 write
struct GdbSyscallInfo::@4::@12 unlink
struct GdbSyscallInfo::@4::@8 read
struct GdbSyscallInfo::@4::@11 rename
struct GdbSyscallInfo::@4::@13 stat
struct GdbSyscallInfo::@4::@6 open
gdb_syscall_callback_t callback
User-supplied callback (if any)
Definition: gdb_syscall.h:110
struct GdbSyscallInfo::@4::@7 close
struct GdbSyscallInfo::@4::@16 isatty
struct GdbSyscallInfo::@4::@17 system
struct GdbSyscallInfo::@4::@14 fstat
struct GdbSyscallInfo::@4::@10 lseek
struct GdbSyscallInfo::@4::@15 gettimeofday
GDB uses a specific version of the stat structure, 64 bytes in size.
Definition: gdb_syscall.h:51
GDB uses a specific version of the timeval structure, 12 bytes in size (manual says 8,...
Definition: gdb_syscall.h:70