diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a7073752..ad73febdd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,8 @@ option(ENABLE_CUBEB "Enables the cubeb audio backend" ON) option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF) +option(YUZU_NO_CPU_DEBUGGER "Do not build debugging code" OFF) + option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}") option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON) @@ -170,7 +172,7 @@ endif() option(ENABLE_OPENSSL "Enable OpenSSL backend for ISslConnection" ${DEFAULT_ENABLE_OPENSSL}) if (ANDROID AND YUZU_DOWNLOAD_ANDROID_VVL) - set(vvl_version "sdk-1.3.261.1") + set(vvl_version "1.4.304.1") set(vvl_zip_file "${CMAKE_BINARY_DIR}/externals/vvl-android.zip") set(vvl_lib_path "${CMAKE_CURRENT_SOURCE_DIR}/src/android/app/src/main/jniLibs/arm64-v8a/") diff --git a/build-for-android.md b/build-for-android.md index 887c6a0e5..f2d1724f4 100644 --- a/build-for-android.md +++ b/build-for-android.md @@ -44,9 +44,9 @@ https://developer.android.com/studio/intro ### Dependencies ``` sudo apt-get update -sudo apt-get install -y sdkmanager openjdk-17-jdk build-essential curl git pkg-config glslang-tools zip -sudo sdkmanager "ndk;26.3.11579264" "platforms;android-34" "build-tools;34.0.0" "cmake;3.22.1" "platform-tools;34.0.5" -sudo update-alternatives --config java # Select Java 17 here if possible +sudo apt-get install -y sdkmanager openjdk-21-jdk build-essential curl git pkg-config glslang-tools zip +sudo sdkmanager "ndk;26.3.11579264" "platforms;android-35" "build-tools;35.0.0" "cmake;3.22.1" "platform-tools;35.0.5" +sudo update-alternatives --config java # Select Java 21 here if possible ``` ### Cloning Yuzu with Git diff --git a/src/android/app/build.gradle.kts b/src/android/app/build.gradle.kts index 10a667630..6231a5a58 100644 --- a/src/android/app/build.gradle.kts +++ b/src/android/app/build.gradle.kts @@ -27,7 +27,7 @@ val autoVersion = (((System.currentTimeMillis() / 1000) - 1451606400) / 10).toIn android { namespace = "org.yuzu.yuzu_emu" - compileSdkVersion = "android-34" + compileSdkVersion = "android-35" ndkVersion = "26.3.11579264" buildFeatures { @@ -35,12 +35,12 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } kotlinOptions { - jvmTarget = "17" + jvmTarget = "21" } packaging { @@ -118,7 +118,6 @@ android { isDefault = true resValue("string", "app_name_suffixed", "yuzu Debug Release") signingConfig = signingConfigs.getByName("default") - isMinifyEnabled = true isDebuggable = true proguardFiles( getDefaultProguardFile("proguard-android.txt"), @@ -165,9 +164,10 @@ android { "-DENABLE_WEB_SERVICE=0", // Don't use telemetry "-DBUNDLE_SPEEX=ON", "-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work + "-DYUZU_NO_CPU_DEBUGGER=ON", + "-DYUZU_ENABLE_LTO=ON", "-DYUZU_USE_BUNDLED_VCPKG=ON", "-DYUZU_USE_BUNDLED_FFMPEG=ON", - "-DYUZU_ENABLE_LTO=ON", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" ) diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 849d8367c..454532f26 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -297,7 +297,9 @@ void EmulationSession::ShutdownEmulation() { // Shutdown the main emulated process if (m_load_result == Core::SystemResultStatus::Success) { +#ifndef YUZU_NO_CPU_DEBUGGER m_system.DetachDebugger(); +#endif m_system.ShutdownMainProcess(); m_detached_tasks.WaitForAllTasks(); m_load_result = Core::SystemResultStatus::ErrorNotInitialized; @@ -344,9 +346,11 @@ void EmulationSession::RunEmulation() { void(m_system.Run()); +#ifndef YUZU_NO_CPU_DEBUGGER if (m_system.DebuggerEnabled()) { m_system.InitializeDebugger(); } +#endif while (true) { { diff --git a/src/android/gradle.properties b/src/android/gradle.properties index 4fca1b576..8939809ce 100644 --- a/src/android/gradle.properties +++ b/src/android/gradle.properties @@ -17,4 +17,4 @@ kotlin.parallel.tasks.in.project=true android.defaults.buildfeatures.buildconfig=true # Android Gradle plugin 8.0.2 -android.suppressUnsupportedCompileSdk=34 +android.suppressUnsupportedCompileSdk=35 diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 7b26e604a..ea330fad3 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -30,13 +30,6 @@ add_library(core STATIC crypto/partition_data_manager.h crypto/xts_encryption_layer.cpp crypto/xts_encryption_layer.h - debugger/debugger.cpp - debugger/debugger.h - debugger/debugger_interface.h - debugger/gdbstub.cpp - debugger/gdbstub.h - debugger/gdbstub_arch.cpp - debugger/gdbstub_arch.h device_memory.cpp device_memory.h device_memory_manager.h @@ -1142,6 +1135,20 @@ add_library(core STATIC tools/renderdoc.h ) +if (YUZU_NO_CPU_DEBUGGER) + target_compile_definitions(core PUBLIC YUZU_NO_CPU_DEBUGGER) +else() + target_sources(core PRIVATE + debugger/debugger.cpp + debugger/debugger.h + debugger/debugger_interface.h + debugger/gdbstub.cpp + debugger/gdbstub.h + debugger/gdbstub_arch.cpp + debugger/gdbstub_arch.h + ) +endif() + if (MSVC) target_compile_options(core PRIVATE /we4245 # 'conversion': conversion from 'type1' to 'type2', signed/unsigned mismatch diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 35d34a0bc..5dce59b57 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -16,10 +16,15 @@ using namespace Common::Literals; class DynarmicCallbacks32 : public Dynarmic::A32::UserCallbacks { public: explicit DynarmicCallbacks32(ArmDynarmic32& parent, Kernel::KProcess* process) - : m_parent{parent}, m_memory(process->GetMemory()), - m_process(process), m_debugger_enabled{parent.m_system.DebuggerEnabled()}, - m_check_memory_access{m_debugger_enabled || - !Settings::values.cpuopt_ignore_memory_aborts.GetValue()} {} + : m_parent{parent} + , m_memory(process->GetMemory()) + , m_process(process) +#ifndef YUZU_NO_CPU_DEBUGGER + , m_debugger_enabled{parent.m_system.DebuggerEnabled()} +#endif + , m_check_memory_access{m_debugger_enabled + || !Settings::values.cpuopt_ignore_memory_aborts.GetValue()} + {} u8 MemoryRead8(u32 vaddr) override { CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Read); @@ -213,10 +218,12 @@ std::shared_ptr ArmDynarmic32::MakeJit(Common::PageTable* pa config.code_cache_size = 512_MiB; #endif +#ifndef YUZU_NO_CPU_DEBUGGER // Allow memory fault handling to work if (m_system.DebuggerEnabled()) { config.check_halt_on_memory_access = true; } +#endif // null_jit if (!page_table) { diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 3778cc91d..108db19fb 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -16,10 +16,18 @@ using namespace Common::Literals; class DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks { public: explicit DynarmicCallbacks64(ArmDynarmic64& parent, Kernel::KProcess* process) - : m_parent{parent}, m_memory(process->GetMemory()), - m_process(process), m_debugger_enabled{parent.m_system.DebuggerEnabled()}, - m_check_memory_access{m_debugger_enabled || - !Settings::values.cpuopt_ignore_memory_aborts.GetValue()} {} + : m_parent{parent} + , m_memory(process->GetMemory()) + , m_process(process) +#ifndef YUZU_NO_CPU_DEBUGGER + , m_debugger_enabled{parent.m_system.DebuggerEnabled()} +#endif + , m_check_memory_access{ +#ifndef YUZU_NO_CPU_DEBUGGER + m_debugger_enabled || +#endif + !Settings::values.cpuopt_ignore_memory_aborts.GetValue()} + {} u8 MemoryRead8(u64 vaddr) override { CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Read); @@ -139,10 +147,12 @@ public: ReturnException(pc, PrefetchAbort); return; default: +#ifndef YUZU_NO_CPU_DEBUGGER if (m_debugger_enabled) { ReturnException(pc, InstructionBreakpoint); return; } +#endif m_parent.LogBacktrace(m_process); LOG_CRITICAL(Core_ARM, "ExceptionRaised(exception = {}, pc = {:08X}, code = {:08X})", @@ -192,6 +202,7 @@ public: return false; } +#ifndef YUZU_NO_CPU_DEBUGGER if (!m_debugger_enabled) { return true; } @@ -202,6 +213,7 @@ public: m_parent.m_jit->HaltExecution(DataAbort); return false; } +#endif return true; } @@ -217,7 +229,9 @@ public: u64 m_tpidrro_el0{}; u64 m_tpidr_el0{}; Kernel::KProcess* m_process{}; +#ifndef YUZU_NO_CPU_DEBUGGER const bool m_debugger_enabled{}; +#endif const bool m_check_memory_access{}; static constexpr u64 MinimumRunCycles = 10000U; }; @@ -272,10 +286,12 @@ std::shared_ptr ArmDynarmic64::MakeJit(Common::PageTable* pa config.code_cache_size = 512_MiB; #endif +#ifndef YUZU_NO_CPU_DEBUGGER // Allow memory fault handling to work if (m_system.DebuggerEnabled()) { config.check_halt_on_memory_access = true; } +#endif // null_jit if (!page_table) { diff --git a/src/core/core.cpp b/src/core/core.cpp index c76bebe98..f1fa56851 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -256,9 +256,11 @@ struct System::Impl { return nvdec_active; } +#ifndef YUZU_NO_CPU_DEBUGGER void InitializeDebugger(System& system, u16 port) { debugger = std::make_unique(system, port); } +#endif void InitializeKernel(System& system) { LOG_DEBUG(Core, "initialized OK"); @@ -421,7 +423,9 @@ struct System::Impl { host1x_core.reset(); perf_stats.reset(); cpu_manager.Shutdown(); +#ifndef YUZU_NO_CPU_DEBUGGER debugger.reset(); +#endif kernel.Shutdown(); stop_event = {}; Network::RestartSocketOperations(); @@ -516,8 +520,10 @@ struct System::Impl { /// Network instance Network::NetworkInstance network_instance; +#ifndef YUZU_NO_CPU_DEBUGGER /// Debugger std::unique_ptr debugger; +#endif SystemResultStatus status = SystemResultStatus::Success; std::string status_details = ""; @@ -582,11 +588,13 @@ void System::SetShuttingDown(bool shutting_down) { impl->SetShuttingDown(shutting_down); } +#ifndef YUZU_NO_CPU_DEBUGGER void System::DetachDebugger() { if (impl->debugger) { impl->debugger->NotifyShutdown(); } } +#endif std::unique_lock System::StallApplication() { return impl->StallApplication(); @@ -604,9 +612,11 @@ bool System::GetNVDECActive() { return impl->GetNVDECActive(); } +#ifndef YUZU_NO_CPU_DEBUGGER void System::InitializeDebugger() { impl->InitializeDebugger(*this, Settings::values.gdbstub_port.GetValue()); } +#endif SystemResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath, Service::AM::FrontendAppletParameters& params) { @@ -927,6 +937,7 @@ bool System::IsMulticore() const { return impl->is_multicore; } +#ifndef YUZU_NO_CPU_DEBUGGER bool System::DebuggerEnabled() const { return Settings::values.use_gdbstub.GetValue(); } @@ -938,6 +949,7 @@ Core::Debugger& System::GetDebugger() { const Core::Debugger& System::GetDebugger() const { return *impl->debugger; } +#endif Network::RoomNetwork& System::GetRoomNetwork() { return impl->room_network; diff --git a/src/core/core.h b/src/core/core.h index a9c9df64d..34c6735d7 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -184,8 +184,10 @@ public: /// Set the shutting down state. void SetShuttingDown(bool shutting_down); +#ifndef YUZU_NO_CPU_DEBUGGER /// Forcibly detach the debugger if it is running. void DetachDebugger(); +#endif std::unique_lock StallApplication(); void UnstallApplication(); @@ -193,10 +195,12 @@ public: void SetNVDECActive(bool is_nvdec_active); [[nodiscard]] bool GetNVDECActive(); +#ifndef YUZU_NO_CPU_DEBUGGER /** * Initialize the debugger. */ void InitializeDebugger(); +#endif /** * Load an executable application. @@ -377,8 +381,10 @@ public: [[nodiscard]] Service::Account::ProfileManager& GetProfileManager(); [[nodiscard]] const Service::Account::ProfileManager& GetProfileManager() const; +#ifndef YUZU_NO_CPU_DEBUGGER [[nodiscard]] Core::Debugger& GetDebugger(); [[nodiscard]] const Core::Debugger& GetDebugger() const; +#endif /// Gets a mutable reference to the Room Network. [[nodiscard]] Network::RoomNetwork& GetRoomNetwork(); @@ -412,8 +418,10 @@ public: /// Tells if system is running on multicore. [[nodiscard]] bool IsMulticore() const; +#ifndef YUZU_NO_CPU_DEBUGGER /// Tells if the system debugger is enabled. [[nodiscard]] bool DebuggerEnabled() const; +#endif /// Runs a server instance until shutdown. void RunServer(std::unique_ptr&& server_manager); diff --git a/src/core/debugger/debugger.cpp b/src/core/debugger/debugger.cpp index af3f71c0d..d035ff83d 100644 --- a/src/core/debugger/debugger.cpp +++ b/src/core/debugger/debugger.cpp @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "core/debugger/debugger.h" + #include #include #include @@ -9,33 +11,34 @@ #include #include "common/logging/log.h" -#include "common/polyfill_thread.h" #include "common/thread.h" #include "core/core.h" -#include "core/debugger/debugger.h" #include "core/debugger/debugger_interface.h" #include "core/debugger/gdbstub.h" #include "core/hle/kernel/global_scheduler_context.h" #include "core/hle/kernel/k_process.h" #include "core/hle/kernel/k_scheduler.h" -template -static void AsyncReceiveInto(Readable& r, Buffer& buffer, Callback&& c) { +template +static void AsyncReceiveInto(Readable& r, Buffer& buffer, Callback&& c) +{ static_assert(std::is_trivial_v); auto boost_buffer{boost::asio::buffer(&buffer, sizeof(Buffer))}; - r.async_read_some( - boost_buffer, [&, c](const boost::system::error_code& error, size_t bytes_read) { - if (!error.failed()) { - const u8* buffer_start = reinterpret_cast(&buffer); - std::span received_data{buffer_start, buffer_start + bytes_read}; - c(received_data); - AsyncReceiveInto(r, buffer, c); - } - }); + r.async_read_some(boost_buffer, + [&, c](const boost::system::error_code& error, size_t bytes_read) { + if (!error.failed()) { + const u8* buffer_start = reinterpret_cast(&buffer); + std::span received_data{buffer_start, + buffer_start + bytes_read}; + c(received_data); + AsyncReceiveInto(r, buffer, c); + } + }); } -template -static void AsyncAccept(boost::asio::ip::tcp::acceptor& acceptor, Callback&& c) { +template +static void AsyncAccept(boost::asio::ip::tcp::acceptor& acceptor, Callback&& c) +{ acceptor.async_accept([&, c](const boost::system::error_code& error, auto&& peer_socket) { if (!error.failed()) { c(peer_socket); @@ -44,8 +47,9 @@ static void AsyncAccept(boost::asio::ip::tcp::acceptor& acceptor, Callback&& c) }); } -template -static std::span ReceiveInto(Readable& r, Buffer& buffer) { +template +static std::span ReceiveInto(Readable& r, Buffer& buffer) +{ static_assert(std::is_trivial_v); auto boost_buffer{boost::asio::buffer(&buffer, sizeof(Buffer))}; size_t bytes_read = r.read_some(boost_buffer); @@ -60,7 +64,8 @@ enum class SignalType { ShuttingDown, }; -struct SignalInfo { +struct SignalInfo +{ SignalType type; Kernel::KThread* thread; const Kernel::DebugWatchpoint* watchpoint; @@ -68,17 +73,19 @@ struct SignalInfo { namespace Core { -class DebuggerImpl : public DebuggerBackend { +class DebuggerImpl : public DebuggerBackend +{ public: - explicit DebuggerImpl(Core::System& system_, u16 port) : system{system_} { + explicit DebuggerImpl(Core::System& system_, u16 port) + : system{system_} + { InitializeServer(port); } - ~DebuggerImpl() override { - ShutdownServer(); - } + ~DebuggerImpl() override { ShutdownServer(); } - bool SignalDebugger(SignalInfo signal_info) { + bool SignalDebugger(SignalInfo signal_info) + { std::scoped_lock lk{connection_lock}; if (stopped || !state) { @@ -100,25 +107,24 @@ public: // These functions are callbacks from the frontend, and the lock will be held. // There is no need to relock it. - std::span ReadFromClient() override { + std::span ReadFromClient() override + { return ReceiveInto(state->client_socket, state->client_data); } - void WriteToClient(std::span data) override { + void WriteToClient(std::span data) override + { boost::asio::write(state->client_socket, boost::asio::buffer(data.data(), data.size_bytes())); } - void SetActiveThread(Kernel::KThread* thread) override { - state->active_thread = thread; - } + void SetActiveThread(Kernel::KThread* thread) override { state->active_thread = thread; } - Kernel::KThread* GetActiveThread() override { - return state->active_thread.GetPointerUnsafe(); - } + Kernel::KThread* GetActiveThread() override { return state->active_thread.GetPointerUnsafe(); } private: - void InitializeServer(u16 port) { + void InitializeServer(u16 port) + { using boost::asio::ip::tcp; LOG_INFO(Debug_GDBStub, "Starting server on port {}...", port); @@ -142,7 +148,8 @@ private: }); } - void AcceptConnection(boost::asio::ip::tcp::socket&& peer) { + void AcceptConnection(boost::asio::ip::tcp::socket&& peer) + { LOG_INFO(Debug_GDBStub, "Accepting new peer connection"); std::scoped_lock lk{connection_lock}; @@ -177,13 +184,15 @@ private: frontend->Connected(); } - void ShutdownServer() { + void ShutdownServer() + { connection_thread.request_stop(); io_context.stop(); connection_thread.join(); } - void PipeData(std::span data) { + void PipeData(std::span data) + { std::scoped_lock lk{connection_lock}; switch (state->info.type) { @@ -197,8 +206,7 @@ private: UpdateActiveThread(); if (state->info.type == SignalType::Watchpoint) { - frontend->Watchpoint(std::addressof(*state->active_thread), - *state->info.watchpoint); + frontend->Watchpoint(std::addressof(*state->active_thread), *state->info.watchpoint); } else { frontend->Stopped(std::addressof(*state->active_thread)); } @@ -220,7 +228,8 @@ private: } } - void ClientData(std::span data) { + void ClientData(std::span data) + { std::scoped_lock lk{connection_lock}; const auto actions{frontend->ClientData(data)}; @@ -262,7 +271,8 @@ private: } } - void PauseEmulation() { + void PauseEmulation() + { Kernel::KScopedLightLock ll{debug_process->GetListLock()}; Kernel::KScopedSchedulerLock sl{system.Kernel()}; @@ -272,7 +282,8 @@ private: } } - void ResumeEmulation(Kernel::KThread* except = nullptr) { + void ResumeEmulation(Kernel::KThread* except = nullptr) + { Kernel::KScopedLightLock ll{debug_process->GetListLock()}; Kernel::KScopedSchedulerLock sl{system.Kernel()}; @@ -287,13 +298,15 @@ private: } } - template - void MarkResumed(Callback&& cb) { + template + void MarkResumed(Callback&& cb) + { stopped = false; cb(); } - void UpdateActiveThread() { + void UpdateActiveThread() + { Kernel::KScopedLightLock ll{debug_process->GetListLock()}; auto& threads{ThreadList()}; @@ -307,13 +320,9 @@ private: } private: - void SetDebugProcess() { - debug_process = std::move(system.Kernel().GetProcessList().back()); - } + void SetDebugProcess() { debug_process = std::move(system.Kernel().GetProcessList().back()); } - Kernel::KProcess::ThreadList& ThreadList() { - return debug_process->GetThreadList(); - } + Kernel::KProcess::ThreadList& ThreadList() { return debug_process->GetThreadList(); } private: System& system; @@ -324,7 +333,8 @@ private: std::jthread connection_thread; std::mutex connection_lock; - struct ConnectionState { + struct ConnectionState + { boost::asio::ip::tcp::socket client_socket; boost::process::v1::async_pipe signal_pipe; @@ -338,7 +348,8 @@ private: bool stopped{}; }; -Debugger::Debugger(Core::System& system, u16 port) { +Debugger::Debugger(Core::System& system, u16 port) +{ try { impl = std::make_unique(system, port); } catch (const std::exception& ex) { @@ -348,16 +359,18 @@ Debugger::Debugger(Core::System& system, u16 port) { Debugger::~Debugger() = default; -bool Debugger::NotifyThreadStopped(Kernel::KThread* thread) { +bool Debugger::NotifyThreadStopped(Kernel::KThread* thread) +{ return impl && impl->SignalDebugger(SignalInfo{SignalType::Stopped, thread, nullptr}); } -bool Debugger::NotifyThreadWatchpoint(Kernel::KThread* thread, - const Kernel::DebugWatchpoint& watch) { +bool Debugger::NotifyThreadWatchpoint(Kernel::KThread* thread, const Kernel::DebugWatchpoint& watch) +{ return impl && impl->SignalDebugger(SignalInfo{SignalType::Watchpoint, thread, &watch}); } -void Debugger::NotifyShutdown() { +void Debugger::NotifyShutdown() +{ if (impl) { impl->SignalDebugger(SignalInfo{SignalType::ShuttingDown, nullptr, nullptr}); } diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index 80566b7e7..aad7fcb21 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp @@ -992,10 +992,12 @@ Result KProcess::Run(s32 priority, size_t stack_size) { this->ChangeState(state); }; +#ifndef YUZU_NO_CPU_DEBUGGER // Suspend for debug, if we should. if (m_kernel.System().DebuggerEnabled()) { main_thread->RequestSuspend(SuspendType::Debug); } +#endif // Run our thread. R_TRY(main_thread->Run()); diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index 0f45a3249..7439b043d 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp @@ -71,7 +71,9 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) { // Notify the debugger and go to sleep if a step was performed // and this thread has been scheduled again. if (thread->GetStepState() == StepState::StepPerformed) { +#ifndef YUZU_NO_CPU_DEBUGGER system.GetDebugger().NotifyThreadStopped(thread); +#endif thread->RequestSuspend(SuspendType::Debug); return; } @@ -113,20 +115,23 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) { if (breakpoint) { interface->RewindBreakpointInstruction(); } +#ifndef YUZU_NO_CPU_DEBUGGER if (system.DebuggerEnabled()) { system.GetDebugger().NotifyThreadStopped(thread); - } else { + } else +#endif interface->LogBacktrace(process); - } thread->RequestSuspend(SuspendType::Debug); return; } // Notify the debugger and go to sleep on data abort. if (data_abort) { +#ifndef YUZU_NO_CPU_DEBUGGER if (system.DebuggerEnabled()) { system.GetDebugger().NotifyThreadWatchpoint(thread, *interface->HaltedWatchpoint()); } +#endif thread->RequestSuspend(SuspendType::Debug); return; } diff --git a/src/core/hle/kernel/svc/svc_exception.cpp b/src/core/hle/kernel/svc/svc_exception.cpp index 47b756828..ee4715fe1 100644 --- a/src/core/hle/kernel/svc/svc_exception.cpp +++ b/src/core/hle/kernel/svc/svc_exception.cpp @@ -2,7 +2,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "core/core.h" +#ifndef YUZU_NO_CPU_DEBUGGER #include "core/debugger/debugger.h" +#endif #include "core/hle/kernel/k_process.h" #include "core/hle/kernel/k_thread.h" #include "core/hle/kernel/svc.h" @@ -106,6 +108,7 @@ void Break(Core::System& system, BreakReason reason, u64 info1, u64 info2) { system.CurrentPhysicalCore().LogBacktrace(); } +#ifndef YUZU_NO_CPU_DEBUGGER const bool is_hbl = GetCurrentProcess(system.Kernel()).IsHbl(); const bool should_break = is_hbl || !notification_only; @@ -114,6 +117,7 @@ void Break(Core::System& system, BreakReason reason, u64 info1, u64 info2) { system.GetDebugger().NotifyThreadStopped(thread); thread->RequestSuspend(Kernel::SuspendType::Debug); } +#endif } void ReturnFromException(Core::System& system, Result result) { diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index ed5750155..aa671c5d6 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -100,9 +100,11 @@ void EmuThread::run() { m_system.GetCpuManager().OnGpuReady(); +#ifndef YUZU_NO_CPU_DEBUGGER if (m_system.DebuggerEnabled()) { m_system.InitializeDebugger(); } +#endif while (!stop_token.stop_requested()) { std::unique_lock lk{m_should_run_mutex}; @@ -122,7 +124,9 @@ void EmuThread::run() { } // Shutdown the main emulated process +#ifndef YUZU_NO_CPU_DEBUGGER m_system.DetachDebugger(); +#endif m_system.ShutdownMainProcess(); #if MICROPROFILE_ENABLED diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index 469a33079..c4be91cf8 100644 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -19,9 +19,14 @@ ConfigureDebug::ConfigureDebug(const Core::System& system_, QWidget* parent) ui->setupUi(this); SetConfiguration(); +#ifdef YUZU_NO_CPU_DEBUGGER + ui->cpu_debug_box->setEnabled(false); + ui->toggle_gdbstub->setCheckState(Qt::Unchecked); +#endif + connect(ui->open_log_button, &QPushButton::clicked, []() { - const auto path = - QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::LogDir)); + const auto path = QString::fromStdString( + Common::FS::GetYuzuPathString(Common::FS::YuzuPath::LogDir)); QDesktopServices::openUrl(QUrl::fromLocalFile(path)); }); diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui index d842b0135..29fffbe1e 100644 --- a/src/yuzu/configuration/configure_debug.ui +++ b/src/yuzu/configuration/configure_debug.ui @@ -18,8 +18,8 @@ 0 0 - 842 - 741 + 829 + 758 @@ -29,7 +29,7 @@ 0 - + 0 @@ -40,7 +40,7 @@ Debugger - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop false @@ -59,7 +59,7 @@ - QLayout::SetDefaultConstraint + QLayout::SizeConstraint::SetDefaultConstraint 0 @@ -355,10 +355,10 @@ - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Preferred + QSizePolicy::Policy::Preferred @@ -452,10 +452,10 @@ - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Expanding + QSizePolicy::Policy::Expanding @@ -501,10 +501,10 @@ - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Expanding + QSizePolicy::Policy::Expanding @@ -522,7 +522,7 @@ - Qt::Vertical + Qt::Orientation::Vertical diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 51a10a3e7..69e47c6e0 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -2076,9 +2076,12 @@ bool GMainWindow::OnShutdownBegin() { int shutdown_time = 1000; +#ifndef YUZU_NO_CPU_DEBUGGER if (system->DebuggerEnabled()) { shutdown_time = 0; - } else if (system->GetExitLocked()) { + } else +#endif + if (system->GetExitLocked()) { shutdown_time = 5000; } diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index e195fdf6e..0f3b0232e 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -436,13 +436,17 @@ int main(int argc, char** argv) { #endif void(system.Run()); +#ifndef YUZU_NO_CPU_DEBUGGER if (system.DebuggerEnabled()) { system.InitializeDebugger(); } +#endif while (emu_window->IsOpen()) { emu_window->WaitEvent(); } +#ifndef YUZU_NO_CPU_DEBUGGER system.DetachDebugger(); +#endif void(system.Pause()); system.ShutdownMainProcess(); diff --git a/vcpkg.json b/vcpkg.json index 6cc090ada..caa237296 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -16,7 +16,10 @@ "boost-icl", "boost-intrusive", "boost-mpl", - "boost-process", + { + "name": "boost-process", + "platform": "!android" + }, "boost-range", "boost-spirit", "boost-test", @@ -48,6 +51,10 @@ { "name": "oboe", "platform": "android" + }, + { + "name": "boost-fiber", + "platform": "android" } ] }