#include "atomsim.hpp" #include #include "util.hpp" #include TARGET_HEADER #define RV_INSTR_EBREAK 0x100073 Atomsim::Atomsim(Atomsim_config sim_config, Backend_config bk_config): sim_config_(sim_config), backend_(this, bk_config) // create backend { // get input file disassembly getDisassembly(&disassembly_, sim_config_.ifile); // clear breakpoints for(int i=0; i sim_config_.maxitr) { throwError("SIM0", "Simulation iterations exceeded maxitr("+std::to_string(sim_config_.maxitr)+")\n"); exitcode = EXIT_FAILURE; break; } // Enter interactive mode if we aren's stepping and we are already in debug mode or run mode // was interrupted by user (CTRL_C) Rcode rval = RC_NONE; if((pending_steps == 0) && (in_debug_mode_ || CTRL_C_PRESSED)) { // explictly set: since we can also enter if CTRL_C_PRESSED in_debug_mode_ = true; pending_steps = 0; // run interactive mode rval = run_interactive_mode(); // if we return, that's either for exiting simulation, single/multi steping, or // switching to run mode if(rval == RC_STEP){ // Number of steps to be taken is set in pending_steps variable // We just pass here } else if (rval == RC_RUN) { /* code */ in_debug_mode_ = false; CTRL_C_PRESSED = false; } else if (rval == RC_EXIT) { // Exit sim exitcode = EXIT_SUCCESS; break; } } // Step this->step(); // Decrement pending_steps if we are in Step mode if(rval == RC_STEP && pending_steps > 0) { pending_steps--; } } } catch(std::exception &e) { std::cerr << "Runtime exception: " << e.what() << std::endl; return 1; } // Exiting sim deinit_interactive_mode(); return exitcode; }