diff --git a/ge/common/profiling/ge_profiling.cc b/ge/common/profiling/ge_profiling.cc index ffda9ad6..55213ceb 100644 --- a/ge/common/profiling/ge_profiling.cc +++ b/ge/common/profiling/ge_profiling.cc @@ -115,6 +115,7 @@ bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) { ge::Status RegProfCtrlCallback(MsprofCtrlCallback func) { if (func == nullptr) { GELOGE(ge::PARAM_INVALID, "[Check][Param]Msprof ctrl callback is nullptr"); + REPORT_INNER_ERROR("E19999", "Msprof ctrl callback is nullptr"); return ge::PARAM_INVALID; } if (ge::ProfilingManager::Instance().GetMsprofCallback().msprofCtrlCallback != nullptr) { @@ -127,13 +128,15 @@ ge::Status RegProfCtrlCallback(MsprofCtrlCallback func) { ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) { if (func == nullptr) { - GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofSetDeviceCallback callback is nullptr."); + GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofSetDeviceCallback callback is nullptr"); + REPORT_INNER_ERROR("E19999", "MsprofSetDeviceCallback callback is nullptr"); return ge::PARAM_INVALID; } // Pass MsprofSetDeviceCallback to runtime ge::Status rt_ret = rtRegDeviceStateCallback(kRtSetDeviceRegName.c_str(), static_cast(func)); if (rt_ret != ge::SUCCESS) { - GELOGE(rt_ret, "[Pass][MsprofSetDeviceCallback]Pass it to runtime failed!"); + GELOGE(rt_ret, "[Pass][MsprofSetDeviceCallback]To runtime failed!"); + REPORT_CALL_ERROR("E19999", "Pass MsprofSetDeviceCallback to runtime failed, ret 0x%X", rt_ret); return rt_ret; } return ge::SUCCESS; @@ -141,7 +144,8 @@ ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) { ge::Status RegProfReporterCallback(MsprofReporterCallback func) { if (func == nullptr) { - GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr."); + GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); + REPORT_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); return ge::PARAM_INVALID; } if (ge::ProfilingManager::Instance().GetMsprofCallback().msprofReporterCallback != nullptr) { @@ -181,6 +185,7 @@ ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t le if (!TransProfConfigToParam(*prof_config_param, prof_params)) { GELOGE(ge::PARAM_INVALID, "[Check][Param]Transfer profilerConfig to string vector failed"); + REPORT_CALL_ERROR("E19999", "Transfer profilerConfig to string vector failed"); return ge::PARAM_INVALID; } } diff --git a/ge/common/profiling/profiling_manager.cc b/ge/common/profiling/profiling_manager.cc index 521f8cc8..2dceba6b 100644 --- a/ge/common/profiling/profiling_manager.cc +++ b/ge/common/profiling/profiling_manager.cc @@ -95,7 +95,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::In if (is_execute_profiling_) { if (prof_cb_.msprofCtrlCallback == nullptr) { GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofCtrlCallback callback is nullptr"); - REPORT_CALL_ERROR("E19999", "MsprofCtrlCallback callback is nullptr"); + REPORT_INNER_ERROR("E19999", "MsprofCtrlCallback callback is nullptr"); return ge::PARAM_INVALID; } int32_t cb_ret = prof_cb_.msprofCtrlCallback( @@ -193,7 +193,7 @@ ge::Status ProfilingManager::ParseOptions(const std::string &options) { if (training_trace != "on") { GELOGE(ge::PARAM_INVALID, "[Check][Param]Training trace param:%s is invalid.", training_trace.c_str()); - REPORT_CALL_ERROR("E19999", "Training trace param:%s is invalid.", training_trace.c_str()); + REPORT_INNER_ERROR("E19999", "Training trace param:%s is invalid.", training_trace.c_str()); return ge::PARAM_INVALID; } fp_point_ = prof_options[kFpPoint]; @@ -418,9 +418,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportPr int32_t logic_device_id = 0; rtError_t rt_ret = rtGetDevice(&logic_device_id); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "[Get][LogicDeviceId]Failed, current logic_device_id %d, ret 0x%X", - logic_device_id, rt_ret); - REPORT_CALL_ERROR("E19999", "Get logic device id %d failed, ret 0x%X", logic_device_id, rt_ret); + GELOGE(rt_ret, "[Get][LogicDeviceId]Failed, ret 0x%X", rt_ret); + REPORT_CALL_ERROR("E19999", "Get logic device id failed, ret 0x%X", rt_ret); return; } GELOGD("current logic_device_id:%d", logic_device_id); @@ -720,7 +719,7 @@ Status ProfilingManager::ProfParseParam(const std::map if (device_num == 0 || device_num > kMaxDeviceNum || device_num != static_cast(device_list.size())) { GELOGE(FAILED, "[Parse][Param]Failed, config para device num %d not equal to " "device list size %zu", device_num, device_list.size()); - REPORT_CALL_ERROR("E19999", "[Parse][Param]Failed, config para device num %d " + REPORT_INNER_ERROR("E19999", "[Parse][Param]Failed, config para device num %d " "not equal to device list size %zu", device_num, device_list.size()); return FAILED; } @@ -748,8 +747,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt auto device_id_ptr = std::unique_ptr(new (std::nothrow) uint32_t[device_num]); if (device_id_ptr == nullptr) { - GELOGE(FAILED, "[Start][Profiling]Failed, device id ptr is null, device num %d", device_num); - REPORT_CALL_ERROR("E19999", "Start profiling failed, device id ptr is null, device num %d", + GELOGE(FAILED, "[Start][Profiling]Malloc buffer failed when start profiling, device num %d", device_num); + REPORT_CALL_ERROR("E19999", "Malloc buffer failed when start profiling, device num %d", device_num); return FAILED; } @@ -798,8 +797,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt } auto device_id_ptr = std::unique_ptr(new (std::nothrow) uint32_t[device_num]); if (device_id_ptr == nullptr) { - GELOGE(FAILED, "[Stop][Profiling]Failed, device id ptr is null, device num %d", device_num); - REPORT_CALL_ERROR("E19999", "Stop profiling failed, device id ptr is null, device num %d", + GELOGE(FAILED, "[Stop][Profiling]Malloc buffer failed when stop profiling, device num %d", device_num); + REPORT_CALL_ERROR("E19999", "Malloc buffer failed when stop profiling, device num %d", device_num); return FAILED; } @@ -869,9 +868,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ProfilingManager::Profilin int32_t logic_device_id = 0; rtError_t rt_ret = rtGetDevice(&logic_device_id); if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "[Get][LogicDeviceId]Failed, current logic_device_id %d, ret 0x%X", - logic_device_id, rt_ret); - REPORT_CALL_ERROR("E19999", "Get logic device id %d failed, ret 0x%X", logic_device_id, rt_ret); + GELOGE(rt_ret, "[Get][LogicDeviceId]Failed, ret 0x%X", rt_ret); + REPORT_CALL_ERROR("E19999", "Get logic device id failed, ret 0x%X", rt_ret); } GELOGI("Current logic_device_id:%d", logic_device_id); @@ -887,7 +885,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ProfilingManager::Profilin FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::PluginInit() { if (prof_cb_.msprofReporterCallback == nullptr) { GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); - REPORT_CALL_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); + REPORT_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); return ge::PARAM_INVALID; } int32_t cb_ret = prof_cb_.msprofReporterCallback( @@ -906,7 +904,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Plugin &reporter_max_len_, sizeof(uint32_t)); if (cb_ret != MSPROF_ERROR_NONE) { REPORT_CALL_ERROR("E19999", "Get profiling reporter data max len failed, ret 0x%X", cb_ret); - GELOGE(INTERNAL_ERROR, "[Get][ProfilingData]Failed, ret 0x%X", cb_ret); + GELOGE(INTERNAL_ERROR, "[Get][ProfilingDataMaxLen]Failed, ret 0x%X", cb_ret); return INTERNAL_ERROR; } @@ -917,7 +915,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::PluginUn #ifdef DAVINCI_SUPPORT_PROFILING if (prof_cb_.msprofReporterCallback == nullptr) { GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); - REPORT_CALL_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); + REPORT_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); return; } int32_t cb_ret = prof_cb_.msprofReporterCallback( @@ -934,7 +932,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::CallMs ReporterData &reporter_data) const { if (prof_cb_.msprofReporterCallback == nullptr) { GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); - REPORT_CALL_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); + REPORT_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); return ge::PARAM_INVALID; } return prof_cb_.msprofReporterCallback( diff --git a/ge/common/properties_manager.cc b/ge/common/properties_manager.cc index eae29e34..e1f4c66e 100644 --- a/ge/common/properties_manager.cc +++ b/ge/common/properties_manager.cc @@ -69,7 +69,8 @@ bool PropertiesManager::LoadFileContent(const std::string &file_path) { std::ifstream fs(resolved_file_path, std::ifstream::in); if (!fs.is_open()) { - GELOGE(PARAM_INVALID, "Open %s failed.", file_path.c_str()); + GELOGE(PARAM_INVALID, "[Open][File]Failed, file path %s invalid", file_path.c_str()); + REPORT_CALL_ERROR("E19999", "Open file failed, path %s invalid", file_path.c_str()); return false; } @@ -77,7 +78,8 @@ bool PropertiesManager::LoadFileContent(const std::string &file_path) { while (getline(fs, line)) { // line not with \n if (!ParseLine(line)) { - GELOGE(PARAM_INVALID, "Parse line failed. content is [%s].", line.c_str()); + GELOGE(PARAM_INVALID, "[Parse][Line]Failed, content is %s", line.c_str()); + REPORT_CALL_ERROR("E19999", "Parse line failed, content is %s", line.c_str()); fs.close(); return false; } @@ -100,15 +102,18 @@ bool PropertiesManager::ParseLine(const std::string &line) { if (!temp.empty()) { std::string::size_type pos = temp.find_first_of(delimiter); if (pos == std::string::npos) { - GELOGE(PARAM_INVALID, "Incorrect line [%s], it must include [%s].Perhaps you use illegal chinese symbol", + GELOGE(PARAM_INVALID, "[Check][Param]Incorrect line %s, it must include %s", line.c_str(), delimiter.c_str()); + REPORT_CALL_ERROR("E19999", "Incorrect line %s, it must include %s", + line.c_str(), delimiter.c_str()); return false; } std::string map_key = Trim(temp.substr(0, pos)); std::string value = Trim(temp.substr(pos + 1)); if (map_key.empty() || value.empty()) { - GELOGE(PARAM_INVALID, "Map_key or value empty. %s", line.c_str()); + GELOGE(PARAM_INVALID, "[Check][Param]Map_key or value empty, line %s", line.c_str()); + REPORT_CALL_ERROR("E19999", "Map_key or value empty, line %s", line.c_str()); return false; } diff --git a/ge/common/util.cc b/ge/common/util.cc index 63d75de1..55f19e54 100644 --- a/ge/common/util.cc +++ b/ge/common/util.cc @@ -83,11 +83,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromBinaryFile(co std::ifstream fs(real_path, std::ifstream::in | std::ifstream::binary); if (!fs.is_open()) { ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file, "ifstream is_open failed"}); - GELOGE(ge::FAILED, "Open real path[%s] failed.", file); + GELOGE(ge::FAILED, "[Open][File]Failed, file path %s", file); return false; } - google::protobuf::io::IstreamInputStream istream(&fs); google::protobuf::io::CodedInputStream coded_stream(&istream); bool ret = ReadProtoFromCodedInputStream(coded_stream, proto); @@ -96,7 +95,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromBinaryFile(co if (!ret) { ErrorManager::GetInstance().ATCReportErrMessage("E19005", {"file"}, {file}); - GELOGE(ge::FAILED, "Parse file[%s] failed.", file); + GELOGE(ge::FAILED, "[Parse][File]Failed, file %s", file); return ret; } @@ -155,7 +154,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate); if (!file.is_open()) { - GELOGE(ge::FAILED, "Read file %s failed.", file_name); + GELOGE(ge::FAILED, "[Read][File]Failed, file %s", file_name); + REPORT_CALL_ERROR("E19999", "Read file %s failed", file_name); return false; } @@ -182,7 +182,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate); if (!file.is_open()) { - GELOGE(ge::FAILED, "Read file %s failed.", file_name); + GELOGE(ge::FAILED, "[Read][File]Failed, file %s", file_name); + REPORT_CALL_ERROR("E19999", "Read file %s failed", file_name); return false; } @@ -250,7 +251,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string CurrentTimeInStr() std::time_t now = std::time(nullptr); std::tm *ptm = std::localtime(&now); if (ptm == nullptr) { - GELOGE(ge::FAILED, "Localtime failed."); + GELOGE(ge::FAILED, "[Check][Param]Localtime incorrect"); + REPORT_CALL_ERROR("E19999", "Localtime incorrect"); return ""; } @@ -277,17 +279,15 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromText(const ch if (!fs.is_open()) { ErrorManager::GetInstance().ATCReportErrMessage("E19017", {"realpth", "protofile"}, {real_path, file}); - GELOGE(ge::FAILED, "Fail to open proto file real path is '%s' when orginal file path is '%s'.", real_path.c_str(), - file); + GELOGE(ge::FAILED, "[Open][ProtoFile]Failed, real path %s, orginal file path %s", + real_path.c_str(), file); return false; } google::protobuf::io::IstreamInputStream input(&fs); bool ret = google::protobuf::TextFormat::Parse(&input, message); GE_IF_BOOL_EXEC(!ret, ErrorManager::GetInstance().ATCReportErrMessage("E19018", {"protofile"}, {file}); - GELOGE(ret, - "Parse file[%s] through [google::protobuf::TextFormat::Parse] failed, " - "please check whether the file is a valid protobuf format file.", + GELOGE(ret, "[Parse][File]Through [google::protobuf::TextFormat::Parse] failed, file %s", file)); fs.close(); @@ -490,7 +490,8 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str ret = regexec(®, str.c_str(), 0, NULL, 0); if (ret) { regerror(ret, ®, ebuff, kMaxBuffSize); - GELOGE(ge::PARAM_INVALID, "regexec failed, reason: %s", ebuff); + GELOGE(ge::PARAM_INVALID, "[Rgexec][Param]Failed, reason %s", ebuff); + REPORT_CALL_ERROR("E19999", "Rgexec failed, reason %s", ebuff); regfree(®); return false; } @@ -518,35 +519,44 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { if (file_path == nullptr) { - GELOGE(PARAM_INVALID, "Config path is null."); + GELOGE(PARAM_INVALID, "[Check][Param]Config path is null"); + REPORT_INNER_ERROR("E19999", "Config path is null"); return false; } if (!CheckInputPathValid(file_path)) { - GELOGE(PARAM_INVALID, "Config path is invalid: %s", file_path); + GELOGE(PARAM_INVALID, "[Check][Param]Config path %s is invalid", file_path); + REPORT_CALL_ERROR("E19999", "Config path %s is invalid", file_path); return false; } // Normalize the path std::string resolved_file_path = RealPath(file_path); if (resolved_file_path.empty()) { - GELOGE(PARAM_INVALID, "Invalid input file path [%s], make sure that the file path is correct.", file_path); + GELOGE(PARAM_INVALID, "[Check][Param]Invalid input file path %s", file_path); + REPORT_CALL_ERROR("E19999", "Invalid input file path %s", file_path); return false; } mmStat_t stat = {0}; int32_t ret = mmStatGet(resolved_file_path.c_str(), &stat); if (ret != EN_OK) { - GELOGE(PARAM_INVALID, "cannot get config file status, which path is %s, maybe not exist, return %d, errcode %d", - resolved_file_path.c_str(), ret, mmGetErrorCode()); + GELOGE(PARAM_INVALID, "[Get][FileStatus]Failed, which path %s maybe not exist, " + "return %d, errcode %d", resolved_file_path.c_str(), ret, mmGetErrorCode()); + REPORT_CALL_ERROR("E19999", "Get config file status failed, which path %s maybe not exist, " + "return %d, errcode %d", resolved_file_path.c_str(), ret, mmGetErrorCode()); return false; } if ((stat.st_mode & S_IFMT) != S_IFREG) { - GELOGE(PARAM_INVALID, "config file is not a common file, which path is %s, mode is %u", resolved_file_path.c_str(), - stat.st_mode); + GELOGE(PARAM_INVALID, "[Check][Param]Config file is not a common file, which path is %s, " + "mode is %u", resolved_file_path.c_str(), stat.st_mode); + REPORT_CALL_ERROR("E19999", "Config file is not a common file, which path is %s, " + "mode is %u", resolved_file_path.c_str(), stat.st_mode); return false; } if (stat.st_size > kMaxConfigFileByte) { - GELOGE(PARAM_INVALID, "config file %s size[%ld] is larger than max config file Bytes[%u]", + GELOGE(PARAM_INVALID, "[Check][Param]Config file %s size %ld is larger than max config file Bytes %u", resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte); + REPORT_CALL_ERROR("E19999", "Config file %s size %ld is larger than max config file Bytes %u", + resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte); return false; } return true; @@ -554,29 +564,35 @@ FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status CheckPath(const char *path, size_t length) { if (path == nullptr) { - GELOGE(PARAM_INVALID, "Config path is invalid."); + GELOGE(PARAM_INVALID, "[Check][Param]Config path is invalid"); + REPORT_CALL_ERROR("E19999", "Config path is invalid"); return PARAM_INVALID; } if (strlen(path) != length) { - GELOGE(PARAM_INVALID, "Path is invalid or length of config path is not equal to given length."); + GELOGE(PARAM_INVALID, "[Check][Param]Path %s is invalid or length %zu " + "not equal to given length %zu", path, strlen(path), length); + REPORT_CALL_ERROR("E19999", "Path %s is invalid or length %zu " + "not equal to given length %zu", path, strlen(path), length); return PARAM_INVALID; } if (length == 0 || length > MMPA_MAX_PATH) { - GELOGE(PARAM_INVALID, "Length of config path is invalid."); + GELOGE(PARAM_INVALID, "[Check][Param]Length of config path %zu is invalid", length); + REPORT_INNER_ERROR("E19999", "Length of config path %zu is invalid", length); return PARAM_INVALID; } INT32 is_dir = mmIsDir(path); if (is_dir != EN_OK) { - GELOGE(PATH_INVALID, "Open directory %s failed, maybe it is not exit or not a dir. errmsg:%s", - path, strerror(errno)); + GELOGE(PATH_INVALID, "[Open][Directory]Failed, directory path %s", path); + REPORT_CALL_ERROR("E19999", "Open directory %s failed", path); return PATH_INVALID; } if (mmAccess2(path, M_R_OK) != EN_OK) { - GELOGE(PATH_INVALID, "Read path[%s] failed, errmsg[%s]", path, strerror(errno)); + GELOGE(PATH_INVALID, "[Read][Path]Failed, path %s, errmsg %s", path, strerror(errno)); + REPORT_CALL_ERROR("E19999", "Read path %s failed, errmsg %s", path, strerror(errno)); return PATH_INVALID; } return SUCCESS;