From 675ca69976e98f35e8575b93fc69833017d8230f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sun, 1 Oct 2017 18:03:06 +0200 Subject: [PATCH] Add more options in the menu and loading --- src/analthread.cpp | 2 + src/cutter.cpp | 6 +++ src/dialogs/asmoptionsdialog.cpp | 80 +++++++++++++++++++++++++++----- src/dialogs/asmoptionsdialog.h | 4 +- src/dialogs/asmoptionsdialog.ui | 59 +++++++++++++++++------ src/optionsdialog.ui | 10 ++++ src/settings.h | 9 ++++ src/widgets/consolewidget.cpp | 2 - 8 files changed, 145 insertions(+), 27 deletions(-) diff --git a/src/analthread.cpp b/src/analthread.cpp index 50e8abda..b63e92d4 100644 --- a/src/analthread.cpp +++ b/src/analthread.cpp @@ -77,6 +77,8 @@ void AnalThread::run() forceBinPlugin = pluginDesc.name; } + main->core->setConfig("bin.demangle", ui->demangleCheckBox->isChecked()); + main->core->loadFile(main->getFilename(), loadaddr, mapaddr, rw, va, binidx, load_bininfo, forceBinPlugin); emit updateProgress("Analysis in progress."); diff --git a/src/cutter.cpp b/src/cutter.cpp index 6e8f5cdc..c4f8c7b2 100644 --- a/src/cutter.cpp +++ b/src/cutter.cpp @@ -508,6 +508,9 @@ void CutterCore::resetDefaultAsmOptions() setConfig("asm.syntax", settings.getAsmSyntax()); setConfig("asm.ucase", settings.getAsmUppercase()); setConfig("asm.bbline", settings.getAsmBBLine()); + setConfig("asm.capitalize", settings.getAsmCapitalize()); + setConfig("asm.varsub", settings.getAsmVarsub()); + setConfig("asm.varsub_only", settings.getAsmVarsubOnly()); } void CutterCore::saveDefaultAsmOptions() @@ -524,6 +527,9 @@ void CutterCore::saveDefaultAsmOptions() settings.setAsmSyntax(getConfig("asm.syntax")); settings.setAsmUppercase(getConfigb("asm.ucase")); settings.setAsmBBLine(getConfigb("asm.bbline")); + settings.setAsmCapitalize(getConfigb("asm.capitalize")); + settings.setAsmVarsub(getConfigb("asm.varsub")); + settings.setAsmVarsubOnly(getConfigb("asm.varsub_only")); } QString CutterCore::getConfig(const QString &k) diff --git a/src/dialogs/asmoptionsdialog.cpp b/src/dialogs/asmoptionsdialog.cpp index 5993138b..6b75d07a 100644 --- a/src/dialogs/asmoptionsdialog.cpp +++ b/src/dialogs/asmoptionsdialog.cpp @@ -53,8 +53,27 @@ void AsmOptionsDialog::updateFromVars() } } - qhelpers::setCheckedWithoutSignals(ui->uppercaseCheckBox, core->getConfigb("asm.ucase")); + ui->caseComboBox->blockSignals(true); + if (core->getConfigb("asm.ucase")) + { + ui->caseComboBox->setCurrentIndex(1); + } + else if(core->getConfigb("asm.capitalize")) + { + ui->caseComboBox->setCurrentIndex(2); + } + else + { + ui->caseComboBox->setCurrentIndex(0); + } + ui->caseComboBox->blockSignals(false); + qhelpers::setCheckedWithoutSignals(ui->bblineCheckBox, core->getConfigb("asm.bbline")); + + bool varsubEnabled = core->getConfigb("asm.varsub"); + qhelpers::setCheckedWithoutSignals(ui->varsubCheckBox, varsubEnabled); + qhelpers::setCheckedWithoutSignals(ui->varsubOnlyCheckBox, core->getConfigb("asm.varsub_only")); + ui->varsubOnlyCheckBox->setEnabled(varsubEnabled); } @@ -127,9 +146,35 @@ void AsmOptionsDialog::on_syntaxComboBox_currentIndexChanged(int index) core->triggerAsmOptionsChanged(); } -void AsmOptionsDialog::on_uppercaseCheckBox_toggled(bool checked) +void AsmOptionsDialog::on_caseComboBox_currentIndexChanged(int index) { - core->setConfig("asm.ucase", checked); + bool ucase; + bool capitalize; + + switch (index) + { + // lowercase + case 0: + default: + ucase = false; + capitalize = false; + break; + + // uppercase + case 1: + ucase = true; + capitalize = false; + break; + + case 2: + ucase = false; + capitalize = true; + break; + } + + core->setConfig("asm.ucase", ucase); + core->setConfig("asm.capitalize", capitalize); + core->triggerAsmOptionsChanged(); } @@ -139,17 +184,30 @@ void AsmOptionsDialog::on_bblineCheckBox_toggled(bool checked) core->triggerAsmOptionsChanged(); } +void AsmOptionsDialog::on_varsubCheckBox_toggled(bool checked) +{ + core->setConfig("asm.varsub", checked); + ui->varsubOnlyCheckBox->setEnabled(checked); + core->triggerAsmOptionsChanged(); +} + +void AsmOptionsDialog::on_varsubOnlyCheckBox_toggled(bool checked) +{ + core->setConfig("asm.varsub_only", checked); + core->triggerAsmOptionsChanged(); +} + void AsmOptionsDialog::on_buttonBox_clicked(QAbstractButton *button) { switch (ui->buttonBox->buttonRole(button)) { - case QDialogButtonBox::ButtonRole::ApplyRole: - saveAsDefault(); - break; - case QDialogButtonBox::ButtonRole::ResetRole: - resetToDefault(); - break; - default: - break; + case QDialogButtonBox::ButtonRole::ApplyRole: + saveAsDefault(); + break; + case QDialogButtonBox::ButtonRole::ResetRole: + resetToDefault(); + break; + default: + break; } } diff --git a/src/dialogs/asmoptionsdialog.h b/src/dialogs/asmoptionsdialog.h index ba957bd2..efe9358a 100644 --- a/src/dialogs/asmoptionsdialog.h +++ b/src/dialogs/asmoptionsdialog.h @@ -40,8 +40,10 @@ private slots: void on_bytespaceCheckBox_toggled(bool checked); void on_lbytesCheckBox_toggled(bool checked); void on_syntaxComboBox_currentIndexChanged(int index); - void on_uppercaseCheckBox_toggled(bool checked); + void on_caseComboBox_currentIndexChanged(int index); void on_bblineCheckBox_toggled(bool checked); + void on_varsubCheckBox_toggled(bool checked); + void on_varsubOnlyCheckBox_toggled(bool checked); void on_buttonBox_clicked(QAbstractButton *button); }; diff --git a/src/dialogs/asmoptionsdialog.ui b/src/dialogs/asmoptionsdialog.ui index 384bc075..fd131ddf 100644 --- a/src/dialogs/asmoptionsdialog.ui +++ b/src/dialogs/asmoptionsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 415 - 368 + 445 + 631 @@ -81,26 +81,38 @@ - - + + + + + Syntax (asm.syntax): - - + + + + + Lowercase + + + + + Uppercase (asm.ucase) + + + + + CamelCase (asm.capitalize) + + + - - - - Uppercase syntax (asm.ucase) - - - @@ -108,6 +120,27 @@ + + + + Substitute variables (asm.varsub) + + + + + + + 16 + + + + + Substitute entire variable expressions with names (asm.varsub_only) + + + + + diff --git a/src/optionsdialog.ui b/src/optionsdialog.ui index f6e99753..6961d582 100644 --- a/src/optionsdialog.ui +++ b/src/optionsdialog.ui @@ -436,6 +436,16 @@ + + + + Import demangled symbols + + + true + + + diff --git a/src/settings.h b/src/settings.h index 5620a4e3..433f1647 100644 --- a/src/settings.h +++ b/src/settings.h @@ -42,6 +42,15 @@ public: bool getAsmBBLine() const { return settings.value("asm.bbline", false).toBool(); } void setAsmBBLine(bool v) { settings.setValue("asm.bbline", v); } + + bool getAsmCapitalize() const { return settings.value("asm.capitalize", false).toBool(); } + void setAsmCapitalize(bool v) { settings.setValue("asm.capitalize", v); } + + bool getAsmVarsub() const { return settings.value("asm.varsub", true).toBool(); } + void setAsmVarsub(bool v) { settings.setValue("asm.varsub", v); } + + bool getAsmVarsubOnly() const { return settings.value("asm.varsub_only", true).toBool(); } + void setAsmVarsubOnly(bool v) { settings.setValue("asm.varsub_only", v); } }; #endif // SETTINGS_H diff --git a/src/widgets/consolewidget.cpp b/src/widgets/consolewidget.cpp index f838604c..61cfad4a 100644 --- a/src/widgets/consolewidget.cpp +++ b/src/widgets/consolewidget.cpp @@ -68,8 +68,6 @@ static const int invalidHistoryPos = -1; static bool isForbidden(const QString &input) { - return false; - static const QRegExp delimiters("[;&]");