fix some smartperf bug

Signed-off-by: zhaohui <zhaohui70@huawei.com>
This commit is contained in:
zhaohui 2022-06-18 17:09:07 +08:00
parent 3e0b23840d
commit 8a869aeef6
3 changed files with 12 additions and 9 deletions

View File

@ -43,6 +43,7 @@ std::map<std::string, std::string> RAM::getRamInfo()
cmdGrep.str("");
cmdGrep << "/proc/" << processId << "/smaps_rollup";
std::string cmdRam = cmdGrep.str();
std::cout << "RAM EXEC" << cmdRam << std::endl;
std::ifstream infile(cmdRam.c_str(), std::ios::in);
if (!infile) {
return ramInfo;

View File

@ -35,14 +35,16 @@ SmartPerfCommand::SmartPerfCommand(int argc, char *argv[])
}
if (argc == TWO_PARAM) {
auto iterator = commandHelpMap.begin();
while (iterator != commandHelpMap.end() && (strcmp(argv[1], iterator->second.c_str()) == 0)) {
if (iterator->first == CommandHelp::HELP) {
std::cout << SmartPerf_MSG << std::endl;
break;
}
if (iterator->first == CommandHelp::VERSION) {
std::cout << SmartPerf_VERSION << std::endl;
break;
while (iterator != commandHelpMap.end()) {
if (strcmp(argv[1], iterator->second.c_str()) == 0) {
if (iterator->first == CommandHelp::HELP) {
std::cout << SmartPerf_MSG << std::endl;
break;
}
if (iterator->first == CommandHelp::VERSION) {
std::cout << SmartPerf_VERSION << std::endl;
break;
}
}
++iterator;
}

View File

@ -57,7 +57,7 @@ bool SPUtils::LoadCmd(const std::string &cmd, std::string &result)
result = buf;
}
if (pclose(fd) == -1) {
result += "pclose failed";
std::cout << "" << std::endl;
}
// remove '' \n\r
ReplaceString(result);