2020-07-30 18:38:15 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-30 18:38:15 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <Kernel/KSyms.h>
|
|
|
|
|
#include <Kernel/Process.h>
|
2020-09-12 00:11:07 -03:00
|
|
|
#include <Kernel/UserOrKernelBuffer.h>
|
2021-06-23 12:55:08 -03:00
|
|
|
#include <Kernel/kstdio.h>
|
2020-07-30 18:38:15 -03:00
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
2021-06-28 15:59:35 -03:00
|
|
|
KResultOr<FlatPtr> Process::sys$dump_backtrace()
|
2020-07-30 18:38:15 -03:00
|
|
|
{
|
2021-08-06 08:27:26 -03:00
|
|
|
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
2020-07-30 18:38:15 -03:00
|
|
|
dump_backtrace();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-28 15:59:35 -03:00
|
|
|
KResultOr<FlatPtr> Process::sys$dbgputch(u8 ch)
|
2020-07-30 18:38:15 -03:00
|
|
|
{
|
2021-08-06 08:39:16 -03:00
|
|
|
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
2021-06-23 12:55:08 -03:00
|
|
|
dbgputch(ch);
|
2020-07-30 18:38:15 -03:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-13 01:41:11 -03:00
|
|
|
KResultOr<FlatPtr> Process::sys$dbgputstr(Userspace<const char*> characters, size_t size)
|
2020-07-30 18:38:15 -03:00
|
|
|
{
|
2021-08-06 08:33:14 -03:00
|
|
|
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
2021-06-23 12:55:08 -03:00
|
|
|
if (size == 0)
|
2020-07-30 18:38:15 -03:00
|
|
|
return 0;
|
2020-09-12 00:11:07 -03:00
|
|
|
|
2021-06-27 05:46:47 -03:00
|
|
|
if (size <= 1024) {
|
|
|
|
|
char buffer[1024];
|
2021-09-05 12:38:37 -03:00
|
|
|
TRY(copy_from_user(buffer, characters, size));
|
2021-06-27 05:46:47 -03:00
|
|
|
dbgputstr(buffer, size);
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-05 13:01:55 -03:00
|
|
|
auto string = TRY(try_copy_kstring_from_user(characters, size));
|
2021-08-13 02:11:06 -03:00
|
|
|
dbgputstr(string->view());
|
|
|
|
|
return string->length();
|
2020-07-30 18:38:15 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|