Skip to content

Commit

Permalink
Implement Luma3DS gdb hio (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
TuxSH authored and WinterMute committed Jun 23, 2019
1 parent 754c334 commit ed76746
Show file tree
Hide file tree
Showing 5 changed files with 721 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libctru/include/3ds.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ extern "C" {
#include <3ds/font.h>
#include <3ds/mii.h>

#include <3ds/gdbhio_dev.h>

#ifdef __cplusplus
}
#endif
Expand Down
29 changes: 29 additions & 0 deletions libctru/include/3ds/gdbhio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @file gdbhio.h
* @brief Luma3DS GDB HIO (called File I/O in GDB documentation) functions.
*/

#pragma once

#include <fcntl.h>
#include <sys/time.h>
#include <sys/stat.h>

#define GDBHIO_STDIN_FILENO 0
#define GDBHIO_STDOUT_FILENO 1
#define GDBHIO_STDERR_FILENO 2

int gdbHioOpen(const char *pathname, int flags, mode_t mode);
int gdbHioClose(int fd);
int gdbHioRead(int fd, void *buf, unsigned int count);
int gdbHioWrite(int fd, const void *buf, unsigned int count);
off_t gdbHioLseek(int fd, off_t offset, int flag);
int gdbHioRename(const char *oldpath, const char *newpath);
int gdbHioUnlink(const char *pathname);
int gdbHioStat(const char *pathname, struct stat *st);
int gdbHioFstat(int fd, struct stat *st);
int gdbHioGettimeofday(struct timeval *tv, void *tz);
int gdbHioIsatty(int fd);

///< Host I/O 'system' function, requires 'set remote system-call-allowed 1'.
int gdbHioSystem(const char *command);
37 changes: 37 additions & 0 deletions libctru/include/3ds/gdbhio_dev.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @file gdbhio_dev.h
* @brief Luma3DS GDB HIO (called File I/O in GDB documentation) devoptab wrapper.
*/

#pragma once

#include <stdbool.h>

struct timeval;

///< Initializes the GDB HIO devoptab wrapper, returns 0 on success, -1 on failure.
int gdbHioDevInit(void);

///< Deinitializes the GDB HIO devoptab wrapper.
void gdbHioDevExit(void);

///< Returns a file descriptor mapping to the GDB client console's standard input stream.
int gdbHioDevGetStdin(void);

///< Returns a file descriptor mapping to the GDB client console's standard output stream.
int gdbHioDevGetStdout(void);

///< Returns a file descriptor mapping to the GDB client console's standard error stream.
int gdbHioDevGetStderr(void);

///< Redirects 0 to 3 of the application's standard streams to GDB client console's. Returns -1, -2, or -3, resp., on failure; 0 on success.
int gdbHioDevRedirectStdStreams(bool in, bool out, bool err);

///< GDB HIO POSIX function gettimeofday.
int gdbHioDevGettimeofday(struct timeval *tv, void *tz);

///< GDB HIO POSIX function isatty.
int gdbHioDevIsatty(int fd);

///< GDB HIO POSIX function system. Requires 'set remote system-call-allowed 1'.
int gdbHioDevSystem(const char *command);
Loading

0 comments on commit ed76746

Please sign in to comment.