From 6609d12582d2bdd9fc777217a2296bacf7678d81 Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Tue, 13 Aug 2024 15:22:34 +0200 Subject: [PATCH] adds flimit that gets properly evaluated in interp --- src/main.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 940a106..02ae4b0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -69,7 +69,8 @@ int main(int argc, char* argv[]) { ("logfile,l", po::value(), "Sets default log file.") ("disass,d", po::value()->implicit_value(""), "Enables disassembly") ("gdb-port,g", po::value()->default_value(0), "enable gdb server and specify port to use") - ("instructions,i", po::value()->default_value(std::numeric_limits::max()), "max. number of instructions to simulate") + ("ilimit,i", po::value()->default_value(std::numeric_limits::max()), "max. number of instructions to simulate") + ("flimit", po::value()->default_value(std::numeric_limits::max()), "max. number of fetches to simulate") ("reset,r", po::value(), "reset address") ("dump-ir", "dump the intermediate representation") ("elf,f", po::value>(), "ELF file(s) to load") @@ -215,8 +216,15 @@ int main(int argc, char* argv[]) { start_address = str.find("0x") == 0 ? std::stoull(str.substr(2), nullptr, 16) : std::stoull(str, nullptr, 10); } vm->reset(start_address); - auto cycles = clim["instructions"].as(); - res = vm->start(cycles, dump); + auto limit = clim["ilimit"].as(); + auto cond = iss::finish_cond_e::JUMP_TO_SELF; + if(clim.count("flimit")) { + cond = cond | iss::finish_cond_e::FCOUNT_LIMIT; + limit = clim["flimit"].as(); + } else { + cond = cond | iss::finish_cond_e::ICOUNT_LIMIT; + } + res = vm->start(limit, dump, cond); auto instr_if = vm->get_arch()->get_instrumentation_if(); // this assumes a single input file