mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 01:41:59 -05:00
Kernel+LibC: Add a dbgputstr() syscall for sending strings to debug output.
This is very handy for the DebugLogStream implementation, among others. :^)
This commit is contained in:
parent
0ef13e60b0
commit
af81645a2a
10 changed files with 33 additions and 4 deletions
|
@ -79,8 +79,7 @@ public:
|
|||
|
||||
virtual void write(const char* characters, int length) const override
|
||||
{
|
||||
for (int i = 0; i < length; ++i)
|
||||
dbgprintf("%c", characters[i]);
|
||||
dbgputstr(characters, length);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -6,4 +6,5 @@
|
|||
#include <stdio.h>
|
||||
#define kprintf printf
|
||||
#define dbgprintf printf
|
||||
#define dbgputstr(characters, length) fwrite(characters, 1, length, stdout)
|
||||
#endif
|
||||
|
|
|
@ -2722,3 +2722,12 @@ int Process::sys$dbgputch(u8 ch)
|
|||
IO::out8(0xe9, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$dbgputstr(const u8* characters, int length)
|
||||
{
|
||||
if (!validate_read(characters, length))
|
||||
return -EFAULT;
|
||||
for (int i = 0; i < length; ++i)
|
||||
IO::out8(0xe9, characters[i]);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ public:
|
|||
void finalize();
|
||||
|
||||
int sys$dbgputch(u8);
|
||||
int sys$dbgputstr(const u8*, int length);
|
||||
int sys$dump_backtrace();
|
||||
int sys$gettid();
|
||||
int sys$donate(int tid);
|
||||
|
|
|
@ -72,6 +72,8 @@ static u32 handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3
|
|||
break;
|
||||
case Syscall::SC_dbgputch:
|
||||
return current->process().sys$dbgputch((u8)arg1);
|
||||
case Syscall::SC_dbgputstr:
|
||||
return current->process().sys$dbgputstr((const u8*)arg1, (int)arg2);
|
||||
case Syscall::SC_sleep:
|
||||
return current->process().sys$sleep((unsigned)arg1);
|
||||
case Syscall::SC_usleep:
|
||||
|
|
|
@ -117,7 +117,8 @@ struct timeval;
|
|||
__ENUMERATE_SYSCALL(halt) \
|
||||
__ENUMERATE_SYSCALL(reboot) \
|
||||
__ENUMERATE_SYSCALL(dump_backtrace) \
|
||||
__ENUMERATE_SYSCALL(dbgputch)
|
||||
__ENUMERATE_SYSCALL(dbgputch) \
|
||||
__ENUMERATE_SYSCALL(dbgputstr)
|
||||
|
||||
namespace Syscall {
|
||||
|
||||
|
|
|
@ -57,12 +57,18 @@ int ksprintf(char* buffer, const char* fmt, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
extern "C" int dbgputstr(const char* characters, int length)
|
||||
{
|
||||
for (int i = 0; i < length; ++i)
|
||||
IO::out8(0xe9, characters[i]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void debugger_putch(char*&, char ch)
|
||||
{
|
||||
IO::out8(0xe9, ch);
|
||||
}
|
||||
|
||||
|
||||
extern "C" int dbgprintf(const char* fmt, ...)
|
||||
{
|
||||
color_on();
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Types.h>
|
||||
|
||||
extern "C" {
|
||||
int dbgprintf(const char* fmt, ...);
|
||||
int dbgputstr(const char*, int);
|
||||
int kprintf(const char* fmt, ...);
|
||||
int ksprintf(char* buf, const char* fmt, ...);
|
||||
}
|
||||
|
|
|
@ -488,6 +488,12 @@ void dbgputch(char ch)
|
|||
syscall(SC_dbgputch, ch);
|
||||
}
|
||||
|
||||
int dbgputstr(const char* characters, int length)
|
||||
{
|
||||
int rc = syscall(SC_dbgputstr, characters, length);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
char* tmpnam(char*)
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
|
|
|
@ -79,6 +79,7 @@ int fprintf(FILE*, const char* fmt, ...);
|
|||
int printf(const char* fmt, ...);
|
||||
int dbgprintf(const char* fmt, ...);
|
||||
void dbgputch(char);
|
||||
int dbgputstr(const char*, ssize_t);
|
||||
int sprintf(char* buffer, const char* fmt, ...);
|
||||
int snprintf(char* buffer, size_t, const char* fmt, ...);
|
||||
int putchar(int ch);
|
||||
|
|
Loading…
Reference in a new issue