char* p = strtok(s," ");
if(!p)
{
- interactive_run_noisy(std::vector<std::string>(1,"1"));
+ interactive_run_noisy(std::string("r"), std::vector<std::string>(1,"1"));
continue;
}
std::string cmd = p;
args.push_back(p);
- typedef void (sim_t::*interactive_func)(const std::vector<std::string>&);
+ typedef void (sim_t::*interactive_func)(const std::string&, const std::vector<std::string>&);
std::map<std::string,interactive_func> funcs;
funcs["r"] = &sim_t::interactive_run_noisy;
funcs["fregd"] = &sim_t::interactive_fregd;
funcs["mem"] = &sim_t::interactive_mem;
funcs["until"] = &sim_t::interactive_until;
+ funcs["while"] = &sim_t::interactive_until;
funcs["q"] = &sim_t::interactive_quit;
try
{
if(funcs.count(cmd))
- (this->*funcs[cmd])(args);
+ (this->*funcs[cmd])(cmd, args);
}
catch(trap_t t) {}
}
procs[i].step(interleave,noisy);
}
-void sim_t::interactive_run_noisy(const std::vector<std::string>& args)
+void sim_t::interactive_run_noisy(const std::string& cmd, const std::vector<std::string>& args)
{
- interactive_run(args,true);
+ interactive_run(cmd,args,true);
}
-void sim_t::interactive_run_silent(const std::vector<std::string>& args)
+void sim_t::interactive_run_silent(const std::string& cmd, const std::vector<std::string>& args)
{
- interactive_run(args,false);
+ interactive_run(cmd,args,false);
}
-void sim_t::interactive_run(const std::vector<std::string>& args, bool noisy)
+void sim_t::interactive_run(const std::string& cmd, const std::vector<std::string>& args, bool noisy)
{
if(args.size())
step_all(atoi(args[0].c_str()),1,noisy);
while(1) step_all(1,1,noisy);
}
-void sim_t::interactive_run_proc_noisy(const std::vector<std::string>& args)
+void sim_t::interactive_run_proc_noisy(const std::string& cmd, const std::vector<std::string>& args)
{
- interactive_run_proc(args,true);
+ interactive_run_proc(cmd,args,true);
}
-void sim_t::interactive_run_proc_silent(const std::vector<std::string>& args)
+void sim_t::interactive_run_proc_silent(const std::string& cmd, const std::vector<std::string>& args)
{
- interactive_run_proc(args,false);
+ interactive_run_proc(cmd,args,false);
}
-void sim_t::interactive_run_proc(const std::vector<std::string>& a, bool noisy)
+void sim_t::interactive_run_proc(const std::string& cmd, const std::vector<std::string>& a, bool noisy)
{
if(a.size() == 0)
return;
while(1) procs[p].step(1,noisy);
}
-void sim_t::interactive_quit(const std::vector<std::string>& args)
+void sim_t::interactive_quit(const std::string& cmd, const std::vector<std::string>& args)
{
exit(0);
}
return procs[p].FR[r];
}
-void sim_t::interactive_reg(const std::vector<std::string>& args)
+reg_t sim_t::get_tohost(const std::vector<std::string>& args)
+{
+ if(args.size() != 1)
+ throw trap_illegal_instruction;
+
+ int p = atoi(args[0].c_str());
+ if(p >= (int)procs.size())
+ throw trap_illegal_instruction;
+
+ return procs[p].tohost;
+}
+
+void sim_t::interactive_reg(const std::string& cmd, const std::vector<std::string>& args)
{
printf("0x%016llx\n",(unsigned long long)get_reg(args));
}
double d;
};
-void sim_t::interactive_fregs(const std::vector<std::string>& args)
+void sim_t::interactive_fregs(const std::string& cmd, const std::vector<std::string>& args)
{
fpr f;
f.r = get_freg(args);
printf("%g\n",f.s);
}
-void sim_t::interactive_fregd(const std::vector<std::string>& args)
+void sim_t::interactive_fregd(const std::string& cmd, const std::vector<std::string>& args)
{
fpr f;
f.r = get_freg(args);
return val;
}
-void sim_t::interactive_mem(const std::vector<std::string>& args)
+void sim_t::interactive_mem(const std::string& cmd, const std::vector<std::string>& args)
{
printf("0x%016llx\n",(unsigned long long)get_mem(args));
}
-void sim_t::interactive_until(const std::vector<std::string>& args)
+void sim_t::interactive_until(const std::string& cmd, const std::vector<std::string>& args)
{
if(args.size() < 3)
return;
- std::string cmd = args[0];
+ std::string scmd = args[0];
reg_t val = strtol(args[args.size()-1].c_str(),NULL,16);
std::vector<std::string> args2;
while(1)
{
reg_t current;
- if(args[0] == "reg")
+ if(scmd == "reg")
current = get_reg(args2);
- else if(args[0] == "pc")
+ else if(scmd == "pc")
current = get_pc(args2);
- else if(args[0] == "mem")
+ else if(scmd == "mem")
current = get_mem(args2);
+ else if(scmd == "tohost")
+ current = get_tohost(args2);
else
return;
- if(current == val)
+ if(cmd == "until" && current == val)
+ break;
+ if(cmd == "while" && current != val)
break;
step_all(1,1,false);
void step_all(size_t n, size_t interleave, bool noisy);
- void interactive_quit(const std::vector<std::string>& args);
+ void interactive_quit(const std::string& cmd, const std::vector<std::string>& args);
- void interactive_run(const std::vector<std::string>& args, bool noisy);
- void interactive_run_noisy(const std::vector<std::string>& args);
- void interactive_run_silent(const std::vector<std::string>& args);
+ 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::vector<std::string>& args, bool noisy);
- void interactive_run_proc_noisy(const std::vector<std::string>& args);
- void interactive_run_proc_silent(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::vector<std::string>& args);
- void interactive_fregs(const std::vector<std::string>& args);
- void interactive_fregd(const std::vector<std::string>& args);
- void interactive_mem(const std::vector<std::string>& args);
- void interactive_until(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);
+ void interactive_mem(const std::string& cmd, const std::vector<std::string>& args);
+ void interactive_until(const std::string& cmd, const std::vector<std::string>& args);
reg_t get_reg(const std::vector<std::string>& args);
reg_t get_freg(const std::vector<std::string>& args);
reg_t get_mem(const std::vector<std::string>& args);
reg_t get_pc(const std::vector<std::string>& args);
+ reg_t get_tohost(const std::vector<std::string>& args);
friend class appserver_link_t;
};