12 Commits

Author SHA1 Message Date
spectranator
945de31fb9 Removed unusued and duplicate YUZU_NO_PRECOMPILED_HEADERS 2025-04-16 21:51:17 +02:00
spectranator
634acab40b Update some Android dependencies and fix build by making boost-process optional (#120)
Based on #119

Co-authored-by: Ramiro <ramiro.depaoli@gmail.com>
Co-authored-by: spectranator <spectranator@y2nlvhmmk5jnsvechppxnbyzmmv3vbl7dvzn6ltwcdbpgxixp3clkgqd.onion>
Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/120
2025-04-16 19:47:40 +00:00
spectranator
8561b75518 Replaced shasum with perl in Arch Linux package dependency list as shasum doesn't exist anymore 2025-04-13 22:49:56 +00:00
spectranator
15d00322a0 In containerized AppImage build script, actually install all required boost components 2025-04-13 19:53:19 +02:00
spectranator
7bd0bfbb0c Do not attempt to find boost in dynarmic if its target already exists 2025-04-13 17:45:01 +02:00
spectranator
829fad8b66 Updated vcpkg baseline for updated Boost library 2025-04-13 14:59:01 +00:00
spectranator
b539eef054 Updated revert list with previous commit 2025-04-13 16:11:38 +02:00
spectranator
f7849077e1 Removed Git SCM string anonymization as it's proven quite useless and hindering in understanding bug report 2025-04-13 16:10:03 +02:00
spectranator
35f4aa964f Fixed about dialog window being too small for content 2025-04-13 16:01:45 +02:00
spectranator
5b478bdb9c Link against all required Boost components 2025-04-13 13:05:27 +02:00
spectranator
b10bcac0cf Added loose snippets for Windows build on Linux guide 2025-04-13 00:21:17 +00:00
spectranator
cfbaa32d66 Updated minimum Boost version in Linux build guide 2025-04-13 00:14:42 +00:00
29 changed files with 251 additions and 177 deletions

View File

@@ -25,7 +25,7 @@ if [ ! "$BUILD_USE_CPM" = 1 ]; then
tar xf boost_1_88_0.tar.bz2
cd boost_1_88_0
./bootstrap.sh
./b2 install --with-{headers,context} link=static
./b2 install --with-{headers,context,system,fiber,atomic,filesystem} link=static
cd ..
rm -rf boost_1_88_0 boost_1_88_0.tar.bz2
fi

View File

@@ -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)
@@ -85,18 +87,10 @@ option(YUZU_ENABLE_PORTABLE "Allow yuzu to enable portable mode if a user folder
option(YUZU_USE_LLVM_DEMANGLE "Use LLVM Demangle" ON)
option(YUZU_NO_PRECOMPILED_HEADERS "Do not precompile headers" OFF)
CMAKE_DEPENDENT_OPTION(YUZU_USE_FASTER_LD "Check if a faster linker is available" ON "NOT WIN32" OFF)
CMAKE_DEPENDENT_OPTION(USE_SYSTEM_MOLTENVK "Use the system MoltenVK lib (instead of the bundled one)" OFF "APPLE" OFF)
if (YUZU_NO_PRECOMPILED_HEADERS)
function (target_precompile_headers)
# Do nothing instead
endfunction()
endif()
# Detect current compilation architecture and create standard definitions
# =======================================================================
@@ -170,7 +164,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/")
@@ -345,7 +339,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# Enforce the search mode of non-required packages for better and shorter failure messages
if (NOT YUZU_USE_CPM)
find_package(Boost 1.86.0 REQUIRED context)
find_package(Boost 1.86.0 REQUIRED headers context system fiber)
find_package(enet 1.3 MODULE)
find_package(fmt REQUIRED)
if (YUZU_USE_LLVM_DEMANGLE)

View File

@@ -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

View File

@@ -89,7 +89,7 @@ If version 5.15.2 is not already installed, pre-compiled binaries for Qt 5.15.2
All other dependencies will be downloaded by [vcpkg](https://vcpkg.io/) if needed:
* [Boost](https://www.boost.org/users/download/) 1.79.0+
* [Boost](https://www.boost.org/users/download/) 1.86.0+
* [Catch2](https://github.com/catchorg/Catch2) 2.13.7 - 2.13.9
* [fmt](https://fmt.dev/) 8.0.1+
* [lz4](http://www.lz4.org) 1.8+
@@ -107,7 +107,7 @@ All other dependencies will be downloaded by [vcpkg](https://vcpkg.io/) if neede
- Arch / Manjaro:
```bash
sudo pacman -Syu --needed base-devel boost catch2 cmake ffmpeg fmt git glslang libzip lz4 mbedtls ninja nlohmann-json openssl opus qt5 sdl2 shasum unzip zip zlib zstd
sudo pacman -Syu --needed base-devel boost catch2 cmake ffmpeg fmt git glslang libzip lz4 mbedtls ninja nlohmann-json openssl opus qt5 sdl2 unzip zip zlib zstd perl
```
- Building with QT Web Engine needs to be specified when running CMake with the param `-DCMAKE_CXX_FLAGS="-I/usr/include/qt/QtWebEngineWidgets"` with qt5-webengine installed.
- GCC 11 or later is required.

View File

@@ -165,7 +165,28 @@ git submodule update --init --recursive
---
---
# Method II: MinGW-w64 Build with MSYS2
# Method II: Clang-CL on Linux
Yet to be written. These loose snippets may help you:
https://github.com/mstorsjo/msvc-wine
https://apt.llvm.org
```
exec bwrap --bind / / --ro-bind '/opt/msvc/Windows Kits/10/Include/10.0.22621.0/ucrt' /usr/include --dev /dev /bin/bash
```
```
CC=clang-cl-19 CXX=clang-cl-19 cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS:STRING="--target=x86_64-windows-msvc /EHa -Wno-unused-command-line-argument -Wno-unknown-argument" -DCMAKE_C_FLAGS:STRING="--target=x86_64-windows-msvc -Wno-unused-command-line-argument -Wno-unknown-argument" -DCMAKE_SYSTEM_NAME:STRING=Windows -DYUZU_USE_BUNDLED_VCPKG=OFF -DYUZU_USE_CPM=ON -DENABLE_OPENSSL=OFF -DENABLE_WEB_SERVICE=OFF -DENABLE_LIBUSB=OFF -DYUZU_TESTS=OFF -GNinja
```
---
---
---
---
---
# Method III: MinGW-w64 Build with MSYS2
## Prerequisites to install
@@ -255,7 +276,7 @@ Doesn't require the rather large Qt dependency, but you will lack a GUI frontend
---
---
# Method III: CLion Environment Setup
# Method IV: CLion Environment Setup
## Minimal Dependencies

View File

@@ -140,7 +140,9 @@ if (DYNARMIC_USE_BUNDLED_EXTERNALS)
set(CMAKE_DISABLE_FIND_PACKAGE_Zydis ON)
endif()
find_package(Boost 1.57 REQUIRED)
if (NOT TARGET boost_headers)
find_package(Boost 1.57 REQUIRED)
endif()
find_package(fmt 9 CONFIG)
find_package(mcl 0.1.12 EXACT CONFIG)
find_package(tsl-robin-map CONFIG)

View File

@@ -5,4 +5,5 @@ c8997e4ab546f1ac29f54a2ef518821ba232b484
c92b9f9024404fbb68ac87370dd7589e1d5f237a
Anonymization (Disabled telemetry, anonymized scm strings)
3857ff1aa81c2e3a97f8b1e35c406853ad0618a5
3857ff1aa81c2e3a97f8b1e35c406853ad0618a5
f7849077e1f8f3d1006485523c48f26d1907763c

View File

@@ -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"
)

View File

@@ -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) {
{

View File

@@ -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

View File

@@ -259,7 +259,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
)
endif()
target_link_libraries(common PUBLIC Boost::context Boost::headers fmt::fmt microprofile stb::headers Threads::Threads)
target_link_libraries(common PUBLIC Boost::headers Boost::context fmt::fmt microprofile stb::headers Threads::Threads)
if (YUZU_USE_CPM)
target_link_libraries(common PUBLIC Boost::icl)
endif()

View File

@@ -19,10 +19,9 @@
#define TITLE_BAR_FORMAT_RUNNING "@TITLE_BAR_FORMAT_RUNNING@"
namespace Common {
const char* g_scm_rev;
const char* g_scm_branch;
const char* g_scm_desc;
const char g_scm_rev[] = GIT_REV;
const char g_scm_branch[] = GIT_BRANCH;
const char g_scm_desc[] = GIT_DESC;
const char g_build_name[] = BUILD_NAME;
const char g_build_date[] = BUILD_DATE;
const char g_build_fullname[] = BUILD_FULLNAME;
@@ -30,50 +29,4 @@ const char g_build_version[] = BUILD_VERSION;
const char g_build_id[] = BUILD_ID;
const char g_title_bar_format_idle[] = TITLE_BAR_FORMAT_IDLE;
const char g_title_bar_format_running[] = TITLE_BAR_FORMAT_RUNNING;
/// Anonymizes SCM data
/// This is quite weak. But better than nothing.
class scm_encrypt {
std::string m_scm_rev, m_scm_branch, m_scm_desc;
public:
scm_encrypt() {
// Get a key that is easy to obtain when asking the person directly but (usually) hard to
// guess
std::string key;
#ifdef __linux__
if (!std::getline(std::ifstream("/proc/sys/kernel/hostname"), key))
key = "linux_error_key";
#else
// Not a good fallback, but better than nothing I guess?
key = g_build_date;
#endif
// Copy strings in place
m_scm_rev = GIT_REV;
m_scm_branch = GIT_BRANCH;
m_scm_desc = GIT_DESC;
// XOR each string with key
auto key_it = key.begin();
for (auto& string : {&m_scm_rev, &m_scm_branch, &m_scm_desc}) {
for (auto& c : *string) {
c ^= *key_it;
if (++key_it == key.end())
key_it = key.begin();
}
}
// Make each string human-readable
for (auto& string : {&m_scm_rev, &m_scm_branch, &m_scm_desc}) {
const std::string original = *string;
string->clear();
for (const auto c : original) {
string->append(fmt::format("{:x}", unsigned(c)));
}
string->pop_back();
}
// Set pointers
g_scm_rev = m_scm_rev.c_str();
g_scm_branch = m_scm_branch.c_str();
g_scm_desc = m_scm_desc.c_str();
}
} scm_encrypt_instance;
} // namespace Common

View File

@@ -5,9 +5,9 @@
namespace Common {
extern const char* g_scm_rev;
extern const char* g_scm_branch;
extern const char* g_scm_desc;
extern const char g_scm_rev[];
extern const char g_scm_branch[];
extern const char g_scm_desc[];
extern const char g_build_name[];
extern const char g_build_date[];
extern const char g_build_fullname[];

View File

@@ -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
@@ -1165,6 +1172,8 @@ target_link_libraries(core PUBLIC common PRIVATE audio_core hid_core network vid
target_link_libraries(core PUBLIC Boost::headers PRIVATE fmt::fmt nlohmann_json::nlohmann_json mbedtls RenderDoc::API)
if (YUZU_USE_CPM)
target_link_libraries(core PUBLIC Boost::heap Boost::asio Boost::process Boost::crc)
else()
target_link_libraries(core PUBLIC Boost::system Boost::fiber)
endif()
if (MINGW)
target_link_libraries(core PRIVATE ${MSWSOCK_LIBRARY})

View File

@@ -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<Dynarmic::A32::Jit> 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) {

View File

@@ -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<Dynarmic::A64::Jit> 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) {

View File

@@ -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<Debugger>(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<Core::Debugger> 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<std::mutex> 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;

View File

@@ -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<std::mutex> 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<Service::ServerManager>&& server_manager);

View File

@@ -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 <algorithm>
#include <mutex>
#include <thread>
@@ -9,33 +11,34 @@
#include <boost/process/v1/async_pipe.hpp>
#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 <typename Readable, typename Buffer, typename Callback>
static void AsyncReceiveInto(Readable& r, Buffer& buffer, Callback&& c) {
template<typename Readable, typename Buffer, typename Callback>
static void AsyncReceiveInto(Readable& r, Buffer& buffer, Callback&& c)
{
static_assert(std::is_trivial_v<Buffer>);
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<const u8*>(&buffer);
std::span<const u8> 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<const u8*>(&buffer);
std::span<const u8> received_data{buffer_start,
buffer_start + bytes_read};
c(received_data);
AsyncReceiveInto(r, buffer, c);
}
});
}
template <typename Callback>
static void AsyncAccept(boost::asio::ip::tcp::acceptor& acceptor, Callback&& c) {
template<typename Callback>
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 <typename Readable, typename Buffer>
static std::span<const u8> ReceiveInto(Readable& r, Buffer& buffer) {
template<typename Readable, typename Buffer>
static std::span<const u8> ReceiveInto(Readable& r, Buffer& buffer)
{
static_assert(std::is_trivial_v<Buffer>);
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<const u8> ReadFromClient() override {
std::span<const u8> ReadFromClient() override
{
return ReceiveInto(state->client_socket, state->client_data);
}
void WriteToClient(std::span<const u8> data) override {
void WriteToClient(std::span<const u8> 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<const u8> data) {
void PipeData(std::span<const u8> 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<const u8> data) {
void ClientData(std::span<const u8> 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 <typename Callback>
void MarkResumed(Callback&& cb) {
template<typename Callback>
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<DebuggerImpl>(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});
}

View File

@@ -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());

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>616</width>
<height>294</height>
<height>341</height>
</rect>
</property>
<property name="windowTitle">
@@ -46,7 +46,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -106,7 +106,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
&lt;br&gt;&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:12pt;&quot;&gt;This software should not be used to play games you have not legally obtained.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
@@ -116,7 +116,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -156,10 +156,10 @@ li.checked::marker { content: &quot;\2612&quot;; }
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>

View File

@@ -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

View File

@@ -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));
});

View File

@@ -18,8 +18,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>842</width>
<height>741</height>
<width>829</width>
<height>758</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_1">
@@ -29,7 +29,7 @@
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="cpu_debug_box">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -40,7 +40,7 @@
<string>Debugger</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property>
<property name="flat">
<bool>false</bool>
@@ -59,7 +59,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
@@ -355,10 +355,10 @@
<item row="10" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
<enum>QSizePolicy::Policy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -452,10 +452,10 @@
<item row="7" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
<enum>QSizePolicy::Policy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -501,10 +501,10 @@
<item row="5" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
<enum>QSizePolicy::Policy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -522,7 +522,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "yuzu",
"builtin-baseline": "c82f74667287d3dc386bce81e44964370c91a289",
"builtin-baseline": "bc994510d2eb11aac7b43b03f67a7751d5bfe0e4",
"version": "1.0",
"dependencies": [
"boost-algorithm",
@@ -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"
}
]
}