Add support for demangling undefined symbols.

This commit is contained in:
ramiro%netscape.com 1999-09-14 13:40:22 +00:00
parent 8662d998bf
commit 5b445b449b
2 changed files with 88 additions and 18 deletions

View File

@ -126,17 +126,8 @@ nsNativeComponentLoader::GetFactory(const nsIID & aCID,
if (PR_GetErrorTextLength() < (int) sizeof(errorMsg))
PR_GetErrorText(errorMsg);
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
("nsComponentManager: Load(\"%s\") FAILED with error: %s",
dll->GetNativePath(), errorMsg));
DumpLoadError(dll, "GetFactory", errorMsg);
#ifdef PRINT_CRITICAL_ERROR_TO_SCREEN
// Put the error message on the screen.
printf("****************************************************\n"
"nsComponentManager: Load(\"%s\") FAILED with error: %s\n"
"****************************************************\n",
dll->GetNativePath(), errorMsg);
#endif
return NS_ERROR_FAILURE;
}
}
@ -459,15 +450,8 @@ nsNativeComponentLoader::SelfRegisterDll(nsDll *dll, const char *registryLocatio
if (PR_GetErrorTextLength() < (int) sizeof(errorMsg))
PR_GetErrorText(errorMsg);
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
("nsNativeComponentLoader: SelfRegisterDll(%s) Load FAILED with error:%s", dll->GetNativePath(), errorMsg));
DumpLoadError(dll, "SelfRegisterDll", errorMsg);
#ifdef PRINT_CRITICAL_ERROR_TO_SCREEN
printf("**************************************************\n"
"nsNativeComponentLoader: Load(%s) FAILED with error: %s\n"
"**************************************************\n",
dll->GetNativePath(), errorMsg);
#endif
return NS_ERROR_FAILURE;
}
@ -517,6 +501,88 @@ nsNativeComponentLoader::SelfRegisterDll(nsDll *dll, const char *registryLocatio
return res;
}
//
// MOZ_DEMANGLE_SYMBOLS is only a linux + MOZ_DEBUG thing.
//
#if defined(MOZ_DEMANGLE_SYMBOLS)
#include "nsTraceRefcnt.h" // for nsTraceRefcnt::DemangleSymbol()
#endif
nsresult
nsNativeComponentLoader::DumpLoadError(nsDll *dll,
const char *aCallerName,
const char *aNsprErrorMsg)
{
PR_ASSERT(aCallerName != NULL);
if (nsnull == dll || nsnull == aNsprErrorMsg)
return NS_OK;
nsCAutoString errorMsg(aNsprErrorMsg);
#if defined(MOZ_DEMANGLE_SYMBOLS)
// Demangle undefined symbols
nsCAutoString undefinedMagicString("undefined symbol:");
PRInt32 offset = errorMsg.Find(undefinedMagicString, PR_TRUE);
if (offset != kNotFound)
{
nsCAutoString symbol(errorMsg);
nsCAutoString demangledSymbol("");
symbol.Cut(0,offset);
symbol.Cut(0,undefinedMagicString.Length());
symbol.StripWhitespace();
char demangled[4096] = "\0";
nsTraceRefcnt::DemangleSymbol(symbol,demangled,sizeof(demangled));
if (demangled && strlen(demangled))
demangledSymbol = demangled;
if (demangledSymbol != "")
{
nsCAutoString tmp(errorMsg);
tmp.Cut(offset + undefinedMagicString.Length(),
tmp.Length() - offset - undefinedMagicString.Length());
tmp += " \n";
tmp += demangledSymbol;
errorMsg = tmp;
}
}
#endif // MOZ_DEMANGLE_SYMBOLS
// Do NSPR log
PR_LOG(nsComponentManagerLog, PR_LOG_ALWAYS,
("nsNativeComponentLoader: %s(%s) Load FAILED with error:%s",
aCallerName,
dll->GetNativePath(),
(const char *) errorMsg));
// Dump to screen if needed
#ifdef PRINT_CRITICAL_ERROR_TO_SCREEN
printf("**************************************************\n"
"nsNativeComponentLoader: %s(%s) Load FAILED with error: %s\n"
"**************************************************\n",
aCallerName,
dll->GetNativePath(),
(const char *) errorMsg);
#endif
return NS_OK;
}
nsresult
nsNativeComponentLoader::SelfUnregisterDll(nsDll *dll)
{

View File

@ -68,6 +68,10 @@ class nsNativeComponentLoader : public nsIComponentLoader {
nsIServiceManager *aServMgr,
nsIFactory **aFactory);
nsresult DumpLoadError(nsDll *dll,
const char *aCallerName,
const char *aNsprErrorMsg);
};
#endif /* nsNativeComponentLoader_h__ */