aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-11 18:40:40 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-11 18:40:40 +0100
commitbb7092e96401e4c89c44773c932788c9b0f87b53 (patch)
treec888153bbdeb52f1c882af1c92fb6e1e9ebe894b
parent10f4d52221438f0d5ce7cc72c5b6c1f6720ef5c6 (diff)
downloadqtmips-bb7092e96401e4c89c44773c932788c9b0f87b53.tar.gz
qtmips-bb7092e96401e4c89c44773c932788c9b0f87b53.tar.bz2
qtmips-bb7092e96401e4c89c44773c932788c9b0f87b53.zip
Basic "hardware" breakpoints support implemented.
It works like real inserted breakpoint on hardware. Breakpoint has to be removed to allow code continue because else instruction is refetch and breakpoint triggers again. The single step function should resolve temporal masking of the breakpoint. Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
-rw-r--r--qtmips_gui/programdock.cpp2
-rw-r--r--qtmips_gui/programmodel.cpp22
-rw-r--r--qtmips_gui/programmodel.h1
-rw-r--r--qtmips_machine/core.cpp6
-rw-r--r--qtmips_machine/core.h2
-rw-r--r--qtmips_machine/qtmipsmachine.cpp4
-rw-r--r--qtmips_machine/qtmipsmachine.h2
7 files changed, 30 insertions, 9 deletions
diff --git a/qtmips_gui/programdock.cpp b/qtmips_gui/programdock.cpp
index a355b22..0466cc2 100644
--- a/qtmips_gui/programdock.cpp
+++ b/qtmips_gui/programdock.cpp
@@ -97,6 +97,8 @@ ProgramDock::ProgramDock(QWidget *parent, QSettings *settings) : Super(parent) {
this, SLOT(set_follow_inst(int)));
connect(this, SIGNAL(focus_addr(std::uint32_t)),
program_content, SLOT(focus_address(std::uint32_t)));
+ connect(program_content, SIGNAL(doubleClicked(QModelIndex)),
+ program_model, SLOT(toggle_hw_break(QModelIndex)));
}
void ProgramDock::setup(machine::QtMipsMachine *machine) {
diff --git a/qtmips_gui/programmodel.cpp b/qtmips_gui/programmodel.cpp
index 19b0f0d..4a758b7 100644
--- a/qtmips_gui/programmodel.cpp
+++ b/qtmips_gui/programmodel.cpp
@@ -113,15 +113,18 @@ QVariant ProgramModel::data(const QModelIndex &index, int role) const {
if (role == Qt::BackgroundRole) {
std::uint32_t address;
if (!get_row_address(address, index.row()) ||
- machine == nullptr || index.column() != 2)
+ machine == nullptr)
return QVariant();
- if (machine->cache_program() != nullptr) {
+ if (index.column() == 2 && machine->cache_program() != nullptr) {
machine::LocationStatus loc_stat;
loc_stat = machine->cache_program()->location_status(address);
if (loc_stat & machine::LOCSTAT_CACHED) {
QBrush bgd(Qt::lightGray);
return bgd;
}
+ } else if (index.column() == 0 && machine->is_hwbreak(address)) {
+ QBrush bgd(Qt::red);
+ return bgd;
}
return QVariant();
}
@@ -185,3 +188,18 @@ bool ProgramModel::adjustRowAndOffset(int &row, int optimal_row, std::uint32_t a
}
return get_row_for_address(row, address);
}
+
+void ProgramModel::toggle_hw_break(const QModelIndex & index) {
+ std::uint32_t address;
+ if (index.column() != 0 || machine == nullptr)
+ return;
+
+ if (!get_row_address(address, index.row()))
+ return;
+
+ if (machine->is_hwbreak(address))
+ machine->remove_hwbreak(address);
+ else
+ machine->insert_hwbreak(address);
+ update_all();
+}
diff --git a/qtmips_gui/programmodel.h b/qtmips_gui/programmodel.h
index 4a17e99..a6db493 100644
--- a/qtmips_gui/programmodel.h
+++ b/qtmips_gui/programmodel.h
@@ -85,6 +85,7 @@ public:
public slots:
void setup(machine::QtMipsMachine *machine);
void check_for_updates();
+ void toggle_hw_break(const QModelIndex & index);
private:
std::uint32_t index0_offset;
diff --git a/qtmips_machine/core.cpp b/qtmips_machine/core.cpp
index 68dbe0b..7c92949 100644
--- a/qtmips_machine/core.cpp
+++ b/qtmips_machine/core.cpp
@@ -83,7 +83,7 @@ Core::hwBreak::hwBreak(std::uint32_t addr) {
count = 0;
}
-void Core::inser_hwbreak(std::uint32_t address) {
+void Core::insert_hwbreak(std::uint32_t address) {
hw_breaks.insert(address, new hwBreak(address));
}
@@ -118,9 +118,9 @@ bool Core::handle_exception(Core *core, Registers *regs, ExceptionCause excause,
{
if (excause == EXCAUSE_HWBREAK) {
if (in_delay_slot)
- regs->pc_abs_jmp(inst_addr);
- else
regs->pc_abs_jmp(jump_branch_pc);
+ else
+ regs->pc_abs_jmp(inst_addr);
}
ExceptionHandler *exhandler = ex_handlers.value(excause);
diff --git a/qtmips_machine/core.h b/qtmips_machine/core.h
index 88d0e9b..bd62f52 100644
--- a/qtmips_machine/core.h
+++ b/qtmips_machine/core.h
@@ -81,7 +81,7 @@ public:
MemoryAccess *get_mem_data();
MemoryAccess *get_mem_program();
void register_exception_handler(ExceptionCause excause, ExceptionHandler *exhandler);
- void inser_hwbreak(std::uint32_t address);
+ void insert_hwbreak(std::uint32_t address);
void remove_hwbreak(std::uint32_t address);
bool is_hwbreak(std::uint32_t address);
diff --git a/qtmips_machine/qtmipsmachine.cpp b/qtmips_machine/qtmipsmachine.cpp
index f846ed2..23a83d3 100644
--- a/qtmips_machine/qtmipsmachine.cpp
+++ b/qtmips_machine/qtmipsmachine.cpp
@@ -206,9 +206,9 @@ void QtMipsMachine::register_exception_handler(ExceptionCause excause,
cr->register_exception_handler(excause, exhandler);
}
-void QtMipsMachine::inser_hwbreak(std::uint32_t address) {
+void QtMipsMachine::insert_hwbreak(std::uint32_t address) {
if (cr != nullptr)
- cr->inser_hwbreak(address);
+ cr->insert_hwbreak(address);
}
void QtMipsMachine::remove_hwbreak(std::uint32_t address) {
diff --git a/qtmips_machine/qtmipsmachine.h b/qtmips_machine/qtmipsmachine.h
index 82245ff..de5275a 100644
--- a/qtmips_machine/qtmipsmachine.h
+++ b/qtmips_machine/qtmipsmachine.h
@@ -78,7 +78,7 @@ public:
bool exited();
void register_exception_handler(ExceptionCause excause, ExceptionHandler *exhandler);
- void inser_hwbreak(std::uint32_t address);
+ void insert_hwbreak(std::uint32_t address);
void remove_hwbreak(std::uint32_t address);
bool is_hwbreak(std::uint32_t address);