Final changes for register profiles.

This commit is contained in:
Ernie Pasveer
2023-12-25 13:51:25 -06:00
parent 0f3361753e
commit 8ba8d65fe6
5 changed files with 155 additions and 1 deletions
+1
View File
@@ -8,6 +8,7 @@
* Fixed long tooltips text by restricting them to 100 characters. (#189)
The text in the various viewing dialogs is still the full length.
The 100 limit probably needs to be configurable.
* Added register profiles to show only interesting/relevant registers.
## [2.3] - 2023-11-19
* In the margins of the source windows, allow CTRL+DoubleClick to do a quick RunToLine or RunToAddress.
+2 -1
View File
@@ -9,6 +9,7 @@
#include <QtPrintSupport/QPrintDialog>
#include <QtCore/QRegularExpression>
#include <QtCore/QSettings>
#include <QtCore/QFile>
#include <QtCore/QDebug>
SeerMemoryVisualizerWidget::SeerMemoryVisualizerWidget (QWidget* parent) : QWidget(parent) {
@@ -376,7 +377,7 @@ void SeerMemoryVisualizerWidget::handlePrintButton () {
void SeerMemoryVisualizerWidget::handleSaveButton () {
QFileDialog dialog(this, "Seer visualizer file", "./", "Logs (*.log);;Text files (*.txt);;All files (*.*)");
QFileDialog dialog(this, "Seer Visualizer File", "./", "Logs (*.log);;Text files (*.txt);;All files (*.*)");
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setDefaultSuffix("log");
+144
View File
@@ -1,6 +1,7 @@
#include "SeerRegisterProfileDialog.h"
#include "SeerRegisterTreeWidgetItem.h"
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QFileDialog>
#include <QtGui/QRegularExpressionValidator>
#include <QtCore/QRegularExpression>
#include <QtCore/QSettings>
@@ -29,6 +30,8 @@ SeerRegisterProfileDialog::SeerRegisterProfileDialog (QWidget* parent) : QDialog
// Connect things.
QObject::connect(enablePushButton, &QPushButton::clicked, this, &SeerRegisterProfileDialog::handleEnableSelected);
QObject::connect(disablePushButton, &QPushButton::clicked, this, &SeerRegisterProfileDialog::handleDisableSelected);
QObject::connect(importPushButton, &QPushButton::clicked, this, &SeerRegisterProfileDialog::handleImportFile);
QObject::connect(exportPushButton, &QPushButton::clicked, this, &SeerRegisterProfileDialog::handleExportFile);
// Restore window settings.
readSettings();
@@ -136,6 +139,147 @@ void SeerRegisterProfileDialog::handleDisableSelected () {
}
}
void SeerRegisterProfileDialog::handleImportFile () {
//
// Get the name of the file to import.
//
QFileDialog dialog(this, "Seer Register Profile File", "./", "Text files (*.txt);;All files (*.*)");
dialog.setAcceptMode(QFileDialog::AcceptOpen);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setDefaultSuffix("txt");
dialog.selectFile("registerprofile.txt");
if (dialog.exec() != QDialog::Accepted) {
return;
}
QStringList files = dialog.selectedFiles();
if (files.size() == 0) {
return;
}
if (files.size() > 1) {
QMessageBox::critical(this, tr("Error"), tr("Select only 1 file."));
return;
}
//
// Open the file and read from it.
// A simple format of:
// <registername> <enable|disable>
//
QFile file(files[0]);
if (file.open(QIODevice::ReadOnly)) {
QStringList registerNames;
QVector<bool> registerEnabled;
QTextStream stream(&file);
while (stream.atEnd() == false) {
QString line = stream.readLine();
QStringList words = line.split(QRegularExpression("\\s+"));
// Ignore empty lines.
if (words.count() == 0) {
continue;
}
// Ignore null lines.
if (words.count() == 1 && words[0] == "") {
continue;
}
// There should be only two words on each line.
if (words.count() != 2) {
QMessageBox::critical(this, tr("Error"), tr("Can't load register profile file.\nEncountered a line not the form of:\n\n<registername> <enabled|disabled>"));
return;
}
// The second word must be 'enabled' or 'disabled'.
if (words[1] != "enabled" && words[1] != "disabled") {
QMessageBox::critical(this, tr("Error"), tr("Can't load register profile file.\nEncountered a line not the form of:\n\n<registername> <enabled|disabled>"));
return;
}
registerNames.push_back(words[0]);
registerEnabled.push_back(words[1] == "enabled" ? true : false);
}
// Populate the list with the imported values.
setRegisters (registerNames, registerEnabled);
QMessageBox::information(this, "Seer", "Loaded.");
}else{
QMessageBox::critical(this, tr("Error"), tr("Can't open register profile file."));
return;
}
}
void SeerRegisterProfileDialog::handleExportFile () {
//
// Get the name of the file to export.
//
QFileDialog dialog(this, "Seer Register Profile File", "./", "Text files (*.txt);;All files (*.*)");
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setDefaultSuffix("txt");
dialog.selectFile("registerprofile.txt");
if (dialog.exec() != QDialog::Accepted) {
return;
}
QStringList files = dialog.selectedFiles();
if (files.size() == 0) {
return;
}
if (files.size() > 1) {
QMessageBox::critical(this, tr("Error"), tr("Select only 1 file."));
return;
}
//
// Create the file and write to it.
// A simple format of:
// <registername> <enable|disable>
//
QFile file(files[0]);
if (file.open(QIODevice::ReadWrite)) {
QTextStream stream(&file);
QStringList names = registerNames();
QVector<bool> enabled = registerEnabled();
for (int i=0; i<names.count(); i++) {
stream << names[i] << " " << (enabled[i] == true ? "enabled" : "disabled") << "\n";
}
file.flush();
file.close();
QMessageBox::information(this, "Seer", "Saved.");
}else{
QMessageBox::critical(this, tr("Error"), tr("Can't create register profile file."));
return;
}
}
void SeerRegisterProfileDialog::writeSettings() {
QSettings settings;
+2
View File
@@ -27,6 +27,8 @@ class SeerRegisterProfileDialog : public QDialog, protected Ui::SeerRegisterProf
private slots:
void handleEnableSelected ();
void handleDisableSelected ();
void handleImportFile ();
void handleExportFile ();
protected:
void writeSettings ();
@@ -68,6 +68,12 @@ The register value can be printed in multiple formats.
Register values can be modified. Double-click on a Value column for a register will allow the value to be edited and changed. Using a RMB on a register will bring up a menu to change the register value as well. This second method can better handle resisters that have 'union' like properties (eg: xmm0 with xmm0.v8_bfloat16, xmm0.v4_float, etc...) where the register name needs to be modified slightly to include the 'union' field name.
Register profiles can be created. A profile selects which registers to actually show. Multiple profiles are allowed. You can create
new ones and modify existing ones. There is one profile that is special. It's called 'allregisters'. It means show all
registers. It can't be modified or deleted.
Switching between register profiles is easily done using the "Profile" list selector.
### References
Consult these gdb references