mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
0718afa773
There are certain checks that we should skip if the system is crashing. The system can avoid stack overflow during crash, or even triple faulting while while handling issues that can causes recursive panics or aborts.
41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/Format.h>
|
|
#include <Kernel/Arch/x86/Processor.h>
|
|
#include <Kernel/CommandLine.h>
|
|
#include <Kernel/IO.h>
|
|
#include <Kernel/KSyms.h>
|
|
#include <Kernel/Panic.h>
|
|
#include <Kernel/Thread.h>
|
|
|
|
namespace Kernel {
|
|
|
|
[[noreturn]] static void __shutdown()
|
|
{
|
|
// Note: This will invoke QEMU Shutdown, but for other platforms (or emulators),
|
|
// this has no effect on the system, so we still need to halt afterwards.
|
|
// We also try the Bochs/Old QEMU shutdown method, if the first didn't work.
|
|
IO::out16(0x604, 0x2000);
|
|
IO::out16(0xb004, 0x2000);
|
|
Processor::halt();
|
|
}
|
|
|
|
void __panic(const char* file, unsigned int line, const char* function)
|
|
{
|
|
// Avoid lock ranking checks on crashing paths, just try to get some debugging messages out.
|
|
auto thread = Thread::current();
|
|
if (thread)
|
|
thread->set_crashing();
|
|
|
|
critical_dmesgln("at {}:{} in {}", file, line, function);
|
|
dump_backtrace(PrintToScreen::Yes);
|
|
if (kernel_command_line().boot_mode() == BootMode::SelfTest)
|
|
__shutdown();
|
|
else
|
|
Processor::halt();
|
|
}
|
|
}
|