From 8d0f4806a7ad55710cb190e5a5c9388bd00c50a8 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Wed, 6 Mar 2019 23:40:34 +0100 Subject: Enable configuration of syscalls emulation and stop on exception. Signed-off-by: Pavel Pisa --- qtmips_gui/NewDialog.ui | 47 +++++++++++++++++++++++++++++++++++++++++++++-- qtmips_gui/mainwindow.cpp | 20 ++++++++++++++------ qtmips_gui/newdialog.cpp | 32 ++++++++++++++++++++++++++++++++ qtmips_gui/newdialog.h | 5 +++++ 4 files changed, 96 insertions(+), 8 deletions(-) (limited to 'qtmips_gui') diff --git a/qtmips_gui/NewDialog.ui b/qtmips_gui/NewDialog.ui index 411b075..1189e21 100644 --- a/qtmips_gui/NewDialog.ui +++ b/qtmips_gui/NewDialog.ui @@ -305,9 +305,52 @@ - + - Enable OS Emulation + Enable emulation of operating system services + + + true + + + + + + + Stop on known system call + + + true + + + + + + + Stop on unknown system call + + + true + + + + + + + Stop on interrupt entry + + + true + + + + + + + Stop and step over exceptions (overflow, etc.) + + + true diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index 3cefe94..d6d0b35 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -153,13 +153,21 @@ void MainWindow::create_core(const machine::MachineConfig &config) { set_speed(); // Update machine speed to current settings -#if 1 - osemu::OsSyscallExceptionHandler *osemu_handler = new osemu::OsSyscallExceptionHandler; - machine->register_exception_handler(machine::EXCAUSE_SYSCALL, osemu_handler); - connect(osemu_handler, SIGNAL(char_written(int,uint)), terminal, SLOT(tx_byte(int,uint))); - connect(osemu_handler, SIGNAL(rx_byte_pool(int,uint&,bool&)), + if (config.osemu_enable()) { + osemu::OsSyscallExceptionHandler *osemu_handler = + new osemu::OsSyscallExceptionHandler(config.osemu_known_syscall_stop(), + config.osemu_unknown_syscall_stop()); + machine->register_exception_handler(machine::EXCAUSE_SYSCALL, osemu_handler); + connect(osemu_handler, SIGNAL(char_written(int,uint)), terminal, SLOT(tx_byte(int,uint))); + connect(osemu_handler, SIGNAL(rx_byte_pool(int,uint&,bool&)), terminal, SLOT(rx_byte_pool(int,uint&,bool&))); -#endif + machine->set_step_over_exception(machine::EXCAUSE_SYSCALL, true); + machine->set_stop_on_exception(machine::EXCAUSE_SYSCALL, false); + } else { + machine->set_step_over_exception(machine::EXCAUSE_SYSCALL, false); + machine->set_stop_on_exception(machine::EXCAUSE_SYSCALL, + config.osemu_exception_stop()); + } // Connect machine signals and slots connect(ui->actionRun, SIGNAL(triggered(bool)), machine, SLOT(play())); diff --git a/qtmips_gui/newdialog.cpp b/qtmips_gui/newdialog.cpp index 3e37357..53b2a05 100644 --- a/qtmips_gui/newdialog.cpp +++ b/qtmips_gui/newdialog.cpp @@ -72,6 +72,12 @@ NewDialog::NewDialog(QWidget *parent, QSettings *settings) : QDialog(parent) { connect(ui->mem_time_write, SIGNAL(valueChanged(int)), this, SLOT(mem_time_write_change(int))); connect(ui->mem_time_burst, SIGNAL(valueChanged(int)), this, SLOT(mem_time_burst_change(int))); + connect(ui->osemu_enable, SIGNAL(clicked(bool)), this, SLOT(osemu_enable_change(bool))); + connect(ui->osemu_known_syscall_stop, SIGNAL(clicked(bool)), this, SLOT(osemu_known_syscall_stop_change(bool))); + connect(ui->osemu_unknown_syscall_stop, SIGNAL(clicked(bool)), this, SLOT(osemu_unknown_syscall_stop_change(bool))); + connect(ui->osemu_interrupt_stop, SIGNAL(clicked(bool)), this, SLOT(osemu_interrupt_stop_change(bool))); + connect(ui->osemu_exception_stop, SIGNAL(clicked(bool)), this, SLOT(osemu_exception_stop_change(bool))); + cache_handler_d = new NewDialogCacheHandler(this, ui_cache_d); cache_handler_p = new NewDialogCacheHandler(this, ui_cache_p); @@ -196,6 +202,26 @@ void NewDialog::mem_time_burst_change(int v) { } } +void NewDialog::osemu_enable_change(bool v) { + config->set_osemu_enable(v); +} + +void NewDialog::osemu_known_syscall_stop_change(bool v) { + config->set_osemu_known_syscall_stop(v); +} + +void NewDialog::osemu_unknown_syscall_stop_change(bool v) { + config->set_osemu_unknown_syscall_stop(v); +} + +void NewDialog::osemu_interrupt_stop_change(bool v) { + config->set_osemu_interrupt_stop(v); +} + +void NewDialog::osemu_exception_stop_change(bool v) { + config->set_osemu_exception_stop(v); +} + void NewDialog::config_gui() { // Basic ui->elf_file->setText(config->elf()); @@ -214,6 +240,12 @@ void NewDialog::config_gui() { // Cache cache_handler_d->config_gui(); cache_handler_p->config_gui(); + // Operating system and exceptions + ui->osemu_enable->setChecked(config->osemu_enable()); + ui->osemu_known_syscall_stop->setChecked(config->osemu_known_syscall_stop()); + ui->osemu_unknown_syscall_stop->setChecked(config->osemu_unknown_syscall_stop()); + ui->osemu_interrupt_stop->setChecked(config->osemu_interrupt_stop()); + ui->osemu_exception_stop->setChecked(config->osemu_exception_stop()); // Disable various sections according to configuration ui->delay_slot->setEnabled(!config->pipelined()); diff --git a/qtmips_gui/newdialog.h b/qtmips_gui/newdialog.h index 2b1b7c4..edd633e 100644 --- a/qtmips_gui/newdialog.h +++ b/qtmips_gui/newdialog.h @@ -70,6 +70,11 @@ private slots: void mem_time_read_change(int); void mem_time_write_change(int); void mem_time_burst_change(int); + void osemu_enable_change(bool); + void osemu_known_syscall_stop_change(bool); + void osemu_unknown_syscall_stop_change(bool); + void osemu_interrupt_stop_change(bool); + void osemu_exception_stop_change(bool); private: Ui::NewDialog *ui; -- cgit v1.2.3