Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debugger: Implement F1 helper #9637

Merged
merged 2 commits into from
Jan 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 48 additions & 11 deletions rpcs3/rpcs3qt/debugger_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,47 @@ void debugger_frame::hideEvent(QHideEvent * event)

void debugger_frame::keyPressEvent(QKeyEvent* event)
{
if (!isActiveWindow())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be at the beginning of the function, and the cpu and currentRow stuff after your new switch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

{
return;
}

const auto cpu = this->cpu.lock();
int i = m_debugger_list->currentRow();

if (!isActiveWindow() || !cpu)
switch (event->key())
{
case Qt::Key_F1:
{
QDialog* dlg = new QDialog(this);
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->setWindowTitle(tr("Debugger Guide & Shortcuts"));

QLabel* l = new QLabel(tr(
"Keys Ctrl+G: Go to typed address."
"\nKeys Alt+S: Capture SPU images of selected SPU."
"\nKey E: Instruction Editor: click on the instruction you want to modify, then press E."
"\nKey F: Dedicated floating point mode switch for SPU threads."
"\nKey R: Registers Editor for selected thread."
"\nKey N: Show next instruction the thread will execute after marked instruction, does nothing if target is not predictable."
"\nKey M: Show the Memory Viewer with initial address pointing to the marked instruction."
"\nKey F10: Perform single-stepping on instructions."
"\nKey F11: Perform step-over on instructions. (skip function calls)"
"\nKey F1: Show this help dialog."));

l->setFont([](QFont f) { f.setPointSize(9); return f; }(l->font()));

QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget(l);
dlg->setLayout(layout);
dlg->setFixedSize(dlg->sizeHint());
dlg->move(QCursor::pos());
dlg->exec();
return;
}
}

if (!cpu)
{
return;
}
Expand Down Expand Up @@ -564,17 +601,17 @@ void debugger_frame::WritePanels()

void debugger_frame::ShowGotoAddressDialog()
{
QDialog* diag = new QDialog(this);
diag->setWindowTitle(tr("Go To Address"));
diag->setModal(true);
QDialog* dlg = new QDialog(this);
dlg->setWindowTitle(tr("Go To Address"));
dlg->setModal(true);

// Panels
QVBoxLayout* vbox_panel(new QVBoxLayout());
QHBoxLayout* hbox_expression_input_panel = new QHBoxLayout();
QHBoxLayout* hbox_button_panel(new QHBoxLayout());

// Address expression input
QLineEdit* expression_input(new QLineEdit(diag));
QLineEdit* expression_input(new QLineEdit(dlg));
expression_input->setFont(m_mono);
expression_input->setMaxLength(18);

Expand All @@ -600,7 +637,7 @@ void debugger_frame::ShowGotoAddressDialog()
vbox_panel->addSpacing(8);
vbox_panel->addLayout(hbox_button_panel);

diag->setLayout(vbox_panel);
dlg->setLayout(vbox_panel);

const auto cpu = this->cpu.lock();
const QFont font = expression_input->font();
Expand All @@ -610,18 +647,18 @@ void debugger_frame::ShowGotoAddressDialog()
expression_input->setPlaceholderText(QString("0x%1").arg(pc, 16, 16, QChar('0')));
expression_input->setFixedWidth(gui::utils::get_label_width(expression_input->placeholderText(), &font));

connect(button_ok, &QAbstractButton::clicked, diag, &QDialog::accept);
connect(button_cancel, &QAbstractButton::clicked, diag, &QDialog::reject);
connect(button_ok, &QAbstractButton::clicked, dlg, &QDialog::accept);
connect(button_cancel, &QAbstractButton::clicked, dlg, &QDialog::reject);

diag->move(QCursor::pos());
dlg->move(QCursor::pos());

if (diag->exec() == QDialog::Accepted)
if (dlg->exec() == QDialog::Accepted)
{
const u32 address = EvaluateExpression(expression_input->text());
m_debugger_list->ShowAddress(address);
}

diag->deleteLater();
dlg->deleteLater();
}

u64 debugger_frame::EvaluateExpression(const QString& expression)
Expand Down