yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0
This repository has been archived on 2024-03-23. You can view files and clone it, but cannot push or open issues or pull requests.
yuzu-android/src/yuzu/debugger/wait_tree.h

200 lines
5.1 KiB
C++
Raw Normal View History

2016-04-08 16:28:54 +00:00
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <cstddef>
#include <memory>
#include <vector>
2016-04-08 16:28:54 +00:00
#include <QAbstractItemModel>
#include <QDockWidget>
#include <QTreeView>
#include "common/common_types.h"
#include "core/hle/kernel/object.h"
2016-04-08 16:28:54 +00:00
class EmuThread;
namespace Kernel {
class HandleTable;
class KSynchronizationObject;
class ReadableEvent;
2016-04-08 16:28:54 +00:00
class Thread;
} // namespace Kernel
2016-04-08 16:28:54 +00:00
class WaitTreeThread;
class WaitTreeItem : public QObject {
Q_OBJECT
public:
WaitTreeItem();
~WaitTreeItem() override;
2016-04-08 16:28:54 +00:00
virtual bool IsExpandable() const;
virtual std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const;
virtual QString GetText() const = 0;
virtual QColor GetColor() const;
2016-04-08 16:28:54 +00: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:
explicit WaitTreeText(QString text);
~WaitTreeText() override;
2016-04-08 16:28:54 +00:00
QString GetText() const override;
private:
QString text;
};
class WaitTreeExpandableItem : public WaitTreeItem {
Q_OBJECT
public:
WaitTreeExpandableItem();
~WaitTreeExpandableItem() override;
2016-04-08 16:28:54 +00:00
bool IsExpandable() const override;
};
class WaitTreeMutexInfo : public WaitTreeExpandableItem {
Q_OBJECT
public:
explicit WaitTreeMutexInfo(VAddr mutex_address, const Kernel::HandleTable& handle_table);
~WaitTreeMutexInfo() override;
QString GetText() const override;
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
private:
VAddr mutex_address;
u32 mutex_value;
Kernel::Handle owner_handle;
std::shared_ptr<Kernel::Thread> owner;
};
class WaitTreeCallstack : public WaitTreeExpandableItem {
Q_OBJECT
public:
explicit WaitTreeCallstack(const Kernel::Thread& thread);
~WaitTreeCallstack() override;
QString GetText() const override;
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
private:
const Kernel::Thread& thread;
};
class WaitTreeSynchronizationObject : public WaitTreeExpandableItem {
2016-04-08 16:28:54 +00:00
Q_OBJECT
public:
explicit WaitTreeSynchronizationObject(const Kernel::KSynchronizationObject& object);
~WaitTreeSynchronizationObject() override;
static std::unique_ptr<WaitTreeSynchronizationObject> make(
const Kernel::KSynchronizationObject& object);
2016-04-08 16:28:54 +00:00
QString GetText() const override;
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
protected:
const Kernel::KSynchronizationObject& object;
2016-04-08 16:28:54 +00:00
};
class WaitTreeObjectList : public WaitTreeExpandableItem {
Q_OBJECT
public:
WaitTreeObjectList(const std::vector<Kernel::KSynchronizationObject*>& list, bool wait_all);
~WaitTreeObjectList() override;
2016-04-08 16:28:54 +00:00
QString GetText() const override;
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
private:
const std::vector<Kernel::KSynchronizationObject*>& object_list;
2016-04-08 16:28:54 +00:00
bool wait_all;
};
class WaitTreeThread : public WaitTreeSynchronizationObject {
2016-04-08 16:28:54 +00:00
Q_OBJECT
public:
explicit WaitTreeThread(const Kernel::Thread& thread);
~WaitTreeThread() override;
2016-04-08 16:28:54 +00:00
QString GetText() const override;
QColor GetColor() const override;
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
};
class WaitTreeEvent : public WaitTreeSynchronizationObject {
2016-04-08 16:28:54 +00:00
Q_OBJECT
public:
explicit WaitTreeEvent(const Kernel::ReadableEvent& object);
~WaitTreeEvent() override;
2016-04-08 16:28:54 +00:00
};
class WaitTreeThreadList : public WaitTreeExpandableItem {
Q_OBJECT
public:
explicit WaitTreeThreadList(const std::vector<Kernel::Thread*>& list);
~WaitTreeThreadList() override;
2016-04-08 16:28:54 +00:00
QString GetText() const override;
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
private:
const std::vector<Kernel::Thread*>& thread_list;
2016-04-08 16:28:54 +00:00
};
class WaitTreeModel : public QAbstractItemModel {
Q_OBJECT
public:
explicit WaitTreeModel(QObject* parent = nullptr);
~WaitTreeModel() override;
2016-04-08 16:28:54 +00: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:
explicit WaitTreeWidget(QWidget* parent = nullptr);
~WaitTreeWidget() override;
2016-04-08 16:28:54 +00:00
public slots:
void OnDebugModeEntered();
void OnDebugModeLeft();
void OnEmulationStarting(EmuThread* emu_thread);
void OnEmulationStopping();
private:
QTreeView* view;
WaitTreeModel* model;
};