summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/Process.cpp6
-rw-r--r--Kernel/Process.h1
-rw-r--r--Kernel/Syscall.cpp2
-rw-r--r--Kernel/Syscall.h3
-rw-r--r--Libraries/LibC/stdio.cpp19
-rw-r--r--Libraries/LibC/stdio.h2
6 files changed, 18 insertions, 15 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index e40ff1cae2..1a0e5ecbb2 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -2716,3 +2716,9 @@ int Process::sys$dump_backtrace()
dump_backtrace();
return 0;
}
+
+int Process::sys$dbgputch(u8 ch)
+{
+ IO::out8(0xe9, ch);
+ return 0;
+}
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 674b12f41f..eb603f9f77 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -104,6 +104,7 @@ public:
void die();
void finalize();
+ int sys$dbgputch(u8);
int sys$dump_backtrace();
int sys$gettid();
int sys$donate(int tid);
diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp
index 0512874e7a..d547f62b8b 100644
--- a/Kernel/Syscall.cpp
+++ b/Kernel/Syscall.cpp
@@ -70,6 +70,8 @@ static u32 handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3
case Syscall::SC_putch:
Console::the().put_char(arg1 & 0xff);
break;
+ case Syscall::SC_dbgputch:
+ return current->process().sys$dbgputch((u8)arg1);
case Syscall::SC_sleep:
return current->process().sys$sleep((unsigned)arg1);
case Syscall::SC_usleep:
diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h
index a20997eb9c..40a585a959 100644
--- a/Kernel/Syscall.h
+++ b/Kernel/Syscall.h
@@ -116,7 +116,8 @@ struct timeval;
__ENUMERATE_SYSCALL(fchown) \
__ENUMERATE_SYSCALL(halt) \
__ENUMERATE_SYSCALL(reboot) \
- __ENUMERATE_SYSCALL(dump_backtrace)
+ __ENUMERATE_SYSCALL(dump_backtrace) \
+ __ENUMERATE_SYSCALL(dbgputch)
namespace Syscall {
diff --git a/Libraries/LibC/stdio.cpp b/Libraries/LibC/stdio.cpp
index 82217fc990..2ce4a8ab5b 100644
--- a/Libraries/LibC/stdio.cpp
+++ b/Libraries/LibC/stdio.cpp
@@ -18,7 +18,6 @@ static FILE __default_streams[4];
FILE* stdin;
FILE* stdout;
FILE* stderr;
-FILE* stddbg;
void init_FILE(FILE& fp, int fd, int mode)
{
@@ -41,16 +40,9 @@ void __stdio_init()
stdin = &__default_streams[0];
stdout = &__default_streams[1];
stderr = &__default_streams[2];
- stddbg = &__default_streams[3];
init_FILE(*stdin, 0, isatty(0) ? _IOLBF : _IOFBF);
init_FILE(*stdout, 1, isatty(1) ? _IOLBF : _IOFBF);
init_FILE(*stderr, 2, _IONBF);
- int fd = open("/dev/debuglog", O_WRONLY | O_CLOEXEC);
- if (fd < 0) {
- perror("open /dev/debuglog");
- ASSERT_NOT_REACHED();
- }
- init_FILE(*stddbg, fd, _IOLBF);
}
int setvbuf(FILE* stream, char* buf, int mode, size_t size)
@@ -337,14 +329,10 @@ void rewind(FILE* stream)
int dbgprintf(const char* fmt, ...)
{
- // if this fails, you're printing too early.
- ASSERT(stddbg);
- int errno_backup = errno;
va_list ap;
va_start(ap, fmt);
- int ret = vfprintf(stddbg, fmt, ap);
+ int ret = printf_internal([](char*&, char ch) { dbgputch(ch); }, nullptr, fmt, ap);
va_end(ap);
- errno = errno_backup;
return ret;
}
@@ -495,6 +483,11 @@ int rename(const char* oldpath, const char* newpath)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
+void dbgputch(char ch)
+{
+ syscall(SC_dbgputch, ch);
+}
+
char* tmpnam(char*)
{
ASSERT_NOT_REACHED();
diff --git a/Libraries/LibC/stdio.h b/Libraries/LibC/stdio.h
index b1878b5fd8..dd166acf20 100644
--- a/Libraries/LibC/stdio.h
+++ b/Libraries/LibC/stdio.h
@@ -43,7 +43,6 @@ typedef struct __STDIO_FILE FILE;
extern FILE* stdin;
extern FILE* stdout;
extern FILE* stderr;
-extern FILE* stddbg;
typedef size_t fpos_t;
@@ -79,6 +78,7 @@ int vsnprintf(char* buffer, size_t, const char* fmt, va_list);
int fprintf(FILE*, const char* fmt, ...);
int printf(const char* fmt, ...);
int dbgprintf(const char* fmt, ...);
+void dbgputch(char);
int sprintf(char* buffer, const char* fmt, ...);
int snprintf(char* buffer, size_t, const char* fmt, ...);
int putchar(int ch);