NewBreakpointDialog: Add a help message for conditionals.

This commit is contained in:
TryTwo 2022-10-08 13:23:24 -07:00
parent 85cb4d1bc5
commit 1ed6028af4
2 changed files with 50 additions and 1 deletions

View File

@ -11,6 +11,7 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QRadioButton>
#include <QVBoxLayout>
@ -36,12 +37,18 @@ void NewBreakpointDialog::CreateWidgets()
auto* type_group = new QButtonGroup(this);
// Instruction BP
auto* top_layout = new QHBoxLayout;
m_instruction_bp = new QRadioButton(tr("Instruction Breakpoint"));
m_instruction_bp->setChecked(true);
type_group->addButton(m_instruction_bp);
m_instruction_box = new QGroupBox;
m_instruction_address = new QLineEdit;
m_instruction_condition = new QLineEdit;
m_cond_help_btn = new QPushButton(tr("Help"));
top_layout->addWidget(m_instruction_bp);
top_layout->addStretch();
top_layout->addWidget(m_cond_help_btn);
auto* instruction_layout = new QGridLayout;
m_instruction_box->setLayout(instruction_layout);
@ -106,7 +113,7 @@ void NewBreakpointDialog::CreateWidgets()
auto* layout = new QVBoxLayout;
layout->addWidget(m_instruction_bp);
layout->addLayout(top_layout);
layout->addWidget(m_instruction_box);
layout->addWidget(m_memory_bp);
layout->addWidget(m_memory_box);
@ -123,6 +130,8 @@ void NewBreakpointDialog::ConnectWidgets()
connect(m_buttons, &QDialogButtonBox::accepted, this, &NewBreakpointDialog::accept);
connect(m_buttons, &QDialogButtonBox::rejected, this, &NewBreakpointDialog::reject);
connect(m_cond_help_btn, &QPushButton::clicked, this, &NewBreakpointDialog::ShowConditionHelp);
connect(m_instruction_bp, &QRadioButton::toggled, this, &NewBreakpointDialog::OnBPTypeChanged);
connect(m_memory_bp, &QRadioButton::toggled, this, &NewBreakpointDialog::OnBPTypeChanged);
@ -217,3 +226,41 @@ void NewBreakpointDialog::accept()
QDialog::accept();
}
void NewBreakpointDialog::ShowConditionHelp()
{
const auto message = QStringLiteral(
"Set a code breakpoint for when an instruction is executed. Use with the code widget.\n"
"\n"
"Conditions:\n"
"Sets an expression that is evaluated when a breakpoint is hit. If the expression is false "
"or 0, the breakpoint is ignored until hit again. Statements should be separated by a comma. "
"Only the last statement will be used to determine what to do.\n"
"\n"
"Registers that can be referenced:\n"
"GPRs : r0..r31\n"
"FPRs : f0..f31\n LR, CTR, PC\n"
"\n"
"Functions:\n"
"Set a register: r1 = 8\n"
"Casts: s8(0xff). Available: s8, u8, s16, u16, s32, u32\n"
"Read Memory: read_u32(0x80000000). Available: u8, s8, u16, s16, u32, s32, f32, f64\n"
"Write Memory: write_u32(r3, 0x80000000). Available: u8, u16, u32, f32, f64\n"
"*currently writing will always be triggered\n"
"\n"
"Operations:\n"
"Unary: -u, !u, ~u\n"
"Math: * / + -, power: **, remainder: %, shift: <<, >>\n"
"Compare: <, <=, >, >=, ==, !=, &&, ||\n"
"Bitwise: &, |, ^\n"
"\n"
"Examples:\n"
"r4 == 1\n"
"f0 == 1.0 && f2 < 10.0\n"
"r26 <= r0 && ((r5 + 3) & -4) * ((r6 + 3) & -4)* 4 > r0\n"
"p = r3 + 0x8, p == 0x8003510 && read_u32(p) != 0\n"
"Write and break: r4 = 8, 1\n"
"Write and continue: f3 = f1 + f2, 0\n"
"The condition must always be last\n");
ModalMessageBox::information(this, tr("Conditional help"), message);
}

View File

@ -29,12 +29,14 @@ private:
void OnBPTypeChanged();
void OnAddressTypeChanged();
void ShowConditionHelp();
// Instruction BPs
QRadioButton* m_instruction_bp;
QGroupBox* m_instruction_box;
QLineEdit* m_instruction_address;
QLineEdit* m_instruction_condition;
QPushButton* m_cond_help_btn;
// Memory BPs
QRadioButton* m_memory_bp;