Seregon/ShadPKG

A tool for deriving PKG packet encryption keys for ps4 written in c++

C++/47.3 KB/No license
common/assert.cpp
ShadPKG / common / assert.cpp
1// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3 
4#include "common/arch.h"
5#include "common/assert.h"
6#include "common/logging/backend.h"
7 
8#if defined(_MSC_VER)
9#define Crash() __debugbreak()
10#elif defined(ARCH_X86_64)
11#define Crash() __asm__ __volatile__("int $3")
12#elif defined(ARCH_ARM64)
13#define Crash() __asm__ __volatile__("brk 0")
14#else
15#error "Missing Crash() implementation for target CPU architecture."
16#endif
17 
18void assert_fail_impl() {
19 Common::Log::Stop();
20 std::fflush(stdout);
21 Crash();
22}
23 
24[[noreturn]] void unreachable_impl() {
25 Common::Log::Stop();
26 std::fflush(stdout);
27 Crash();
28 throw std::runtime_error("Unreachable code");
29}
30 
31void assert_fail_debug_msg(const char* msg) {
32 LOG_CRITICAL(Debug, "Assertion Failed!\n{}", msg);
33 assert_fail_impl();
34}
35