mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-07 03:32:53 +00:00
This rewrites the dbgputch and dbgputstr system calls as wrappers of kstdio.h. This fixes a bug where only the Kernel's debug output was also sent to a serial debugger, while the userspace's debug output was only sent to the Bochs debugger. This also fixes a bug where debug output from one process would sometimes "interrupt" the debug output from another process in the middle of a line.
38 lines
832 B
C++
38 lines
832 B
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/KSyms.h>
|
|
#include <Kernel/Process.h>
|
|
#include <Kernel/UserOrKernelBuffer.h>
|
|
#include <Kernel/kstdio.h>
|
|
|
|
namespace Kernel {
|
|
|
|
KResultOr<int> Process::sys$dump_backtrace()
|
|
{
|
|
dump_backtrace();
|
|
return 0;
|
|
}
|
|
|
|
KResultOr<int> Process::sys$dbgputch(u8 ch)
|
|
{
|
|
dbgputch(ch);
|
|
return 0;
|
|
}
|
|
|
|
KResultOr<size_t> Process::sys$dbgputstr(Userspace<const u8*> characters, size_t size)
|
|
{
|
|
if (size == 0)
|
|
return 0;
|
|
|
|
auto result = try_copy_kstring_from_user(reinterpret_cast<char const*>(characters.unsafe_userspace_ptr()), size);
|
|
if (result.is_error())
|
|
return result.error();
|
|
dbgputstr(reinterpret_cast<const char*>(result.value()->characters()), size);
|
|
return size;
|
|
}
|
|
|
|
}
|