1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 20:22:30 +01:00

Qt: some cleanup in debugger

This commit is contained in:
Megamouse 2021-03-23 20:39:39 +01:00
parent b3fb6d7d18
commit ba45daff35
13 changed files with 82 additions and 96 deletions

View File

@ -479,7 +479,7 @@ static bool ppu_break(ppu_thread& ppu, ppu_opcode_t)
}
// Set or remove breakpoint
extern void ppu_breakpoint(u32 addr, bool isAdding)
extern void ppu_breakpoint(u32 addr, bool is_adding)
{
if (g_cfg.core.ppu_decoder == ppu_decoder_type::llvm)
{
@ -488,7 +488,7 @@ extern void ppu_breakpoint(u32 addr, bool isAdding)
const u64 _break = reinterpret_cast<uptr>(&ppu_break);
if (isAdding)
if (is_adding)
{
// Set breakpoint
ppu_ref(addr) = _break;

View File

@ -19,14 +19,14 @@ auto_pause_settings_dialog::auto_pause_settings_dialog(QWidget *parent) : QDialo
{
QLabel *description = new QLabel(tr("To use auto pause: enter the ID(s) of a function or a system call.\nRestart of the game is required to apply. You can enable/disable this in the settings."), this);
pauseList = new QTableWidget(this);
pauseList->setColumnCount(2);
pauseList->setHorizontalHeaderLabels(QStringList() << tr("Call ID") << tr("Type"));
//pauseList->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
pauseList->setSelectionBehavior(QAbstractItemView::SelectRows);
pauseList->setContextMenuPolicy(Qt::CustomContextMenu);
pauseList->setItemDelegate(new table_item_delegate(this));
pauseList->setShowGrid(false);
m_pause_list = new QTableWidget(this);
m_pause_list->setColumnCount(2);
m_pause_list->setHorizontalHeaderLabels(QStringList() << tr("Call ID") << tr("Type"));
//m_pause_list->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
m_pause_list->setSelectionBehavior(QAbstractItemView::SelectRows);
m_pause_list->setContextMenuPolicy(Qt::CustomContextMenu);
m_pause_list->setItemDelegate(new table_item_delegate(this));
m_pause_list->setShowGrid(false);
QPushButton *clearButton = new QPushButton(tr("Clear"), this);
QPushButton *reloadButton = new QPushButton(tr("Reload"), this);
@ -43,7 +43,7 @@ auto_pause_settings_dialog::auto_pause_settings_dialog(QWidget *parent) : QDialo
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(description);
mainLayout->addWidget(pauseList);
mainLayout->addWidget(m_pause_list);
mainLayout->addLayout(buttonsLayout);
setLayout(mainLayout);
@ -52,7 +52,7 @@ auto_pause_settings_dialog::auto_pause_settings_dialog(QWidget *parent) : QDialo
setObjectName("auto_pause_manager");
// Events
connect(pauseList, &QTableWidget::customContextMenuRequested, this, &auto_pause_settings_dialog::ShowContextMenu);
connect(m_pause_list, &QTableWidget::customContextMenuRequested, this, &auto_pause_settings_dialog::ShowContextMenu);
connect(clearButton, &QAbstractButton::clicked, [this](){ m_entries.clear(); UpdateList(); });
connect(reloadButton, &QAbstractButton::clicked, [this](){ LoadEntries(); UpdateList(); });
connect(saveButton, &QAbstractButton::clicked, [this]()
@ -118,8 +118,8 @@ void auto_pause_settings_dialog::SaveEntries(void)
void auto_pause_settings_dialog::UpdateList(void)
{
const int entries_size = static_cast<int>(m_entries.size());
pauseList->clearContents();
pauseList->setRowCount(entries_size);
m_pause_list->clearContents();
m_pause_list->setRowCount(entries_size);
for (int i = 0; i < entries_size; ++i)
{
QTableWidgetItem* callItem = new QTableWidgetItem;
@ -144,14 +144,14 @@ void auto_pause_settings_dialog::UpdateList(void)
typeItem->setData(Qt::DisplayRole, tr("Function Call"));
}
pauseList->setItem(i, 0, callItem);
pauseList->setItem(i, 1, typeItem);
m_pause_list->setItem(i, 0, callItem);
m_pause_list->setItem(i, 1, typeItem);
}
}
void auto_pause_settings_dialog::ShowContextMenu(const QPoint &pos)
{
const int row = pauseList->indexAt(pos).row();
const int row = m_pause_list->indexAt(pos).row();
QMenu myMenu;
@ -175,22 +175,23 @@ void auto_pause_settings_dialog::ShowContextMenu(const QPoint &pos)
UpdateList();
};
connect(add, &QAction::triggered, [=, this]() {
connect(add, &QAction::triggered, this, [=, this]()
{
m_entries.emplace_back(0xFFFFFFFF);
UpdateList();
int idx = static_cast<int>(m_entries.size()) - 1;
pauseList->selectRow(idx);
m_pause_list->selectRow(idx);
OnEntryConfig(idx, true);
});
connect(remove, &QAction::triggered, this, &auto_pause_settings_dialog::OnRemove);
connect(config, &QAction::triggered, [=, this]() {OnEntryConfig(row, false); });
connect(config, &QAction::triggered, this, [=, this]() {OnEntryConfig(row, false); });
myMenu.exec(pauseList->viewport()->mapToGlobal(pos));
myMenu.exec(m_pause_list->viewport()->mapToGlobal(pos));
}
void auto_pause_settings_dialog::OnRemove()
{
QModelIndexList selection = pauseList->selectionModel()->selectedRows();
QModelIndexList selection = m_pause_list->selectionModel()->selectedRows();
std::sort(selection.begin(), selection.end());
for (int i = selection.count() - 1; i >= 0; i--)
{

View File

@ -20,10 +20,10 @@ class auto_pause_settings_dialog : public QDialog
};
std::vector<u32> m_entries;
QTableWidget *m_pause_list;
public:
explicit auto_pause_settings_dialog(QWidget* parent);
QTableWidget *pauseList;
void UpdateList(void);
void LoadEntries(void);
void SaveEntries(void);

View File

@ -1,20 +1,18 @@
#include "breakpoint_handler.h"
extern void ppu_breakpoint(u32 loc, bool isAdding);
extern void ppu_breakpoint(u32 loc, bool is_adding);
breakpoint_handler::breakpoint_handler() :m_breakpoints()
breakpoint_handler::breakpoint_handler()
{
}
breakpoint_handler::~breakpoint_handler()
{
}
bool breakpoint_handler::HasBreakpoint(u32 loc) const
{
return m_breakpoints.find(loc) != m_breakpoints.end();
return m_breakpoints.contains(loc);
}
bool breakpoint_handler::AddBreakpoint(u32 loc)

View File

@ -31,7 +31,6 @@ public:
*/
bool AddBreakpoint(u32 loc);
/**
* Returns true if removed breakpoint at loc successfully.
*/

View File

@ -64,17 +64,14 @@ void breakpoint_list::AddBreakpoint(u32 pc)
m_disasm->disasm(pc);
QString breakpointItemText = qstr(m_disasm->last_opcode);
QString text = qstr(m_disasm->last_opcode);
text.remove(10, 13);
breakpointItemText.remove(10, 13);
QListWidgetItem* breakpointItem = new QListWidgetItem(breakpointItemText);
breakpointItem->setForeground(m_text_color_bp);
breakpointItem->setBackground(m_color_bp);
QVariant pcVariant;
pcVariant.setValue(pc);
breakpointItem->setData(Qt::UserRole, pcVariant);
addItem(breakpointItem);
QListWidgetItem* breakpoint_item = new QListWidgetItem(text);
breakpoint_item->setForeground(m_text_color_bp);
breakpoint_item->setBackground(m_color_bp);
breakpoint_item->setData(Qt::UserRole, pc);
addItem(breakpoint_item);
Q_EMIT RequestShowAddress(pc);
}
@ -102,7 +99,7 @@ void breakpoint_list::HandleBreakpointRequest(u32 loc)
void breakpoint_list::OnBreakpointListDoubleClicked()
{
u32 address = currentItem()->data(Qt::UserRole).value<u32>();
const u32 address = currentItem()->data(Qt::UserRole).value<u32>();
Q_EMIT RequestShowAddress(address);
}
@ -117,36 +114,28 @@ void breakpoint_list::OnBreakpointListRightClicked(const QPoint &pos)
if (selectedItems().count() == 1)
{
menu->addAction("Rename");
QAction* rename_action = menu->addAction(tr("&Rename"));
connect(rename_action, &QAction::triggered, this, [this]()
{
QListWidgetItem* current_item = selectedItems().first();
current_item->setFlags(current_item->flags() | Qt::ItemIsEditable);
editItem(current_item);
});
menu->addSeparator();
}
QAction* m_breakpoint_list_delete = new QAction("Delete", this);
m_breakpoint_list_delete->setShortcut(Qt::Key_Delete);
m_breakpoint_list_delete->setShortcutContext(Qt::WidgetShortcut);
addAction(m_breakpoint_list_delete);
connect(m_breakpoint_list_delete, &QAction::triggered, this, &breakpoint_list::OnBreakpointListDelete);
QAction* delete_action = new QAction(tr("&Delete"), this);
delete_action->setShortcut(Qt::Key_Delete);
delete_action->setShortcutContext(Qt::WidgetShortcut);
connect(delete_action, &QAction::triggered, this, &breakpoint_list::OnBreakpointListDelete);
menu->addAction(delete_action);
menu->addAction(m_breakpoint_list_delete);
QAction* selectedItem = menu->exec(viewport()->mapToGlobal(pos));
if (selectedItem)
{
if (selectedItem->text() == "Rename")
{
QListWidgetItem* currentItem = selectedItems().at(0);
currentItem->setFlags(currentItem->flags() | Qt::ItemIsEditable);
editItem(currentItem);
}
}
menu->exec(viewport()->mapToGlobal(pos));
}
void breakpoint_list::OnBreakpointListDelete()
{
int selectedCount = selectedItems().count();
for (int i = selectedCount - 1; i >= 0; i--)
for (int i = selectedItems().count() - 1; i >= 0; i--)
{
RemoveBreakpoint(item(i)->data(Qt::UserRole).value<u32>());
}

View File

@ -20,10 +20,10 @@ void call_stack_list::HandleUpdate(std::vector<std::pair<u32, u32>> call_stack)
for (const auto& addr : call_stack)
{
const QString call_stack_item_text = qstr(fmt::format("0x%08llx (sp=0x%08llx)", addr.first, addr.second));
QListWidgetItem* callStackItem = new QListWidgetItem(call_stack_item_text);
callStackItem->setData(Qt::UserRole, { addr.first });
addItem(callStackItem);
const QString text = qstr(fmt::format("0x%08llx (sp=0x%08llx)", addr.first, addr.second));
QListWidgetItem* call_stack_item = new QListWidgetItem(text);
call_stack_item->setData(Qt::UserRole, { addr.first });
addItem(call_stack_item);
}
}

View File

@ -3,7 +3,6 @@
#include "util/types.hpp"
#include <QListWidget>
#include <memory>
#include <vector>
class cpu_thread;

View File

@ -16,7 +16,8 @@ LOG_CHANNEL(gui_log, "GUI");
constexpr auto qstr = QString::fromStdString;
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
cg_disasm_window::cg_disasm_window(std::shared_ptr<gui_settings> xSettings): xgui_settings(xSettings)
cg_disasm_window::cg_disasm_window(std::shared_ptr<gui_settings> xSettings)
: m_gui_settings(xSettings)
{
setWindowTitle(tr("Cg Disasm"));
setObjectName("cg_disasm");
@ -26,7 +27,7 @@ cg_disasm_window::cg_disasm_window(std::shared_ptr<gui_settings> xSettings): xgu
setMinimumSize(QSize(200, 150)); // seems fine on win 10
resize(QSize(620, 395));
m_path_last = xgui_settings->GetValue(gui::fd_cg_disasm).toString();
m_path_last = m_gui_settings->GetValue(gui::fd_cg_disasm).toString();
m_disasm_text = new QTextEdit(this);
m_disasm_text->setReadOnly(true);
@ -114,7 +115,7 @@ void cg_disasm_window::ShowDisasm()
disasm.BuildShaderBody();
m_disasm_text->setText(qstr(disasm.GetArbShader()));
m_glsl_text->setText(qstr(disasm.GetGlslShader()));
xgui_settings->SetValue(gui::fd_cg_disasm, m_path_last);
m_gui_settings->SetValue(gui::fd_cg_disasm, m_path_last);
}
else if (!m_path_last.isEmpty())
{

View File

@ -26,9 +26,7 @@ private:
QTextEdit* m_disasm_text;
QTextEdit* m_glsl_text;
QAction *openCgBinaryProgram;
std::shared_ptr<gui_settings> xgui_settings;
std::shared_ptr<gui_settings> m_gui_settings;
AsmHighlighter* sh_asm;
GlslHighlighter* sh_glsl;

View File

@ -21,7 +21,7 @@ constexpr auto qstr = QString::fromStdString;
debugger_list::debugger_list(QWidget* parent, std::shared_ptr<gui_settings> settings, breakpoint_handler* handler)
: QListWidget(parent)
, xgui_settings(settings)
, m_gui_settings(settings)
, m_breakpoint_handler(handler)
{
setWindowTitle(tr("ASM"));
@ -50,7 +50,7 @@ void debugger_list::ShowAddress(u32 addr, bool force)
return m_cpu && m_cpu->id_type() == 1 && m_breakpoint_handler->HasBreakpoint(pc);
};
bool center_pc = xgui_settings->GetValue(gui::d_centerPC).toBool();
bool center_pc = m_gui_settings->GetValue(gui::d_centerPC).toBool();
// How many spaces addr can move down without us needing to move the entire view
const u32 addr_margin = (m_item_count / (center_pc ? 2 : 1) - 4); // 4 is just a buffer of 4 spaces at the bottom
@ -74,16 +74,17 @@ void debugger_list::ShowAddress(u32 addr, bool force)
}
}
const auto default_foreground = palette().color(foregroundRole());
const auto default_background = palette().color(backgroundRole());
const auto& default_foreground = palette().color(foregroundRole());
const auto& default_background = palette().color(backgroundRole());
if (!m_cpu || !m_disasm || +m_cpu->state + cpu_flag::exit + cpu_flag::wait == +m_cpu->state)
{
for (uint i = 0; i < m_item_count; ++i)
{
item(i)->setText(qstr(fmt::format(" [%08x] ?? ?? ?? ??:", 0)));
item(i)->setForeground(default_foreground);
item(i)->setBackground(default_background);
QListWidgetItem* list_item = item(i);
list_item->setText(qstr(fmt::format(" [%08x] ?? ?? ?? ??:", 0)));
list_item->setForeground(default_foreground);
list_item->setBackground(default_background);
}
}
else
@ -95,25 +96,27 @@ void debugger_list::ShowAddress(u32 addr, bool force)
for (uint i = 0, count = 4; i < m_item_count; ++i, pc = (pc + count) & address_limits)
{
QListWidgetItem* list_item = item(i);
if (m_cpu->is_paused() && pc == m_cpu->get_pc())
{
item(i)->setForeground(m_text_color_pc);
item(i)->setBackground(m_color_pc);
list_item->setForeground(m_text_color_pc);
list_item->setBackground(m_color_pc);
}
else if (IsBreakpoint(pc))
{
item(i)->setForeground(m_text_color_bp);
item(i)->setBackground(m_color_bp);
list_item->setForeground(m_text_color_bp);
list_item->setBackground(m_color_bp);
}
else
{
item(i)->setForeground(default_foreground);
item(i)->setBackground(default_background);
list_item->setForeground(default_foreground);
list_item->setBackground(default_background);
}
if (m_cpu->id_type() == 1 && !vm::check_addr(pc, 0))
{
item(i)->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(fmt::format("[%08x] ?? ?? ?? ??:", pc)));
list_item->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(fmt::format("[%08x] ?? ?? ?? ??:", pc)));
count = 4;
continue;
}
@ -121,7 +124,7 @@ void debugger_list::ShowAddress(u32 addr, bool force)
if (m_cpu->id_type() == 1 && !vm::check_addr(pc, vm::page_executable))
{
const u32 data = *vm::get_super_ptr<atomic_be_t<u32>>(pc);
item(i)->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(fmt::format("[%08x] %02x %02x %02x %02x:", pc,
list_item->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(fmt::format("[%08x] %02x %02x %02x %02x:", pc,
static_cast<u8>(data >> 24),
static_cast<u8>(data >> 16),
static_cast<u8>(data >> 8),
@ -134,12 +137,12 @@ void debugger_list::ShowAddress(u32 addr, bool force)
if (!count)
{
item(i)->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(fmt::format("[%08x] ??? ?? ??", pc)));
list_item->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(fmt::format("[%08x] ??? ?? ??", pc)));
count = 4;
continue;
}
item(i)->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(m_disasm->last_opcode));
list_item->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(m_disasm->last_opcode));
}
}
@ -250,7 +253,7 @@ void debugger_list::mouseDoubleClickEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton)
{
int i = currentRow();
const int i = currentRow();
if (i < 0) return;
const u32 pc = m_pc + i * 4;

View File

@ -46,7 +46,7 @@ private:
*/
u32 GetCenteredAddress(u32 address) const;
std::shared_ptr<gui_settings> xgui_settings;
std::shared_ptr<gui_settings> m_gui_settings;
breakpoint_handler* m_breakpoint_handler;
cpu_thread* m_cpu = nullptr;

View File

@ -6,8 +6,6 @@
#include <QLineEdit>
#include <QLabel>
#include <memory>
class CPUDisAsm;
class cpu_thread;