early-access version 3927

This commit is contained in:
pineappleEA
2023-10-12 19:22:22 +02:00
parent 91ade31ddd
commit 7fe7262395
29 changed files with 330 additions and 106 deletions
+5 -5
View File
@@ -227,14 +227,14 @@ add_executable(yuzu
yuzu.rc
)
if (WIN32 AND YUZU_CRASH_DUMPS)
if (YUZU_CRASH_DUMPS)
target_sources(yuzu PRIVATE
mini_dump.cpp
mini_dump.h
breakpad.cpp
breakpad.h
)
target_link_libraries(yuzu PRIVATE ${DBGHELP_LIBRARY})
target_compile_definitions(yuzu PRIVATE -DYUZU_DBGHELP)
target_link_libraries(yuzu PRIVATE libbreakpad_client)
target_compile_definitions(yuzu PRIVATE YUZU_CRASH_DUMPS)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+77
View File
@@ -0,0 +1,77 @@
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include <ranges>
#if defined(_WIN32)
#include <client/windows/handler/exception_handler.h>
#elif defined(__linux__)
#include <client/linux/handler/exception_handler.h>
#else
#error Minidump creation not supported on this platform
#endif
#include "common/fs/fs_paths.h"
#include "common/fs/path_util.h"
#include "yuzu/breakpad.h"
namespace Breakpad {
static void PruneDumpDirectory(const std::filesystem::path& dump_path) {
// Code in this function should be exception-safe.
struct Entry {
std::filesystem::path path;
std::filesystem::file_time_type last_write_time;
};
std::vector<Entry> existing_dumps;
// Get existing entries.
std::error_code ec;
std::filesystem::directory_iterator dir(dump_path, ec);
for (auto& entry : dir) {
if (entry.is_regular_file()) {
existing_dumps.push_back(Entry{
.path = entry.path(),
.last_write_time = entry.last_write_time(ec),
});
}
}
// Sort descending by creation date.
std::ranges::stable_sort(existing_dumps, [](const auto& a, const auto& b) {
return a.last_write_time > b.last_write_time;
});
// Delete older dumps.
for (size_t i = 5; i < existing_dumps.size(); i++) {
std::filesystem::remove(existing_dumps[i].path, ec);
}
}
#if defined(__linux__)
[[noreturn]] bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* context,
bool succeeded) {
// Prevent time- and space-consuming core dumps from being generated, as we have
// already generated a minidump and a core file will not be useful anyway.
_exit(1);
}
#endif
void InstallCrashHandler() {
// Write crash dumps to profile directory.
const auto dump_path = GetYuzuPath(Common::FS::YuzuPath::CrashDumpsDir);
PruneDumpDirectory(dump_path);
#if defined(_WIN32)
// TODO: If we switch to MinGW builds for Windows, this needs to be wrapped in a C API.
static google_breakpad::ExceptionHandler eh{dump_path, nullptr, nullptr, nullptr,
google_breakpad::ExceptionHandler::HANDLER_ALL};
#elif defined(__linux__)
static google_breakpad::MinidumpDescriptor descriptor{dump_path};
static google_breakpad::ExceptionHandler eh{descriptor, nullptr, DumpCallback,
nullptr, true, -1};
#endif
}
} // namespace Breakpad
+10
View File
@@ -0,0 +1,10 @@
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
namespace Breakpad {
void InstallCrashHandler();
}
@@ -27,16 +27,6 @@ ConfigureDebug::ConfigureDebug(const Core::System& system_, QWidget* parent)
connect(ui->toggle_gdbstub, &QCheckBox::toggled,
[&]() { ui->gdbport_spinbox->setEnabled(ui->toggle_gdbstub->isChecked()); });
connect(ui->create_crash_dumps, &QCheckBox::stateChanged, [&](int) {
if (crash_dump_warning_shown) {
return;
}
QMessageBox::warning(this, tr("Restart Required"),
tr("yuzu is required to restart in order to apply this setting."),
QMessageBox::Ok, QMessageBox::Ok);
crash_dump_warning_shown = true;
});
}
ConfigureDebug::~ConfigureDebug() = default;
@@ -91,13 +81,6 @@ void ConfigureDebug::SetConfiguration() {
ui->disable_web_applet->setEnabled(false);
ui->disable_web_applet->setText(tr("Web applet not compiled"));
#endif
#ifdef YUZU_DBGHELP
ui->create_crash_dumps->setChecked(Settings::values.create_crash_dumps.GetValue());
#else
ui->create_crash_dumps->setEnabled(false);
ui->create_crash_dumps->setText(tr("MiniDump creation not compiled"));
#endif
}
void ConfigureDebug::ApplyConfiguration() {
@@ -109,7 +92,6 @@ void ConfigureDebug::ApplyConfiguration() {
Settings::values.enable_fs_access_log = ui->fs_access_log->isChecked();
Settings::values.reporting_services = ui->reporting_services->isChecked();
Settings::values.dump_audio_commands = ui->dump_audio_commands->isChecked();
Settings::values.create_crash_dumps = ui->create_crash_dumps->isChecked();
Settings::values.quest_flag = ui->quest_flag->isChecked();
Settings::values.use_debug_asserts = ui->use_debug_asserts->isChecked();
Settings::values.use_auto_stub = ui->use_auto_stub->isChecked();
@@ -481,13 +481,6 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="create_crash_dumps">
<property name="text">
<string>Create Minidump After Crash</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="dump_audio_commands">
<property name="toolTip">
+6 -13
View File
@@ -157,8 +157,8 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include "yuzu/util/clickable_label.h"
#include "yuzu/vk_device_info.h"
#ifdef YUZU_DBGHELP
#include "yuzu/mini_dump.h"
#ifdef YUZU_CRASH_DUMPS
#include "yuzu/breakpad.h"
#endif
using namespace Common::Literals;
@@ -5146,22 +5146,15 @@ int main(int argc, char* argv[]) {
return 0;
}
#ifdef YUZU_DBGHELP
PROCESS_INFORMATION pi;
if (!is_child && Settings::values.create_crash_dumps.GetValue() &&
MiniDump::SpawnDebuggee(argv[0], pi)) {
// Delete the config object so that it doesn't save when the program exits
config.reset(nullptr);
MiniDump::DebugDebuggee(pi);
return 0;
}
#endif
if (StartupChecks(argv[0], &has_broken_vulkan,
Settings::values.perform_vulkan_check.GetValue())) {
return 0;
}
#ifdef YUZU_CRASH_DUMPS
Breakpad::InstallCrashHandler();
#endif
Common::DetachedTasks detached_tasks;
MicroProfileOnThreadCreate("Frontend");
SCOPE_EXIT({ MicroProfileShutdown(); });