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