Browse Source

Exit cleanly from debug console

confprec
Andrew Waterman 13 years ago
parent
commit
790db6c910
  1. 27
      riscv/interactive.cc
  2. 23
      riscv/sim.cc
  3. 12
      riscv/sim.h
  4. 3
      riscv/spike.cc

27
riscv/interactive.cc

@ -58,8 +58,6 @@ void sim_t::interactive()
funcs["r"] = &sim_t::interactive_run_noisy;
funcs["rs"] = &sim_t::interactive_run_silent;
funcs["rp"] = &sim_t::interactive_run_proc_noisy;
funcs["rps"] = &sim_t::interactive_run_proc_silent;
funcs["reg"] = &sim_t::interactive_reg;
funcs["fregs"] = &sim_t::interactive_fregs;
funcs["fregd"] = &sim_t::interactive_fregd;
@ -93,32 +91,9 @@ void sim_t::interactive_run(const std::string& cmd, const std::vector<std::strin
step(steps, noisy);
}
void sim_t::interactive_run_proc_noisy(const std::string& cmd, const std::vector<std::string>& args)
{
interactive_run_proc(cmd,args,true);
}
void sim_t::interactive_run_proc_silent(const std::string& cmd, const std::vector<std::string>& args)
{
interactive_run_proc(cmd,args,false);
}
void sim_t::interactive_run_proc(const std::string& cmd, const std::vector<std::string>& a, bool noisy)
{
if(a.size() == 0)
return;
int p = atoi(a[0].c_str());
if(p >= (int)num_cores())
return;
size_t steps = a.size() > 1 ? atoll(a[1].c_str()) : -1;
procs[p]->step(steps, noisy);
}
void sim_t::interactive_quit(const std::string& cmd, const std::vector<std::string>& args)
{
exit(0);
stop();
}
reg_t sim_t::get_pc(const std::vector<std::string>& args)

23
riscv/sim.cc

@ -13,9 +13,9 @@
# define mmap mmap64
#endif
sim_t::sim_t(int _nprocs, int mem_mb, const std::vector<std::string>& args)
sim_t::sim_t(size_t _nprocs, size_t mem_mb, const std::vector<std::string>& args)
: htif(new htif_isasim_t(this, args)),
procs(_nprocs), current_step(0), current_proc(0)
procs(_nprocs), current_step(0), current_proc(0), debug(false)
{
// allocate target machine's memory, shrinking it as necessary
// until the allocation succeeds
@ -68,20 +68,20 @@ reg_t sim_t::get_scr(int which)
{
switch (which)
{
case 0: return num_cores();
case 0: return procs.size();
case 1: return memsz >> 20;
default: return -1;
}
}
void sim_t::run(bool debug)
void sim_t::run()
{
while (!htif->done())
{
if(!debug)
step(INTERLEAVE, false);
else
if (debug)
interactive();
else
step(INTERLEAVE, false);
}
}
@ -99,8 +99,15 @@ void sim_t::step(size_t n, bool noisy)
{
current_step = 0;
procs[current_proc]->mmu.yield_load_reservation();
if (++current_proc == num_cores())
if (++current_proc == procs.size())
current_proc = 0;
}
}
}
void sim_t::stop()
{
procs[0]->tohost = 1;
while (!htif->done())
htif->tick();
}

12
riscv/sim.h

@ -15,11 +15,13 @@ class htif_isasim_t;
class sim_t
{
public:
sim_t(int _nprocs, int mem_mb, const std::vector<std::string>& htif_args);
sim_t(size_t _nprocs, size_t mem_mb, const std::vector<std::string>& htif_args);
~sim_t();
// run the simulation to completion
void run(bool debug);
void run();
void stop();
void set_debug(bool value) { debug = value; }
// deliver an IPI to a specific processor
void send_ipi(reg_t who);
@ -39,9 +41,10 @@ private:
std::vector<processor_t*> procs;
void step(size_t n, bool noisy); // step through simulation
static const size_t INTERLEAVE = 5000;
static const size_t INTERLEAVE = 1000;
size_t current_step;
size_t current_proc;
bool debug;
// presents a prompt for introspection into the simulation
void interactive();
@ -51,9 +54,6 @@ private:
void interactive_run(const std::string& cmd, const std::vector<std::string>& args, bool noisy);
void interactive_run_noisy(const std::string& cmd, const std::vector<std::string>& args);
void interactive_run_silent(const std::string& cmd, const std::vector<std::string>& args);
void interactive_run_proc(const std::string& cmd, const std::vector<std::string>& args, bool noisy);
void interactive_run_proc_noisy(const std::string& cmd, const std::vector<std::string>& args);
void interactive_run_proc_silent(const std::string& cmd, const std::vector<std::string>& args);
void interactive_reg(const std::string& cmd, const std::vector<std::string>& args);
void interactive_fregs(const std::string& cmd, const std::vector<std::string>& args);
void interactive_fregd(const std::string& cmd, const std::vector<std::string>& args);

3
riscv/spike.cc

@ -58,5 +58,6 @@ int main(int argc, char** argv)
if (dc) s.get_core(i)->get_mmu()->register_memtracer(&*dc);
}
s.run(debug);
s.set_debug(debug);
s.run();
}

Loading…
Cancel
Save