mirror of
https://github.com/dingusdev/dingusppc.git
synced 2024-12-22 15:29:58 +00:00
profiler: add reset command.
This commit is contained in:
parent
31b5290ac9
commit
ed6c316c82
@ -71,7 +71,10 @@ static void show_help() {
|
|||||||
cout << " dump NT,X -- dump N memory cells of size T at address X" << endl;
|
cout << " dump NT,X -- dump N memory cells of size T at address X" << endl;
|
||||||
cout << " T can be b(byte), w(word), d(double)," << endl;
|
cout << " T can be b(byte), w(word), d(double)," << endl;
|
||||||
cout << " q(quad) or c(character)." << endl;
|
cout << " q(quad) or c(character)." << endl;
|
||||||
cout << " profile N -- print variables for profile N" << endl;
|
cout << " profile C N -- run subcommand C on profile N" << endl;
|
||||||
|
cout << " supported subcommands:" << endl;
|
||||||
|
cout << " 'show' - show profile report" << endl;
|
||||||
|
cout << " 'reset' - reset profile variables" << endl;
|
||||||
#ifdef PROFILER
|
#ifdef PROFILER
|
||||||
cout << " profiler -- show stats related to the processor" << endl;
|
cout << " profiler -- show stats related to the processor" << endl;
|
||||||
#endif
|
#endif
|
||||||
@ -368,7 +371,7 @@ static void print_gprs() {
|
|||||||
|
|
||||||
void enter_debugger() {
|
void enter_debugger() {
|
||||||
string inp, cmd, addr_str, expr_str, reg_expr, last_cmd, reg_value_str,
|
string inp, cmd, addr_str, expr_str, reg_expr, last_cmd, reg_value_str,
|
||||||
inst_string, inst_num_str, profile_name;
|
inst_string, inst_num_str, profile_name, sub_cmd;
|
||||||
uint32_t addr, inst_grab;
|
uint32_t addr, inst_grab;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
int log_level, context;
|
int log_level, context;
|
||||||
@ -400,9 +403,16 @@ void enter_debugger() {
|
|||||||
} else if (cmd == "quit") {
|
} else if (cmd == "quit") {
|
||||||
break;
|
break;
|
||||||
} else if (cmd == "profile") {
|
} else if (cmd == "profile") {
|
||||||
|
ss >> sub_cmd;
|
||||||
ss >> profile_name;
|
ss >> profile_name;
|
||||||
|
|
||||||
|
if (sub_cmd == "show") {
|
||||||
gProfilerObj->print_profile(profile_name);
|
gProfilerObj->print_profile(profile_name);
|
||||||
|
} else if (sub_cmd == "reset") {
|
||||||
|
gProfilerObj->reset_profile(profile_name);
|
||||||
|
} else {
|
||||||
|
cout << "Unknown/empty subcommand " << sub_cmd << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef PROFILER
|
#ifdef PROFILER
|
||||||
else if (cmd == "profiler") {
|
else if (cmd == "profiler") {
|
||||||
|
@ -77,3 +77,13 @@ void Profiler::print_profile(std::string name)
|
|||||||
|
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Profiler::reset_profile(std::string name)
|
||||||
|
{
|
||||||
|
if (this->profiles_map.find(name) == this->profiles_map.end()) {
|
||||||
|
std::cout << "Profile " << name << " not found." << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->profiles_map.find(name)->second->reset();
|
||||||
|
}
|
||||||
|
@ -36,7 +36,7 @@ enum class ProfileVarFmt { DEC, HEX };
|
|||||||
typedef struct ProfileVar {
|
typedef struct ProfileVar {
|
||||||
std::string name;
|
std::string name;
|
||||||
ProfileVarFmt format;
|
ProfileVarFmt format;
|
||||||
uint32_t value;
|
uint64_t value;
|
||||||
} ProfileVar;
|
} ProfileVar;
|
||||||
|
|
||||||
/** Base class for user-defined profiles. */
|
/** Base class for user-defined profiles. */
|
||||||
@ -48,6 +48,8 @@ public:
|
|||||||
|
|
||||||
virtual void populate_variables(std::vector<ProfileVar>& vars) = 0;
|
virtual void populate_variables(std::vector<ProfileVar>& vars) = 0;
|
||||||
|
|
||||||
|
virtual void reset(void) = 0; // reset profile counters
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string name;
|
std::string name;
|
||||||
};
|
};
|
||||||
@ -63,6 +65,8 @@ public:
|
|||||||
|
|
||||||
void print_profile(std::string name);
|
void print_profile(std::string name);
|
||||||
|
|
||||||
|
void reset_profile(std::string name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, std::unique_ptr<BaseProfile>> profiles_map;
|
std::map<std::string, std::unique_ptr<BaseProfile>> profiles_map;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user