chore: make yuzu REUSE compliant
[REUSE] is a specification that aims at making file copyright
information consistent, so that it can be both human and machine
readable. It basically requires that all files have a header containing
copyright and licensing information. When this isn't possible, like
when dealing with binary assets, generated files or embedded third-party
dependencies, it is permitted to insert copyright information in the
`.reuse/dep5` file.
Oh, and it also requires that all the licenses used in the project are
present in the `LICENSES` folder, that's why the diff is so huge.
This can be done automatically with `reuse download --all`.
The `reuse` tool also contains a handy subcommand that analyzes the
project and tells whether or not the project is (still) compliant,
`reuse lint`.
Following REUSE has a few advantages over the current approach:
- Copyright information is easy to access for users / downstream
- Files like `dist/license.md` do not need to exist anymore, as
`.reuse/dep5` is used instead
- `reuse lint` makes it easy to ensure that copyright information of
files like binary assets / images is always accurate and up to date
To add copyright information of files that didn't have it I looked up
who committed what and when, for each file. As yuzu contributors do not
have to sign a CLA or similar I couldn't assume that copyright ownership
was of the "yuzu Emulator Project", so I used the name and/or email of
the commit author instead.
[REUSE]: https://reuse.software
Follow-up to 01cf05bc75b1e47beb08937439f3ed9339e7b254
2022-05-15 02:06:02 +02:00
|
|
|
// SPDX-FileCopyrightText: 2016 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2016-04-08 18:28:54 +02:00
|
|
|
|
2020-07-18 12:22:03 +02:00
|
|
|
#include <array>
|
2020-03-20 19:05:47 +01:00
|
|
|
#include <fmt/format.h>
|
|
|
|
|
2018-01-12 04:33:56 +01:00
|
|
|
#include "yuzu/debugger/wait_tree.h"
|
2020-07-18 12:22:03 +02:00
|
|
|
#include "yuzu/uisettings.h"
|
2016-04-08 18:28:54 +02:00
|
|
|
|
2020-03-20 19:05:47 +01:00
|
|
|
#include "core/arm/arm_interface.h"
|
2018-02-18 21:17:16 +01:00
|
|
|
#include "core/core.h"
|
2021-04-24 06:50:04 +02:00
|
|
|
#include "core/hle/kernel/k_class_token.h"
|
2021-04-24 11:40:31 +02:00
|
|
|
#include "core/hle/kernel/k_handle_table.h"
|
2021-04-24 07:04:28 +02:00
|
|
|
#include "core/hle/kernel/k_process.h"
|
2021-01-30 07:48:06 +01:00
|
|
|
#include "core/hle/kernel/k_readable_event.h"
|
2020-12-03 03:08:35 +01:00
|
|
|
#include "core/hle/kernel/k_scheduler.h"
|
2020-12-22 07:36:53 +01:00
|
|
|
#include "core/hle/kernel/k_synchronization_object.h"
|
2020-12-31 08:01:08 +01:00
|
|
|
#include "core/hle/kernel/k_thread.h"
|
2020-12-30 10:14:02 +01:00
|
|
|
#include "core/hle/kernel/svc_common.h"
|
2021-01-03 10:49:18 +01:00
|
|
|
#include "core/hle/kernel/svc_types.h"
|
2018-09-21 01:28:48 +02:00
|
|
|
#include "core/memory.h"
|
2016-04-08 18:28:54 +02:00
|
|
|
|
2020-07-18 12:22:03 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
constexpr std::array<std::array<Qt::GlobalColor, 2>, 10> WaitTreeColors{{
|
|
|
|
{Qt::GlobalColor::darkGreen, Qt::GlobalColor::green},
|
|
|
|
{Qt::GlobalColor::darkBlue, Qt::GlobalColor::cyan},
|
|
|
|
{Qt::GlobalColor::lightGray, Qt::GlobalColor::lightGray},
|
|
|
|
{Qt::GlobalColor::lightGray, Qt::GlobalColor::lightGray},
|
|
|
|
{Qt::GlobalColor::darkRed, Qt::GlobalColor::red},
|
|
|
|
{Qt::GlobalColor::darkYellow, Qt::GlobalColor::yellow},
|
|
|
|
{Qt::GlobalColor::red, Qt::GlobalColor::red},
|
|
|
|
{Qt::GlobalColor::darkCyan, Qt::GlobalColor::cyan},
|
|
|
|
{Qt::GlobalColor::gray, Qt::GlobalColor::gray},
|
|
|
|
}};
|
|
|
|
|
|
|
|
bool IsDarkTheme() {
|
2020-07-18 17:02:41 +02:00
|
|
|
const auto& theme = UISettings::values.theme;
|
2020-07-19 09:00:34 +02:00
|
|
|
return theme == QStringLiteral("qdarkstyle") ||
|
|
|
|
theme == QStringLiteral("qdarkstyle_midnight_blue") ||
|
|
|
|
theme == QStringLiteral("colorful_dark") ||
|
|
|
|
theme == QStringLiteral("colorful_midnight_blue");
|
2020-07-18 12:22:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2018-08-31 18:21:34 +02:00
|
|
|
WaitTreeItem::WaitTreeItem() = default;
|
2018-08-06 18:58:46 +02:00
|
|
|
WaitTreeItem::~WaitTreeItem() = default;
|
2016-04-08 18:28:54 +02:00
|
|
|
|
|
|
|
QColor WaitTreeItem::GetColor() const {
|
2020-07-18 12:22:03 +02:00
|
|
|
if (IsDarkTheme()) {
|
|
|
|
return QColor(Qt::GlobalColor::white);
|
|
|
|
} else {
|
|
|
|
return QColor(Qt::GlobalColor::black);
|
|
|
|
}
|
2016-04-08 18:28:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeItem::GetChildren() const {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
void WaitTreeItem::Expand() {
|
|
|
|
if (IsExpandable() && !expanded) {
|
|
|
|
children = GetChildren();
|
|
|
|
for (std::size_t i = 0; i < children.size(); ++i) {
|
|
|
|
children[i]->parent = this;
|
|
|
|
children[i]->row = i;
|
|
|
|
}
|
|
|
|
expanded = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitTreeItem* WaitTreeItem::Parent() const {
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::vector<std::unique_ptr<WaitTreeItem>>& WaitTreeItem::Children() const {
|
|
|
|
return children;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WaitTreeItem::IsExpandable() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::size_t WaitTreeItem::Row() const {
|
|
|
|
return row;
|
|
|
|
}
|
|
|
|
|
2021-09-03 03:40:55 +02:00
|
|
|
std::vector<std::unique_ptr<WaitTreeThread>> WaitTreeItem::MakeThreadItemList(
|
|
|
|
Core::System& system) {
|
2016-04-08 18:28:54 +02:00
|
|
|
std::vector<std::unique_ptr<WaitTreeThread>> item_list;
|
2018-05-05 18:08:16 +02:00
|
|
|
std::size_t row = 0;
|
2021-04-04 04:11:46 +02:00
|
|
|
auto add_threads = [&](const std::vector<Kernel::KThread*>& threads) {
|
2018-05-05 18:08:16 +02:00
|
|
|
for (std::size_t i = 0; i < threads.size(); ++i) {
|
2022-01-18 01:41:06 +01:00
|
|
|
if (threads[i]->GetThreadType() == Kernel::ThreadType::User) {
|
2021-09-03 03:40:55 +02:00
|
|
|
item_list.push_back(std::make_unique<WaitTreeThread>(*threads[i], system));
|
2021-01-25 07:55:08 +01:00
|
|
|
item_list.back()->row = row;
|
|
|
|
}
|
2018-05-05 18:08:16 +02:00
|
|
|
++row;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-12-03 03:08:35 +01:00
|
|
|
add_threads(system.GlobalSchedulerContext().GetThreadList());
|
2018-05-05 18:08:16 +02:00
|
|
|
|
2016-04-08 18:28:54 +02:00
|
|
|
return item_list;
|
|
|
|
}
|
|
|
|
|
2018-12-05 21:59:48 +01:00
|
|
|
WaitTreeText::WaitTreeText(QString t) : text(std::move(t)) {}
|
2018-08-31 18:21:34 +02:00
|
|
|
WaitTreeText::~WaitTreeText() = default;
|
2016-04-08 18:28:54 +02:00
|
|
|
|
|
|
|
QString WaitTreeText::GetText() const {
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2022-06-14 11:44:08 +02:00
|
|
|
WaitTreeCallstack::WaitTreeCallstack(const Kernel::KThread& thread_, Core::System& system_)
|
|
|
|
: thread{thread_}, system{system_} {}
|
2018-08-31 18:21:34 +02:00
|
|
|
WaitTreeCallstack::~WaitTreeCallstack() = default;
|
2018-05-19 23:52:49 +02:00
|
|
|
|
|
|
|
QString WaitTreeCallstack::GetText() const {
|
|
|
|
return tr("Call stack");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeCallstack::GetChildren() const {
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> list;
|
|
|
|
|
2022-01-18 01:41:06 +01:00
|
|
|
if (thread.GetThreadType() != Kernel::ThreadType::User) {
|
2021-01-25 07:55:08 +01:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2020-03-20 19:05:47 +01:00
|
|
|
if (thread.GetOwnerProcess() == nullptr || !thread.GetOwnerProcess()->Is64BitProcess()) {
|
|
|
|
return list;
|
|
|
|
}
|
2019-05-19 06:47:34 +02:00
|
|
|
|
2021-09-03 03:40:55 +02:00
|
|
|
auto backtrace = Core::ARM_Interface::GetBacktraceFromContext(system, thread.GetContext64());
|
2019-05-19 06:47:34 +02:00
|
|
|
|
2020-03-20 19:05:47 +01:00
|
|
|
for (auto& entry : backtrace) {
|
|
|
|
std::string s = fmt::format("{:20}{:016X} {:016X} {:016X} {}", entry.module, entry.address,
|
2020-05-09 00:53:13 +02:00
|
|
|
entry.original_address, entry.offset, entry.name);
|
2020-03-20 19:05:47 +01:00
|
|
|
list.push_back(std::make_unique<WaitTreeText>(QString::fromStdString(s)));
|
2018-05-19 23:52:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2020-12-22 07:36:53 +01:00
|
|
|
WaitTreeSynchronizationObject::WaitTreeSynchronizationObject(
|
2022-06-14 11:44:08 +02:00
|
|
|
const Kernel::KSynchronizationObject& object_, Core::System& system_)
|
|
|
|
: object{object_}, system{system_} {}
|
2020-02-11 15:46:25 +01:00
|
|
|
WaitTreeSynchronizationObject::~WaitTreeSynchronizationObject() = default;
|
2018-08-31 18:21:34 +02:00
|
|
|
|
|
|
|
WaitTreeExpandableItem::WaitTreeExpandableItem() = default;
|
|
|
|
WaitTreeExpandableItem::~WaitTreeExpandableItem() = default;
|
2016-04-08 18:28:54 +02:00
|
|
|
|
|
|
|
bool WaitTreeExpandableItem::IsExpandable() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-11 15:46:25 +01:00
|
|
|
QString WaitTreeSynchronizationObject::GetText() const {
|
2023-03-07 02:34:25 +01:00
|
|
|
return tr("[%1] %2")
|
2021-04-24 06:50:04 +02:00
|
|
|
.arg(object.GetId())
|
2023-03-07 02:34:25 +01:00
|
|
|
.arg(QString::fromStdString(object.GetTypeObj().GetName()));
|
2016-04-08 18:28:54 +02:00
|
|
|
}
|
|
|
|
|
2020-02-11 15:46:25 +01:00
|
|
|
std::unique_ptr<WaitTreeSynchronizationObject> WaitTreeSynchronizationObject::make(
|
2021-09-03 03:40:55 +02:00
|
|
|
const Kernel::KSynchronizationObject& object, Core::System& system) {
|
2021-04-24 06:50:04 +02:00
|
|
|
const auto type =
|
|
|
|
static_cast<Kernel::KClassTokenGenerator::ObjectType>(object.GetTypeObj().GetClassToken());
|
|
|
|
switch (type) {
|
|
|
|
case Kernel::KClassTokenGenerator::ObjectType::KReadableEvent:
|
2021-09-03 03:40:55 +02:00
|
|
|
return std::make_unique<WaitTreeEvent>(static_cast<const Kernel::KReadableEvent&>(object),
|
|
|
|
system);
|
2021-04-24 06:50:04 +02:00
|
|
|
case Kernel::KClassTokenGenerator::ObjectType::KThread:
|
2021-09-03 03:40:55 +02:00
|
|
|
return std::make_unique<WaitTreeThread>(static_cast<const Kernel::KThread&>(object),
|
|
|
|
system);
|
2016-04-08 18:28:54 +02:00
|
|
|
default:
|
2021-09-03 03:40:55 +02:00
|
|
|
return std::make_unique<WaitTreeSynchronizationObject>(object, system);
|
2016-04-08 18:28:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-11 15:46:25 +01:00
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeSynchronizationObject::GetChildren() const {
|
2016-04-08 18:28:54 +02:00
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> list;
|
|
|
|
|
2021-04-24 06:50:04 +02:00
|
|
|
auto threads = object.GetWaitingThreadsForDebugging();
|
2016-04-08 18:28:54 +02:00
|
|
|
if (threads.empty()) {
|
|
|
|
list.push_back(std::make_unique<WaitTreeText>(tr("waited by no thread")));
|
|
|
|
} else {
|
2021-09-03 03:40:55 +02:00
|
|
|
list.push_back(std::make_unique<WaitTreeThreadList>(std::move(threads), system));
|
2016-04-08 18:28:54 +02:00
|
|
|
}
|
2021-04-24 06:50:04 +02:00
|
|
|
|
2016-04-08 18:28:54 +02:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2021-09-03 03:40:55 +02:00
|
|
|
WaitTreeThread::WaitTreeThread(const Kernel::KThread& thread, Core::System& system_)
|
|
|
|
: WaitTreeSynchronizationObject(thread, system_), system{system_} {}
|
2018-08-31 18:21:34 +02:00
|
|
|
WaitTreeThread::~WaitTreeThread() = default;
|
2016-04-08 18:28:54 +02:00
|
|
|
|
|
|
|
QString WaitTreeThread::GetText() const {
|
2020-12-31 08:01:08 +01:00
|
|
|
const auto& thread = static_cast<const Kernel::KThread&>(object);
|
2016-04-08 18:28:54 +02:00
|
|
|
QString status;
|
2020-12-28 22:16:43 +01:00
|
|
|
switch (thread.GetState()) {
|
|
|
|
case Kernel::ThreadState::Runnable:
|
2021-01-20 22:42:27 +01:00
|
|
|
if (!thread.IsSuspended()) {
|
|
|
|
status = tr("runnable");
|
2020-03-07 18:07:04 +01:00
|
|
|
} else {
|
|
|
|
status = tr("paused");
|
|
|
|
}
|
2016-04-08 18:28:54 +02:00
|
|
|
break;
|
2020-12-28 22:16:43 +01:00
|
|
|
case Kernel::ThreadState::Waiting:
|
2021-01-10 23:29:02 +01:00
|
|
|
switch (thread.GetWaitReasonForDebugging()) {
|
|
|
|
case Kernel::ThreadWaitReasonForDebugging::Sleep:
|
|
|
|
status = tr("sleeping");
|
|
|
|
break;
|
|
|
|
case Kernel::ThreadWaitReasonForDebugging::IPC:
|
|
|
|
status = tr("waiting for IPC reply");
|
|
|
|
break;
|
|
|
|
case Kernel::ThreadWaitReasonForDebugging::Synchronization:
|
|
|
|
status = tr("waiting for objects");
|
|
|
|
break;
|
|
|
|
case Kernel::ThreadWaitReasonForDebugging::ConditionVar:
|
|
|
|
status = tr("waiting for condition variable");
|
|
|
|
break;
|
|
|
|
case Kernel::ThreadWaitReasonForDebugging::Arbitration:
|
|
|
|
status = tr("waiting for address arbiter");
|
|
|
|
break;
|
|
|
|
case Kernel::ThreadWaitReasonForDebugging::Suspended:
|
|
|
|
status = tr("waiting for suspend resume");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status = tr("waiting");
|
|
|
|
break;
|
|
|
|
}
|
2018-12-03 18:25:27 +01:00
|
|
|
break;
|
2020-12-28 22:16:43 +01:00
|
|
|
case Kernel::ThreadState::Initialized:
|
|
|
|
status = tr("initialized");
|
2016-04-08 18:28:54 +02:00
|
|
|
break;
|
2020-12-28 22:16:43 +01:00
|
|
|
case Kernel::ThreadState::Terminated:
|
|
|
|
status = tr("terminated");
|
2016-04-08 18:28:54 +02:00
|
|
|
break;
|
2021-01-10 10:02:46 +01:00
|
|
|
default:
|
|
|
|
status = tr("unknown");
|
|
|
|
break;
|
2016-04-08 18:28:54 +02:00
|
|
|
}
|
2018-10-04 00:47:57 +02:00
|
|
|
|
2020-03-02 05:46:10 +01:00
|
|
|
const auto& context = thread.GetContext64();
|
2018-10-04 00:47:57 +02:00
|
|
|
const QString pc_info = tr(" PC = 0x%1 LR = 0x%2")
|
2019-05-19 06:47:34 +02:00
|
|
|
.arg(context.pc, 8, 16, QLatin1Char{'0'})
|
|
|
|
.arg(context.cpu_registers[30], 8, 16, QLatin1Char{'0'});
|
2020-02-11 15:46:25 +01:00
|
|
|
return QStringLiteral("%1%2 (%3) ")
|
|
|
|
.arg(WaitTreeSynchronizationObject::GetText(), pc_info, status);
|
2016-04-08 18:28:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QColor WaitTreeThread::GetColor() const {
|
2020-07-18 17:02:41 +02:00
|
|
|
const std::size_t color_index = IsDarkTheme() ? 1 : 0;
|
2020-07-18 12:22:03 +02:00
|
|
|
|
2020-12-31 08:01:08 +01:00
|
|
|
const auto& thread = static_cast<const Kernel::KThread&>(object);
|
2020-12-28 22:16:43 +01:00
|
|
|
switch (thread.GetState()) {
|
|
|
|
case Kernel::ThreadState::Runnable:
|
2021-01-20 22:42:27 +01:00
|
|
|
if (!thread.IsSuspended()) {
|
|
|
|
return QColor(WaitTreeColors[0][color_index]);
|
2020-03-07 18:07:04 +01:00
|
|
|
} else {
|
2020-11-15 07:37:45 +01:00
|
|
|
return QColor(WaitTreeColors[2][color_index]);
|
2020-03-07 18:07:04 +01:00
|
|
|
}
|
2020-12-28 22:16:43 +01:00
|
|
|
case Kernel::ThreadState::Waiting:
|
2021-01-10 23:29:02 +01:00
|
|
|
switch (thread.GetWaitReasonForDebugging()) {
|
|
|
|
case Kernel::ThreadWaitReasonForDebugging::IPC:
|
|
|
|
return QColor(WaitTreeColors[4][color_index]);
|
|
|
|
case Kernel::ThreadWaitReasonForDebugging::Sleep:
|
|
|
|
return QColor(WaitTreeColors[5][color_index]);
|
|
|
|
case Kernel::ThreadWaitReasonForDebugging::Synchronization:
|
|
|
|
case Kernel::ThreadWaitReasonForDebugging::ConditionVar:
|
|
|
|
case Kernel::ThreadWaitReasonForDebugging::Arbitration:
|
|
|
|
case Kernel::ThreadWaitReasonForDebugging::Suspended:
|
|
|
|
return QColor(WaitTreeColors[6][color_index]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return QColor(WaitTreeColors[3][color_index]);
|
|
|
|
}
|
2020-12-28 22:16:43 +01:00
|
|
|
case Kernel::ThreadState::Initialized:
|
2020-11-15 07:37:45 +01:00
|
|
|
return QColor(WaitTreeColors[7][color_index]);
|
2020-12-28 22:16:43 +01:00
|
|
|
case Kernel::ThreadState::Terminated:
|
2020-11-15 07:37:45 +01:00
|
|
|
return QColor(WaitTreeColors[8][color_index]);
|
2016-04-08 18:28:54 +02:00
|
|
|
default:
|
|
|
|
return WaitTreeItem::GetColor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const {
|
2020-02-11 15:46:25 +01:00
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeSynchronizationObject::GetChildren());
|
2016-04-08 18:28:54 +02:00
|
|
|
|
2020-12-31 08:01:08 +01:00
|
|
|
const auto& thread = static_cast<const Kernel::KThread&>(object);
|
2016-04-08 18:28:54 +02:00
|
|
|
|
|
|
|
QString processor;
|
2021-01-20 22:42:27 +01:00
|
|
|
switch (thread.GetActiveCore()) {
|
2021-01-03 10:49:18 +01:00
|
|
|
case Kernel::Svc::IdealCoreUseProcessValue:
|
2018-12-28 03:14:59 +01:00
|
|
|
processor = tr("ideal");
|
2016-04-08 18:28:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
2021-01-20 22:42:27 +01:00
|
|
|
processor = tr("core %1").arg(thread.GetActiveCore());
|
2016-04-08 18:28:54 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
list.push_back(std::make_unique<WaitTreeText>(tr("processor = %1").arg(processor)));
|
2020-11-17 06:02:45 +01:00
|
|
|
list.push_back(std::make_unique<WaitTreeText>(
|
|
|
|
tr("affinity mask = %1").arg(thread.GetAffinityMask().GetAffinityMask())));
|
2023-03-07 22:11:50 +01:00
|
|
|
list.push_back(std::make_unique<WaitTreeText>(tr("thread id = %1").arg(thread.GetThreadId())));
|
2016-04-08 18:28:54 +02:00
|
|
|
list.push_back(std::make_unique<WaitTreeText>(tr("priority = %1(current) / %2(normal)")
|
2018-10-04 00:47:57 +02:00
|
|
|
.arg(thread.GetPriority())
|
2020-12-30 10:14:02 +01:00
|
|
|
.arg(thread.GetBasePriority())));
|
2016-04-08 18:28:54 +02:00
|
|
|
list.push_back(std::make_unique<WaitTreeText>(
|
2020-12-03 03:08:35 +01:00
|
|
|
tr("last running ticks = %1").arg(thread.GetLastScheduledTick())));
|
2016-04-08 18:28:54 +02:00
|
|
|
|
2021-09-03 03:40:55 +02:00
|
|
|
list.push_back(std::make_unique<WaitTreeCallstack>(thread, system));
|
2018-05-19 23:52:49 +02:00
|
|
|
|
2016-04-08 18:28:54 +02:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2022-06-14 11:44:08 +02:00
|
|
|
WaitTreeEvent::WaitTreeEvent(const Kernel::KReadableEvent& object_, Core::System& system_)
|
|
|
|
: WaitTreeSynchronizationObject(object_, system_) {}
|
2018-08-31 18:21:34 +02:00
|
|
|
WaitTreeEvent::~WaitTreeEvent() = default;
|
2016-04-08 18:28:54 +02:00
|
|
|
|
2021-09-03 03:40:55 +02:00
|
|
|
WaitTreeThreadList::WaitTreeThreadList(std::vector<Kernel::KThread*>&& list, Core::System& system_)
|
|
|
|
: thread_list(std::move(list)), system{system_} {}
|
2018-08-31 18:21:34 +02:00
|
|
|
WaitTreeThreadList::~WaitTreeThreadList() = default;
|
2016-04-08 18:28:54 +02:00
|
|
|
|
|
|
|
QString WaitTreeThreadList::GetText() const {
|
|
|
|
return tr("waited by thread");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThreadList::GetChildren() const {
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> list(thread_list.size());
|
|
|
|
std::transform(thread_list.begin(), thread_list.end(), list.begin(),
|
2021-09-03 03:40:55 +02:00
|
|
|
[this](const auto& t) { return std::make_unique<WaitTreeThread>(*t, system); });
|
2016-04-08 18:28:54 +02:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2021-09-03 03:40:55 +02:00
|
|
|
WaitTreeModel::WaitTreeModel(Core::System& system_, QObject* parent)
|
|
|
|
: QAbstractItemModel(parent), system{system_} {}
|
2018-08-31 18:21:34 +02:00
|
|
|
WaitTreeModel::~WaitTreeModel() = default;
|
2016-04-08 18:28:54 +02:00
|
|
|
|
|
|
|
QModelIndex WaitTreeModel::index(int row, int column, const QModelIndex& parent) const {
|
|
|
|
if (!hasIndex(row, column, parent))
|
|
|
|
return {};
|
|
|
|
|
|
|
|
if (parent.isValid()) {
|
|
|
|
WaitTreeItem* parent_item = static_cast<WaitTreeItem*>(parent.internalPointer());
|
|
|
|
parent_item->Expand();
|
|
|
|
return createIndex(row, column, parent_item->Children()[row].get());
|
|
|
|
}
|
|
|
|
|
|
|
|
return createIndex(row, column, thread_items[row].get());
|
|
|
|
}
|
|
|
|
|
|
|
|
QModelIndex WaitTreeModel::parent(const QModelIndex& index) const {
|
|
|
|
if (!index.isValid())
|
|
|
|
return {};
|
|
|
|
|
|
|
|
WaitTreeItem* parent_item = static_cast<WaitTreeItem*>(index.internalPointer())->Parent();
|
|
|
|
if (!parent_item) {
|
|
|
|
return QModelIndex();
|
|
|
|
}
|
|
|
|
return createIndex(static_cast<int>(parent_item->Row()), 0, parent_item);
|
|
|
|
}
|
|
|
|
|
|
|
|
int WaitTreeModel::rowCount(const QModelIndex& parent) const {
|
|
|
|
if (!parent.isValid())
|
|
|
|
return static_cast<int>(thread_items.size());
|
|
|
|
|
|
|
|
WaitTreeItem* parent_item = static_cast<WaitTreeItem*>(parent.internalPointer());
|
|
|
|
parent_item->Expand();
|
|
|
|
return static_cast<int>(parent_item->Children().size());
|
|
|
|
}
|
|
|
|
|
|
|
|
int WaitTreeModel::columnCount(const QModelIndex&) const {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant WaitTreeModel::data(const QModelIndex& index, int role) const {
|
|
|
|
if (!index.isValid())
|
|
|
|
return {};
|
|
|
|
|
|
|
|
switch (role) {
|
|
|
|
case Qt::DisplayRole:
|
|
|
|
return static_cast<WaitTreeItem*>(index.internalPointer())->GetText();
|
|
|
|
case Qt::ForegroundRole:
|
|
|
|
return static_cast<WaitTreeItem*>(index.internalPointer())->GetColor();
|
|
|
|
default:
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WaitTreeModel::ClearItems() {
|
|
|
|
thread_items.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WaitTreeModel::InitItems() {
|
2021-09-03 03:40:55 +02:00
|
|
|
thread_items = WaitTreeItem::MakeThreadItemList(system);
|
2016-04-08 18:28:54 +02:00
|
|
|
}
|
|
|
|
|
2021-09-03 03:40:55 +02:00
|
|
|
WaitTreeWidget::WaitTreeWidget(Core::System& system_, QWidget* parent)
|
|
|
|
: QDockWidget(tr("&Wait Tree"), parent), system{system_} {
|
2019-05-19 06:47:34 +02:00
|
|
|
setObjectName(QStringLiteral("WaitTreeWidget"));
|
2016-04-08 18:28:54 +02:00
|
|
|
view = new QTreeView(this);
|
|
|
|
view->setHeaderHidden(true);
|
|
|
|
setWidget(view);
|
|
|
|
setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2018-08-31 18:21:34 +02:00
|
|
|
WaitTreeWidget::~WaitTreeWidget() = default;
|
|
|
|
|
2016-04-08 18:28:54 +02:00
|
|
|
void WaitTreeWidget::OnDebugModeEntered() {
|
2021-09-03 03:40:55 +02:00
|
|
|
if (!system.IsPoweredOn())
|
2016-04-08 18:28:54 +02:00
|
|
|
return;
|
|
|
|
model->InitItems();
|
|
|
|
view->setModel(model);
|
|
|
|
setEnabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WaitTreeWidget::OnDebugModeLeft() {
|
|
|
|
setEnabled(false);
|
|
|
|
view->setModel(nullptr);
|
|
|
|
model->ClearItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WaitTreeWidget::OnEmulationStarting(EmuThread* emu_thread) {
|
2021-09-03 03:40:55 +02:00
|
|
|
model = new WaitTreeModel(system, this);
|
2016-04-08 18:28:54 +02:00
|
|
|
view->setModel(model);
|
|
|
|
setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WaitTreeWidget::OnEmulationStopping() {
|
|
|
|
view->setModel(nullptr);
|
|
|
|
delete model;
|
|
|
|
setEnabled(false);
|
|
|
|
}
|