2020-07-31 00:38:15 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-31 00:38:15 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Kernel/KSyms.h>
|
|
|
|
#include <Kernel/Process.h>
|
2020-09-12 06:11:07 +03:00
|
|
|
#include <Kernel/UserOrKernelBuffer.h>
|
2021-06-23 18:55:08 +03:00
|
|
|
#include <Kernel/kstdio.h>
|
2020-07-31 00:38:15 +03:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2021-06-28 21:59:35 +03:00
|
|
|
KResultOr<FlatPtr> Process::sys$dump_backtrace()
|
2020-07-31 00:38:15 +03:00
|
|
|
{
|
|
|
|
dump_backtrace();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-28 21:59:35 +03:00
|
|
|
KResultOr<FlatPtr> Process::sys$dbgputch(u8 ch)
|
2020-07-31 00:38:15 +03:00
|
|
|
{
|
2021-06-23 18:55:08 +03:00
|
|
|
dbgputch(ch);
|
2020-07-31 00:38:15 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-28 21:59:35 +03:00
|
|
|
KResultOr<FlatPtr> Process::sys$dbgputstr(Userspace<const u8*> characters, size_t size)
|
2020-07-31 00:38:15 +03:00
|
|
|
{
|
2021-06-23 18:55:08 +03:00
|
|
|
if (size == 0)
|
2020-07-31 00:38:15 +03:00
|
|
|
return 0;
|
2020-09-12 06:11:07 +03:00
|
|
|
|
2021-06-27 11:46:47 +03:00
|
|
|
if (size <= 1024) {
|
|
|
|
char buffer[1024];
|
|
|
|
if (!copy_from_user(buffer, characters, size))
|
|
|
|
return EFAULT;
|
|
|
|
dbgputstr(buffer, size);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2021-06-23 18:55:08 +03:00
|
|
|
auto result = try_copy_kstring_from_user(reinterpret_cast<char const*>(characters.unsafe_userspace_ptr()), size);
|
|
|
|
if (result.is_error())
|
|
|
|
return result.error();
|
2021-06-27 11:46:47 +03:00
|
|
|
dbgputstr(result.value()->characters(), size);
|
2021-06-23 18:55:08 +03:00
|
|
|
return size;
|
2020-07-31 00:38:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|