2016-04-08 17:28:54 +01:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2016-12-11 11:53:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-08-31 17:21:34 +01:00
|
|
|
#include <cstddef>
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-04-08 17:28:54 +01:00
|
|
|
#include <QAbstractItemModel>
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QTreeView>
|
2018-08-31 17:21:34 +01:00
|
|
|
#include "common/common_types.h"
|
2018-08-02 03:40:00 +01:00
|
|
|
#include "core/hle/kernel/object.h"
|
2016-04-08 17:28:54 +01:00
|
|
|
|
|
|
|
class EmuThread;
|
|
|
|
|
|
|
|
namespace Kernel {
|
2018-11-27 14:18:29 +00:00
|
|
|
class ReadableEvent;
|
2016-04-08 17:28:54 +01:00
|
|
|
class WaitObject;
|
|
|
|
class Thread;
|
2018-01-20 07:48:02 +00:00
|
|
|
} // namespace Kernel
|
2016-04-08 17:28:54 +01:00
|
|
|
|
|
|
|
class WaitTreeThread;
|
|
|
|
|
|
|
|
class WaitTreeItem : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-08-31 17:21:34 +01:00
|
|
|
WaitTreeItem();
|
2018-08-06 18:12:32 +01:00
|
|
|
~WaitTreeItem() override;
|
|
|
|
|
2016-04-08 17:28:54 +01:00
|
|
|
virtual bool IsExpandable() const;
|
|
|
|
virtual std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const;
|
|
|
|
virtual QString GetText() const = 0;
|
|
|
|
virtual QColor GetColor() const;
|
2018-08-06 18:12:32 +01:00
|
|
|
|
2016-04-08 17:28:54 +01:00
|
|
|
void Expand();
|
|
|
|
WaitTreeItem* Parent() const;
|
|
|
|
const std::vector<std::unique_ptr<WaitTreeItem>>& Children() const;
|
|
|
|
std::size_t Row() const;
|
|
|
|
static std::vector<std::unique_ptr<WaitTreeThread>> MakeThreadItemList();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::size_t row;
|
|
|
|
bool expanded = false;
|
|
|
|
WaitTreeItem* parent = nullptr;
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> children;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaitTreeText : public WaitTreeItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-12-05 20:59:48 +00:00
|
|
|
explicit WaitTreeText(QString text);
|
2018-08-31 17:21:34 +01:00
|
|
|
~WaitTreeText() override;
|
|
|
|
|
2016-04-08 17:28:54 +01:00
|
|
|
QString GetText() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString text;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaitTreeExpandableItem : public WaitTreeItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-08-31 17:21:34 +01:00
|
|
|
WaitTreeExpandableItem();
|
|
|
|
~WaitTreeExpandableItem() override;
|
|
|
|
|
2016-04-08 17:28:54 +01:00
|
|
|
bool IsExpandable() const override;
|
|
|
|
};
|
|
|
|
|
2018-04-20 21:52:06 +01:00
|
|
|
class WaitTreeMutexInfo : public WaitTreeExpandableItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit WaitTreeMutexInfo(VAddr mutex_address);
|
2018-08-31 17:21:34 +01:00
|
|
|
~WaitTreeMutexInfo() override;
|
|
|
|
|
2018-04-20 21:52:06 +01:00
|
|
|
QString GetText() const override;
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
VAddr mutex_address;
|
|
|
|
u32 mutex_value;
|
|
|
|
Kernel::Handle owner_handle;
|
|
|
|
Kernel::SharedPtr<Kernel::Thread> owner;
|
|
|
|
};
|
|
|
|
|
2018-05-19 22:52:49 +01:00
|
|
|
class WaitTreeCallstack : public WaitTreeExpandableItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit WaitTreeCallstack(const Kernel::Thread& thread);
|
2018-08-31 17:21:34 +01:00
|
|
|
~WaitTreeCallstack() override;
|
|
|
|
|
2018-05-19 22:52:49 +01:00
|
|
|
QString GetText() const override;
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Kernel::Thread& thread;
|
|
|
|
};
|
|
|
|
|
2016-04-08 17:28:54 +01:00
|
|
|
class WaitTreeWaitObject : public WaitTreeExpandableItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2016-12-11 12:22:10 +00:00
|
|
|
explicit WaitTreeWaitObject(const Kernel::WaitObject& object);
|
2018-08-31 17:21:34 +01:00
|
|
|
~WaitTreeWaitObject() override;
|
|
|
|
|
2016-04-08 17:28:54 +01:00
|
|
|
static std::unique_ptr<WaitTreeWaitObject> make(const Kernel::WaitObject& object);
|
|
|
|
QString GetText() const override;
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const Kernel::WaitObject& object;
|
|
|
|
|
|
|
|
static QString GetResetTypeQString(Kernel::ResetType reset_type);
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaitTreeObjectList : public WaitTreeExpandableItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
WaitTreeObjectList(const std::vector<Kernel::SharedPtr<Kernel::WaitObject>>& list,
|
|
|
|
bool wait_all);
|
2018-08-31 17:21:34 +01:00
|
|
|
~WaitTreeObjectList() override;
|
|
|
|
|
2016-04-08 17:28:54 +01:00
|
|
|
QString GetText() const override;
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const std::vector<Kernel::SharedPtr<Kernel::WaitObject>>& object_list;
|
|
|
|
bool wait_all;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaitTreeThread : public WaitTreeWaitObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2016-12-11 12:22:10 +00:00
|
|
|
explicit WaitTreeThread(const Kernel::Thread& thread);
|
2018-08-31 17:21:34 +01:00
|
|
|
~WaitTreeThread() override;
|
|
|
|
|
2016-04-08 17:28:54 +01:00
|
|
|
QString GetText() const override;
|
|
|
|
QColor GetColor() const override;
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaitTreeEvent : public WaitTreeWaitObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-11-27 14:18:29 +00:00
|
|
|
explicit WaitTreeEvent(const Kernel::ReadableEvent& object);
|
2018-08-31 17:21:34 +01:00
|
|
|
~WaitTreeEvent() override;
|
|
|
|
|
2016-04-08 17:28:54 +01:00
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaitTreeThreadList : public WaitTreeExpandableItem {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2016-12-11 12:22:10 +00:00
|
|
|
explicit WaitTreeThreadList(const std::vector<Kernel::SharedPtr<Kernel::Thread>>& list);
|
2018-08-31 17:21:34 +01:00
|
|
|
~WaitTreeThreadList() override;
|
|
|
|
|
2016-04-08 17:28:54 +01:00
|
|
|
QString GetText() const override;
|
|
|
|
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const std::vector<Kernel::SharedPtr<Kernel::Thread>>& thread_list;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaitTreeModel : public QAbstractItemModel {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-12-11 12:22:10 +00:00
|
|
|
explicit WaitTreeModel(QObject* parent = nullptr);
|
2018-08-31 17:21:34 +01:00
|
|
|
~WaitTreeModel() override;
|
2016-04-08 17:28:54 +01:00
|
|
|
|
|
|
|
QVariant data(const QModelIndex& index, int role) const override;
|
|
|
|
QModelIndex index(int row, int column, const QModelIndex& parent) const override;
|
|
|
|
QModelIndex parent(const QModelIndex& index) const override;
|
|
|
|
int rowCount(const QModelIndex& parent) const override;
|
|
|
|
int columnCount(const QModelIndex& parent) const override;
|
|
|
|
|
|
|
|
void ClearItems();
|
|
|
|
void InitItems();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<std::unique_ptr<WaitTreeThread>> thread_items;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaitTreeWidget : public QDockWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-12-11 12:22:10 +00:00
|
|
|
explicit WaitTreeWidget(QWidget* parent = nullptr);
|
2018-08-31 17:21:34 +01:00
|
|
|
~WaitTreeWidget() override;
|
2016-04-08 17:28:54 +01:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void OnDebugModeEntered();
|
|
|
|
void OnDebugModeLeft();
|
|
|
|
|
|
|
|
void OnEmulationStarting(EmuThread* emu_thread);
|
|
|
|
void OnEmulationStopping();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QTreeView* view;
|
|
|
|
WaitTreeModel* model;
|
|
|
|
};
|