2016-04-08 18:28:54 +02:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "citra_qt/debugger/wait_tree.h"
|
|
|
|
#include "citra_qt/util/util.h"
|
|
|
|
|
2018-07-24 10:06:33 +02:00
|
|
|
#include "common/assert.h"
|
2016-04-08 18:28:54 +02:00
|
|
|
#include "core/hle/kernel/event.h"
|
|
|
|
#include "core/hle/kernel/mutex.h"
|
|
|
|
#include "core/hle/kernel/semaphore.h"
|
|
|
|
#include "core/hle/kernel/thread.h"
|
|
|
|
#include "core/hle/kernel/timer.h"
|
2017-05-30 00:45:30 +02:00
|
|
|
#include "core/hle/kernel/wait_object.h"
|
2016-04-08 18:28:54 +02:00
|
|
|
|
2018-08-24 17:14:09 +02:00
|
|
|
WaitTreeItem::~WaitTreeItem() = default;
|
2016-04-08 18:28:54 +02:00
|
|
|
|
|
|
|
QColor WaitTreeItem::GetColor() const {
|
|
|
|
return QColor(Qt::GlobalColor::black);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeThread>> WaitTreeItem::MakeThreadItemList() {
|
2018-10-23 18:18:35 +02:00
|
|
|
const auto& threads = Core::System::GetInstance().Kernel().GetThreadManager().GetThreadList();
|
2016-04-08 18:28:54 +02:00
|
|
|
std::vector<std::unique_ptr<WaitTreeThread>> item_list;
|
|
|
|
item_list.reserve(threads.size());
|
|
|
|
for (std::size_t i = 0; i < threads.size(); ++i) {
|
|
|
|
item_list.push_back(std::make_unique<WaitTreeThread>(*threads[i]));
|
|
|
|
item_list.back()->row = i;
|
|
|
|
}
|
|
|
|
return item_list;
|
|
|
|
}
|
|
|
|
|
2018-12-05 21:59:48 +01:00
|
|
|
WaitTreeText::WaitTreeText(QString t) : text(std::move(t)) {}
|
|
|
|
WaitTreeText::~WaitTreeText() = default;
|
2016-04-08 18:28:54 +02:00
|
|
|
|
|
|
|
QString WaitTreeText::GetText() const {
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitTreeWaitObject::WaitTreeWaitObject(const Kernel::WaitObject& o) : object(o) {}
|
|
|
|
|
|
|
|
bool WaitTreeExpandableItem::IsExpandable() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString WaitTreeWaitObject::GetText() const {
|
|
|
|
return tr("[%1]%2 %3")
|
|
|
|
.arg(object.GetObjectId())
|
|
|
|
.arg(QString::fromStdString(object.GetTypeName()),
|
|
|
|
QString::fromStdString(object.GetName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<WaitTreeWaitObject> WaitTreeWaitObject::make(const Kernel::WaitObject& object) {
|
|
|
|
switch (object.GetHandleType()) {
|
|
|
|
case Kernel::HandleType::Event:
|
|
|
|
return std::make_unique<WaitTreeEvent>(static_cast<const Kernel::Event&>(object));
|
|
|
|
case Kernel::HandleType::Mutex:
|
|
|
|
return std::make_unique<WaitTreeMutex>(static_cast<const Kernel::Mutex&>(object));
|
|
|
|
case Kernel::HandleType::Semaphore:
|
|
|
|
return std::make_unique<WaitTreeSemaphore>(static_cast<const Kernel::Semaphore&>(object));
|
|
|
|
case Kernel::HandleType::Timer:
|
|
|
|
return std::make_unique<WaitTreeTimer>(static_cast<const Kernel::Timer&>(object));
|
|
|
|
case Kernel::HandleType::Thread:
|
|
|
|
return std::make_unique<WaitTreeThread>(static_cast<const Kernel::Thread&>(object));
|
|
|
|
default:
|
|
|
|
return std::make_unique<WaitTreeWaitObject>(object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeWaitObject::GetChildren() const {
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> list;
|
|
|
|
|
|
|
|
const auto& threads = object.GetWaitingThreads();
|
|
|
|
if (threads.empty()) {
|
|
|
|
list.push_back(std::make_unique<WaitTreeText>(tr("waited by no thread")));
|
|
|
|
} else {
|
|
|
|
list.push_back(std::make_unique<WaitTreeThreadList>(threads));
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString WaitTreeWaitObject::GetResetTypeQString(Kernel::ResetType reset_type) {
|
|
|
|
switch (reset_type) {
|
|
|
|
case Kernel::ResetType::OneShot:
|
|
|
|
return tr("one shot");
|
|
|
|
case Kernel::ResetType::Sticky:
|
|
|
|
return tr("sticky");
|
|
|
|
case Kernel::ResetType::Pulse:
|
|
|
|
return tr("pulse");
|
|
|
|
}
|
2018-07-24 10:06:33 +02:00
|
|
|
UNREACHABLE();
|
|
|
|
return {};
|
2016-04-08 18:28:54 +02:00
|
|
|
}
|
|
|
|
|
2019-03-23 21:04:19 +01:00
|
|
|
WaitTreeObjectList::WaitTreeObjectList(const std::vector<std::shared_ptr<Kernel::WaitObject>>& list,
|
|
|
|
bool w_all)
|
2016-04-08 18:28:54 +02:00
|
|
|
: object_list(list), wait_all(w_all) {}
|
|
|
|
|
|
|
|
QString WaitTreeObjectList::GetText() const {
|
|
|
|
if (wait_all)
|
|
|
|
return tr("waiting for all objects");
|
|
|
|
return tr("waiting for one of the following objects");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeObjectList::GetChildren() const {
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> list(object_list.size());
|
|
|
|
std::transform(object_list.begin(), object_list.end(), list.begin(),
|
|
|
|
[](const auto& t) { return WaitTreeWaitObject::make(*t); });
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitTreeThread::WaitTreeThread(const Kernel::Thread& thread) : WaitTreeWaitObject(thread) {}
|
|
|
|
|
|
|
|
QString WaitTreeThread::GetText() const {
|
|
|
|
const auto& thread = static_cast<const Kernel::Thread&>(object);
|
|
|
|
QString status;
|
|
|
|
switch (thread.status) {
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::Running:
|
2016-04-08 18:28:54 +02:00
|
|
|
status = tr("running");
|
|
|
|
break;
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::Ready:
|
2016-04-08 18:28:54 +02:00
|
|
|
status = tr("ready");
|
|
|
|
break;
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::WaitArb:
|
2016-04-08 18:28:54 +02:00
|
|
|
status = tr("waiting for address 0x%1").arg(thread.wait_address, 8, 16, QLatin1Char('0'));
|
|
|
|
break;
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::WaitSleep:
|
2016-04-08 18:28:54 +02:00
|
|
|
status = tr("sleeping");
|
|
|
|
break;
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::WaitIPC:
|
2017-10-02 05:06:46 +02:00
|
|
|
status = tr("waiting for IPC response");
|
|
|
|
break;
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::WaitSynchAll:
|
|
|
|
case Kernel::ThreadStatus::WaitSynchAny:
|
2016-04-08 18:28:54 +02:00
|
|
|
status = tr("waiting for objects");
|
|
|
|
break;
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::WaitHleEvent:
|
2017-07-21 06:18:56 +02:00
|
|
|
status = tr("waiting for HLE return");
|
|
|
|
break;
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::Dormant:
|
2016-04-08 18:28:54 +02:00
|
|
|
status = tr("dormant");
|
|
|
|
break;
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::Dead:
|
2016-04-08 18:28:54 +02:00
|
|
|
status = tr("dead");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
QString pc_info = tr(" PC = 0x%1 LR = 0x%2")
|
2017-12-12 20:12:03 +01:00
|
|
|
.arg(thread.context->GetProgramCounter(), 8, 16, QLatin1Char('0'))
|
|
|
|
.arg(thread.context->GetLinkRegister(), 8, 16, QLatin1Char('0'));
|
2016-04-08 18:28:54 +02:00
|
|
|
return WaitTreeWaitObject::GetText() + pc_info + " (" + status + ") ";
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor WaitTreeThread::GetColor() const {
|
|
|
|
const auto& thread = static_cast<const Kernel::Thread&>(object);
|
|
|
|
switch (thread.status) {
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::Running:
|
2016-04-08 18:28:54 +02:00
|
|
|
return QColor(Qt::GlobalColor::darkGreen);
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::Ready:
|
2016-04-08 18:28:54 +02:00
|
|
|
return QColor(Qt::GlobalColor::darkBlue);
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::WaitArb:
|
2016-04-08 18:28:54 +02:00
|
|
|
return QColor(Qt::GlobalColor::darkRed);
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::WaitSleep:
|
2016-04-08 18:28:54 +02:00
|
|
|
return QColor(Qt::GlobalColor::darkYellow);
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::WaitIPC:
|
2017-10-02 05:06:46 +02:00
|
|
|
return QColor(Qt::GlobalColor::darkCyan);
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::WaitSynchAll:
|
|
|
|
case Kernel::ThreadStatus::WaitSynchAny:
|
|
|
|
case Kernel::ThreadStatus::WaitHleEvent:
|
2016-04-08 18:28:54 +02:00
|
|
|
return QColor(Qt::GlobalColor::red);
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::Dormant:
|
2016-04-08 18:28:54 +02:00
|
|
|
return QColor(Qt::GlobalColor::darkCyan);
|
2018-09-13 21:57:45 +02:00
|
|
|
case Kernel::ThreadStatus::Dead:
|
2016-04-08 18:28:54 +02:00
|
|
|
return QColor(Qt::GlobalColor::gray);
|
|
|
|
default:
|
|
|
|
return WaitTreeItem::GetColor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const {
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
|
|
|
|
|
|
|
|
const auto& thread = static_cast<const Kernel::Thread&>(object);
|
|
|
|
|
|
|
|
QString processor;
|
|
|
|
switch (thread.processor_id) {
|
2018-09-21 16:39:10 +02:00
|
|
|
case Kernel::ThreadProcessorId::ThreadProcessorIdDefault:
|
2016-04-08 18:28:54 +02:00
|
|
|
processor = tr("default");
|
|
|
|
break;
|
2018-09-21 16:39:10 +02:00
|
|
|
case Kernel::ThreadProcessorId::ThreadProcessorIdAll:
|
2016-04-08 18:28:54 +02:00
|
|
|
processor = tr("all");
|
|
|
|
break;
|
2018-09-21 16:39:10 +02:00
|
|
|
case Kernel::ThreadProcessorId::ThreadProcessorId0:
|
2016-04-08 18:28:54 +02:00
|
|
|
processor = tr("AppCore");
|
|
|
|
break;
|
2018-09-21 16:39:10 +02:00
|
|
|
case Kernel::ThreadProcessorId::ThreadProcessorId1:
|
2016-04-08 18:28:54 +02:00
|
|
|
processor = tr("SysCore");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
processor = tr("Unknown processor %1").arg(thread.processor_id);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
list.push_back(std::make_unique<WaitTreeText>(tr("processor = %1").arg(processor)));
|
|
|
|
list.push_back(std::make_unique<WaitTreeText>(tr("thread id = %1").arg(thread.GetThreadId())));
|
|
|
|
list.push_back(std::make_unique<WaitTreeText>(tr("priority = %1(current) / %2(normal)")
|
|
|
|
.arg(thread.current_priority)
|
|
|
|
.arg(thread.nominal_priority)));
|
|
|
|
list.push_back(std::make_unique<WaitTreeText>(
|
|
|
|
tr("last running ticks = %1").arg(thread.last_running_ticks)));
|
|
|
|
|
|
|
|
if (thread.held_mutexes.empty()) {
|
|
|
|
list.push_back(std::make_unique<WaitTreeText>(tr("not holding mutex")));
|
|
|
|
} else {
|
|
|
|
list.push_back(std::make_unique<WaitTreeMutexList>(thread.held_mutexes));
|
|
|
|
}
|
2018-09-13 21:57:45 +02:00
|
|
|
if (thread.status == Kernel::ThreadStatus::WaitSynchAny ||
|
|
|
|
thread.status == Kernel::ThreadStatus::WaitSynchAll ||
|
|
|
|
thread.status == Kernel::ThreadStatus::WaitHleEvent) {
|
2016-12-14 18:13:02 +01:00
|
|
|
list.push_back(std::make_unique<WaitTreeObjectList>(thread.wait_objects,
|
|
|
|
thread.IsSleepingOnWaitAll()));
|
2016-04-08 18:28:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitTreeEvent::WaitTreeEvent(const Kernel::Event& object) : WaitTreeWaitObject(object) {}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeEvent::GetChildren() const {
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
|
|
|
|
|
|
|
|
list.push_back(std::make_unique<WaitTreeText>(
|
|
|
|
tr("reset type = %1")
|
2018-08-24 19:43:29 +02:00
|
|
|
.arg(GetResetTypeQString(static_cast<const Kernel::Event&>(object).GetResetType()))));
|
2016-04-08 18:28:54 +02:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitTreeMutex::WaitTreeMutex(const Kernel::Mutex& object) : WaitTreeWaitObject(object) {}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutex::GetChildren() const {
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
|
|
|
|
|
|
|
|
const auto& mutex = static_cast<const Kernel::Mutex&>(object);
|
|
|
|
if (mutex.lock_count) {
|
|
|
|
list.push_back(
|
|
|
|
std::make_unique<WaitTreeText>(tr("locked %1 times by thread:").arg(mutex.lock_count)));
|
|
|
|
list.push_back(std::make_unique<WaitTreeThread>(*mutex.holding_thread));
|
|
|
|
} else {
|
|
|
|
list.push_back(std::make_unique<WaitTreeText>(tr("free")));
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitTreeSemaphore::WaitTreeSemaphore(const Kernel::Semaphore& object)
|
|
|
|
: WaitTreeWaitObject(object) {}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeSemaphore::GetChildren() const {
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
|
|
|
|
|
|
|
|
const auto& semaphore = static_cast<const Kernel::Semaphore&>(object);
|
|
|
|
list.push_back(
|
|
|
|
std::make_unique<WaitTreeText>(tr("available count = %1").arg(semaphore.available_count)));
|
|
|
|
list.push_back(std::make_unique<WaitTreeText>(tr("max count = %1").arg(semaphore.max_count)));
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitTreeTimer::WaitTreeTimer(const Kernel::Timer& object) : WaitTreeWaitObject(object) {}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeTimer::GetChildren() const {
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
|
|
|
|
|
|
|
|
const auto& timer = static_cast<const Kernel::Timer&>(object);
|
|
|
|
|
|
|
|
list.push_back(std::make_unique<WaitTreeText>(
|
2018-07-26 15:45:18 +02:00
|
|
|
tr("reset type = %1").arg(GetResetTypeQString(timer.GetResetType()))));
|
2016-04-08 18:28:54 +02:00
|
|
|
list.push_back(
|
2018-07-26 15:45:18 +02:00
|
|
|
std::make_unique<WaitTreeText>(tr("initial delay = %1").arg(timer.GetInitialDelay())));
|
2016-04-08 18:28:54 +02:00
|
|
|
list.push_back(
|
2018-07-26 15:45:18 +02:00
|
|
|
std::make_unique<WaitTreeText>(tr("interval delay = %1").arg(timer.GetIntervalDelay())));
|
2016-04-08 18:28:54 +02:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitTreeMutexList::WaitTreeMutexList(
|
2019-03-23 21:04:19 +01:00
|
|
|
const boost::container::flat_set<std::shared_ptr<Kernel::Mutex>>& list)
|
2016-04-08 18:28:54 +02:00
|
|
|
: mutex_list(list) {}
|
|
|
|
|
|
|
|
QString WaitTreeMutexList::GetText() const {
|
|
|
|
return tr("holding mutexes");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutexList::GetChildren() const {
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> list(mutex_list.size());
|
|
|
|
std::transform(mutex_list.begin(), mutex_list.end(), list.begin(),
|
|
|
|
[](const auto& t) { return std::make_unique<WaitTreeMutex>(*t); });
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2019-03-23 21:04:19 +01:00
|
|
|
WaitTreeThreadList::WaitTreeThreadList(const std::vector<std::shared_ptr<Kernel::Thread>>& list)
|
2016-04-08 18:28:54 +02:00
|
|
|
: thread_list(list) {}
|
|
|
|
|
|
|
|
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(),
|
|
|
|
[](const auto& t) { return std::make_unique<WaitTreeThread>(*t); });
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitTreeModel::WaitTreeModel(QObject* parent) : QAbstractItemModel(parent) {}
|
|
|
|
|
|
|
|
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() {
|
|
|
|
thread_items = WaitTreeItem::MakeThreadItemList();
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitTreeWidget::WaitTreeWidget(QWidget* parent) : QDockWidget(tr("Wait Tree"), parent) {
|
2019-07-25 21:50:36 +02:00
|
|
|
setObjectName(QStringLiteral("WaitTreeWidget"));
|
2016-04-08 18:28:54 +02:00
|
|
|
view = new QTreeView(this);
|
|
|
|
view->setHeaderHidden(true);
|
|
|
|
setWidget(view);
|
|
|
|
setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WaitTreeWidget::OnDebugModeEntered() {
|
2016-12-16 01:01:48 +01:00
|
|
|
if (!Core::System::GetInstance().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) {
|
|
|
|
model = new WaitTreeModel(this);
|
|
|
|
view->setModel(model);
|
|
|
|
setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WaitTreeWidget::OnEmulationStopping() {
|
|
|
|
view->setModel(nullptr);
|
|
|
|
delete model;
|
|
|
|
setEnabled(false);
|
|
|
|
}
|