Use DEBUG_FUNCTION_LINE_ERR on error.

This commit is contained in:
Maschell
2022-04-22 22:55:53 +02:00
parent 6f607cfec3
commit 48eb915a70
15 changed files with 128 additions and 104 deletions

View File

@@ -4,16 +4,18 @@
dyn_linking_function_t *DynamicLinkingHelper::getOrAddFunctionEntryByName(dyn_linking_relocation_data_t *data, const char *functionName) {
if (data == nullptr) {
DEBUG_FUNCTION_LINE_ERR("data was NULL");
return nullptr;
}
if (functionName == nullptr) {
DEBUG_FUNCTION_LINE_ERR("functionName was NULL");
return nullptr;
}
dyn_linking_function_t *result = nullptr;
for (auto &curEntry : data->functions) {
if (strlen(curEntry.functionName) == 0) {
if (strlen(functionName) > DYN_LINK_FUNCTION_NAME_LENGTH) {
DEBUG_FUNCTION_LINE("Failed to add function name, it's too long.");
DEBUG_FUNCTION_LINE_ERR("Failed to add function name, it's too long.");
return nullptr;
}
strncpy(curEntry.functionName, functionName, DYN_LINK_FUNCTION_NAME_LENGTH);
@@ -44,7 +46,7 @@ dyn_linking_import_t *DynamicLinkingHelper::getOrAddImport(dyn_linking_relocatio
for (auto &curEntry : data->imports) {
if (strlen(curEntry.importName) == 0) {
if (strlen(importName) > DYN_LINK_IMPORT_NAME_LENGTH) {
DEBUG_FUNCTION_LINE("Failed to add Import, it's too long.");
DEBUG_FUNCTION_LINE_ERR("Failed to add Import, it's too long.");
return nullptr;
}
strncpy(curEntry.importName, importName, DYN_LINK_IMPORT_NAME_LENGTH);
@@ -71,13 +73,13 @@ bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_data_t *link
const std::string &name, const std::shared_ptr<ImportRPLInformation> &rplInfo) {
dyn_linking_import_t *importInfoGbl = DynamicLinkingHelper::getOrAddImport(linking_data, rplInfo->getName().c_str(), rplInfo->isData());
if (importInfoGbl == nullptr) {
DEBUG_FUNCTION_LINE("Getting import info failed. Probably maximum of %d rpl files to import reached.", DYN_LINK_IMPORT_LIST_LENGTH);
DEBUG_FUNCTION_LINE_ERR("Getting import info failed. Probably maximum of %d rpl files to import reached.", DYN_LINK_IMPORT_LIST_LENGTH);
return false;
}
dyn_linking_function_t *functionInfo = DynamicLinkingHelper::getOrAddFunctionEntryByName(linking_data, name.c_str());
if (functionInfo == nullptr) {
DEBUG_FUNCTION_LINE("Getting import info failed. Probably maximum of %d function to be relocated reached.", DYN_LINK_FUNCTION_LIST_LENGTH);
DEBUG_FUNCTION_LINE_ERR("Getting import info failed. Probably maximum of %d function to be relocated reached.", DYN_LINK_FUNCTION_LIST_LENGTH);
return false;
}
@@ -100,6 +102,6 @@ bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_entry_t *lin
curEntry->importEntry = importInfo;
return true;
}
DEBUG_FUNCTION_LINE("Failed to find empty slot for saving relocations entry. We ned more than %d slots.", linking_entry_length);
DEBUG_FUNCTION_LINE_ERR("Failed to find empty slot for saving relocations entry. We need more than %d slots.", linking_entry_length);
return false;
}