summaryrefslogtreecommitdiff
path: root/emulate/emulator.cpp
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2018-06-16 19:26:39 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2018-06-16 19:26:39 +0200
commit01e7e033e6254f141e44c4e3fc5fe8fc9d0b0c59 (patch)
tree008cdda2937a827802f6725ebf99e13e54a3b4e7 /emulate/emulator.cpp
parent6af709cc54d3f14155f34692716f598406d2ce6e (diff)
downloadopenwar-01e7e033e6254f141e44c4e3fc5fe8fc9d0b0c59.tar.gz
openwar-01e7e033e6254f141e44c4e3fc5fe8fc9d0b0c59.tar.bz2
openwar-01e7e033e6254f141e44c4e3fc5fe8fc9d0b0c59.zip
Adds some more output to a emulation run.
Diffstat (limited to 'emulate/emulator.cpp')
-rw-r--r--emulate/emulator.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/emulate/emulator.cpp b/emulate/emulator.cpp
index 2e30fd8..669684f 100644
--- a/emulate/emulator.cpp
+++ b/emulate/emulator.cpp
@@ -1,6 +1,8 @@
#include "emulator.hpp"
+#include <boost/timer/timer.hpp>
+
template <>
struct SignedCounterpart<uint32_t> {
typedef int32_t type;
@@ -417,8 +419,13 @@ void emulate(std::string file_path) {
emulator.set_data_segment(file.object_table.entries.at(2).reloc_base_address);
unsigned int decodedInstructionsCount;
+ unsigned int emulated_instructions = 0;
bool run = true;
+
+ boost::timer::cpu_timer timer;
+ timer.start();
+
while(run) {
ci.code = binary.data() + emulator.cpu.eip();
ci.nextOffset = emulator.cpu.eip();
@@ -428,17 +435,21 @@ void emulate(std::string file_path) {
ci.features = DF_NONE;
_DInst decinst;
- distorm_decompose(&ci, &decinst, 1, &decodedInstructionsCount);
+ distorm_decompose(&ci, &decinst, 1, &decodedInstructionsCount);
_DecodedInst inst;
distorm_format64(&ci, &decinst, &inst);
std::cout << emulator.cpu << std::endl;
- std::cout << "CurrentInstruction: " << std::hex << std::setw(8) << std::setfill('0') << inst.offset << ":\t" << inst.mnemonic.p << " " << inst.operands.p << std::endl;
+ std::cout << "CurrentInstruction: " << std::hex << std::setw(8) << std::setfill('0') << inst.offset << ":\t" << inst.mnemonic.p << " " << inst.operands.p << std::dec << std::endl;
std::cout << std::endl << std::endl;
emulator.cpu.eip() += decinst.size;
run = emulator.handle_instruction(decinst);
+ emulated_instructions++;
}
+
+ timer.stop();
+ std::cout << "Serviced: " << emulated_instructions << " Instructions in: " << timer.elapsed().user << "ns" << std::endl;
}