*/
void printHWClockLog(const char* format, ...);
+/**
+ * @brief Return NCDB startup hook
+ * @return NCDB startup hook
+ */
+const char* getNCDBStartupHook();
+
+/**
+ * @brief Check is NCDB startup hook provided in DOTNET_STARTUP_HOOKS env
+ * @return `true` if provided, otherwise `false`
+ */
+bool isNCDBStartupHookProvided();
+
#endif /* __UTILS_H__ */
return -1;
}
+ bool ncdbStartupHook = isNCDBStartupHookProvided();
+
const char* propertyKeys[] = {
"TRUSTED_PLATFORM_ASSEMBLIES",
"APP_PATHS",
"APP_NI_PATHS",
"NATIVE_DLL_SEARCH_DIRECTORIES",
"System.Globalization.Invariant",
+ ncdbStartupHook ? "STARTUP_HOOKS" : "" // must be the last one
};
const char* propertyValues[] = {
tpaList.c_str(),
appPath.c_str(),
nativeDllSearchDirs.c_str(),
globalizationInvariant ? "true" : "false",
+ ncdbStartupHook ? getNCDBStartupHook() : "" // must be the last one
};
void* hostHandle;
int st = initializeCoreCLR(
currentExeAbsolutePath.c_str(),
"dotnet",
- sizeof(propertyKeys) / sizeof(propertyKeys[0]),
+ sizeof(propertyKeys) / sizeof(propertyKeys[0]) - (ncdbStartupHook ? 0 : 1),
propertyKeys,
propertyValues,
&hostHandle,
bool initializeCoreClr(PathManager* pm, const std::string& tpa)
{
+ bool ncdbStartupHook = isNCDBStartupHookProvided();
+
const char *propertyKeys[] = {
"TRUSTED_PLATFORM_ASSEMBLIES",
"APP_PATHS",
"APP_NI_PATHS",
"NATIVE_DLL_SEARCH_DIRECTORIES",
- "AppDomainCompatSwitch"
+ "AppDomainCompatSwitch",
+ ncdbStartupHook ? "STARTUP_HOOKS" : "" // must be the last one
};
const char *propertyValues[] = {
pm->getAppPaths().c_str(),
pm->getAppNIPaths().c_str(),
pm->getNativeDllSearchingPaths().c_str(),
- "UseLatestBehaviorWhenTFMNotSpecified"
+ "UseLatestBehaviorWhenTFMNotSpecified",
+ ncdbStartupHook ? getNCDBStartupHook() : "" // must be the last one
};
std::string selfPath = readSelfPath();
int st = initializeClr(selfPath.c_str(),
"TizenDotnetApp",
- sizeof(propertyKeys) / sizeof(propertyKeys[0]),
+ sizeof(propertyKeys) / sizeof(propertyKeys[0]) - (ncdbStartupHook ? 0 : 1),
propertyKeys,
propertyValues,
&__hostHandle,
prctl(PR_TASK_PERF_USER_TRACE, buf, strlen(buf));
}
+const char* getNCDBStartupHook()
+{
+ return "/home/owner/share/tmp/sdk_tools/netcoredbg/ncdbhook.dll";
+}
+
+bool isNCDBStartupHookProvided()
+{
+ char *env = nullptr;
+ env = getenv("DOTNET_STARTUP_HOOKS");
+ if (env == nullptr)
+ return false;
+
+ // Note, `DOTNET_STARTUP_HOOKS` env could provide list of dlls with ':' delimiter,
+ // for example: "/path1/name1.dll:/path2/name2.dll"
+ while (*env != '\0')
+ {
+ const char *ncdbCur = getNCDBStartupHook();
+ while (*ncdbCur != '\0' && *env != '\0' && *env != ':')
+ {
+ if (*ncdbCur != *env)
+ break;
+
+ ncdbCur++;
+ env++;
+
+ if (*ncdbCur == '\0' && (*env == '\0' || *env == ':'))
+ return true;
+ }
+ while (*env != '\0' && *env != ':')
+ {
+ env++;
+ }
+ if (*env == ':')
+ env++;
+ }
+
+ return false;
+}