Skip to content

Commit ed76746

Browse files
TuxSHWinterMute
authored andcommitted
Implement Luma3DS gdb hio (#433)
1 parent 754c334 commit ed76746

5 files changed

Lines changed: 721 additions & 0 deletions

File tree

libctru/include/3ds.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ extern "C" {
9191
#include <3ds/font.h>
9292
#include <3ds/mii.h>
9393

94+
#include <3ds/gdbhio_dev.h>
95+
9496
#ifdef __cplusplus
9597
}
9698
#endif

libctru/include/3ds/gdbhio.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @file gdbhio.h
3+
* @brief Luma3DS GDB HIO (called File I/O in GDB documentation) functions.
4+
*/
5+
6+
#pragma once
7+
8+
#include <fcntl.h>
9+
#include <sys/time.h>
10+
#include <sys/stat.h>
11+
12+
#define GDBHIO_STDIN_FILENO 0
13+
#define GDBHIO_STDOUT_FILENO 1
14+
#define GDBHIO_STDERR_FILENO 2
15+
16+
int gdbHioOpen(const char *pathname, int flags, mode_t mode);
17+
int gdbHioClose(int fd);
18+
int gdbHioRead(int fd, void *buf, unsigned int count);
19+
int gdbHioWrite(int fd, const void *buf, unsigned int count);
20+
off_t gdbHioLseek(int fd, off_t offset, int flag);
21+
int gdbHioRename(const char *oldpath, const char *newpath);
22+
int gdbHioUnlink(const char *pathname);
23+
int gdbHioStat(const char *pathname, struct stat *st);
24+
int gdbHioFstat(int fd, struct stat *st);
25+
int gdbHioGettimeofday(struct timeval *tv, void *tz);
26+
int gdbHioIsatty(int fd);
27+
28+
///< Host I/O 'system' function, requires 'set remote system-call-allowed 1'.
29+
int gdbHioSystem(const char *command);

libctru/include/3ds/gdbhio_dev.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @file gdbhio_dev.h
3+
* @brief Luma3DS GDB HIO (called File I/O in GDB documentation) devoptab wrapper.
4+
*/
5+
6+
#pragma once
7+
8+
#include <stdbool.h>
9+
10+
struct timeval;
11+
12+
///< Initializes the GDB HIO devoptab wrapper, returns 0 on success, -1 on failure.
13+
int gdbHioDevInit(void);
14+
15+
///< Deinitializes the GDB HIO devoptab wrapper.
16+
void gdbHioDevExit(void);
17+
18+
///< Returns a file descriptor mapping to the GDB client console's standard input stream.
19+
int gdbHioDevGetStdin(void);
20+
21+
///< Returns a file descriptor mapping to the GDB client console's standard output stream.
22+
int gdbHioDevGetStdout(void);
23+
24+
///< Returns a file descriptor mapping to the GDB client console's standard error stream.
25+
int gdbHioDevGetStderr(void);
26+
27+
///< 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.
28+
int gdbHioDevRedirectStdStreams(bool in, bool out, bool err);
29+
30+
///< GDB HIO POSIX function gettimeofday.
31+
int gdbHioDevGettimeofday(struct timeval *tv, void *tz);
32+
33+
///< GDB HIO POSIX function isatty.
34+
int gdbHioDevIsatty(int fd);
35+
36+
///< GDB HIO POSIX function system. Requires 'set remote system-call-allowed 1'.
37+
int gdbHioDevSystem(const char *command);

0 commit comments

Comments
 (0)