aboutsummaryrefslogtreecommitdiff
path: root/qtmips_cli/reporter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_cli/reporter.cpp')
-rw-r--r--qtmips_cli/reporter.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/qtmips_cli/reporter.cpp b/qtmips_cli/reporter.cpp
index 70803a8..4f9a8cb 100644
--- a/qtmips_cli/reporter.cpp
+++ b/qtmips_cli/reporter.cpp
@@ -35,6 +35,7 @@
#include "reporter.h"
#include <iostream>
+#include <fstream>
#include <iomanip>
#include <typeinfo>
#include <qtmipsexception.h>
@@ -67,6 +68,10 @@ void Reporter::expect_fail(enum FailReason reason) {
e_fail = (enum FailReason)(e_fail | reason);
}
+void Reporter::add_dump_range(std::uint32_t start, std::uint32_t len, QString fname) {
+ dump_ranges.append({start, len, fname});
+}
+
void Reporter::machine_exit() {
report();
if (e_fail != 0) {
@@ -188,4 +193,18 @@ void Reporter::report() {
cout << "d-cache:stalled-cycles:" << machine->cache_data()->stalled_cycles() << endl;
cout << "d-cache:improved-speed:" << machine->cache_data()->speed_improvement() << endl;
}
+ foreach (DumpRange range, dump_ranges) {
+ ofstream out;
+ out.open(range.fname.toLocal8Bit().data(), ios::out | ios::trunc);
+ std::int32_t start = range.start & ~3;
+ std::int32_t end = range.start + range.len;
+ if (end < start)
+ end = 0xffffffff;
+ for (std::int32_t addr = start; addr < end; addr += 4) {
+ out << "0x";
+ out_hex(out, machine->memory()->read_word(addr), 8);
+ out << endl;
+ }
+ out.close();
+ }
}