static coreclr_shutdown_ptr shutdown = nullptr;
static coreclr_create_delegate_ptr createDelegate = nullptr;
static set_environment_variable_ptr setEnvironmentVariable = nullptr;
+static stop_profile_after_delay_ptr stopProfileAfterDelay = nullptr;
+static set_switch_ptr setSwitch = nullptr;
static void* __coreclrLib = nullptr;
static void* __hostHandle = nullptr;
static unsigned int __domainId = -1;
static bool __isProfileMode = false;
PathManager* CoreRuntime::__pm = nullptr;
+#define MAX_DELAY_SEC 100
+
static std::vector<std::string> __envList;
static void setEnvFromFile()
return true;
}
-static void initEnvForSpecialFolder()
+static void setSpecialFolder(storage_directory_e type, const char* key)
{
- int storageId;
int error;
- char *path = NULL;
+ char* path = NULL;
+ static int __storageId = -1;
- error = storage_foreach_device_supported(storage_cb, &storageId);
- if (error != STORAGE_ERROR_NONE) {
- return;
+ if (__storageId < 0) {
+ error = storage_foreach_device_supported(storage_cb, &__storageId);
+ if (error != STORAGE_ERROR_NONE) {
+ return;
+ }
}
- error = storage_get_directory(storageId, STORAGE_DIRECTORY_IMAGES, &path);
+ error = storage_get_directory(__storageId, type, &path);
if (error == STORAGE_ERROR_NONE && path != NULL) {
- setenv("XDG_PICTURES_DIR", const_cast<char *>(path), 1);
+ setenv(key, const_cast<char *>(path), 1);
free(path);
- path = NULL;
}
+}
- error = storage_get_directory(storageId, STORAGE_DIRECTORY_MUSIC, &path);
- if (error == STORAGE_ERROR_NONE && path != NULL) {
- setenv("XDG_MUSIC_DIR", const_cast<char *>(path), 1);
- free(path);
- path = NULL;
+static void initEnvForSpecialFolder()
+{
+ if (getenv("XDG_PICTURES_DIR") == NULL) {
+ setSpecialFolder(STORAGE_DIRECTORY_IMAGES, "XDG_PICTURES_DIR");
}
- error = storage_get_directory(storageId, STORAGE_DIRECTORY_VIDEOS, &path);
- if (error == STORAGE_ERROR_NONE && path != NULL) {
- setenv("XDG_VIDEOS_DIR", const_cast<char *>(path), 1);
- free(path);
- path = NULL;
+ if (getenv("XDG_MUSIC_DIR") == NULL) {
+ setSpecialFolder(STORAGE_DIRECTORY_MUSIC, "XDG_MUSIC_DIR");
+ }
+
+ if (getenv("XDG_VIDEOS_DIR") == NULL) {
+ setSpecialFolder(STORAGE_DIRECTORY_VIDEOS, "XDG_VIDEOS_DIR");
}
}
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,
putenv(const_cast<char *>("COMPlus_UseDefaultBaseAddr=1"));
#endif // USE_DEFAULT_BASE_ADDR
+ // Disable config cache to set environment after coreclr_initialize()
+ putenv(const_cast<char *>("COMPlus_DisableConfigCache=1"));
+
// read string from external file and set them to environment value.
setEnvFromFile();
return -1;
}
- char* pluginPath = pluginGetDllPath();
- if (pluginPath) {
- __pm->addPlatformAssembliesPaths(pluginPath);
+ char* pluginDllPaths = pluginGetDllPath();
+ if (pluginDllPaths && pluginDllPaths[0] != '\0') {
+ __pm->addPlatformAssembliesPaths(pluginDllPaths, true);
+ }
+
+ char* pluginNativePaths = pluginGetNativeDllSearchingPath();
+ if (pluginNativePaths && pluginNativePaths[0] != '\0') {
+ __pm->addNativeDllSearchingPaths(pluginNativePaths, true);
+ }
+
+ char* pluginExtraDllPaths = pluginGetExtraDllPath();
+ if (pluginExtraDllPaths && pluginExtraDllPaths[0] != '\0') {
+ __pm->setExtraDllPaths(pluginExtraDllPaths);
}
pluginHasLogControl();
std::string tpa;
char* pluginTPA = pluginGetTPA();
- if (pluginTPA) {
+ if (pluginTPA && pluginTPA[0] != '\0') {
tpa = std::string(pluginTPA);
} else {
addAssembliesFromDirectories(__pm->getPlatformAssembliesPaths(), tpa);
return -1;
}
+ st = createDelegate(__hostHandle, __domainId, "Tizen.Runtime", "Tizen.Runtime.Profiler", "StopProfileAfterDelay", (void**)&stopProfileAfterDelay);
+ if (st < 0 || stopProfileAfterDelay == nullptr) {
+ _ERR("Create delegate for Tizen.Runtime.dll -> Tizen.Runtime.Profiler -> StopProfileAfterDelay failed (0x%08x)", st);
+ return -1;
+ }
+
+ st = createDelegate(__hostHandle, __domainId, "Tizen.Runtime", "Tizen.Runtime.AppSetting", "SetSwitch", (void**)&setSwitch);
+ if (st < 0 || setSwitch == nullptr) {
+ _ERR("Create delegate for Tizen.Runtime.dll -> Tizen.Runtime.AppSetting -> SetSwitch failed (0x%08x)", st);
+ return -1;
+ }
+
if (launchMode == LaunchMode::loader) {
// terminate candidate process if language is changed.
// CurrentCulture created for preloaded dlls should be updated.
// set profile.data path and collect/use it if it non-exists/exists.
if (profile) {
- char multiCoreJitProfile[strlen(localDataPath) + strlen(PROFILE_BASENAME)];
- strncpy(multiCoreJitProfile, localDataPath, strlen(localDataPath));
+ char multiCoreJitProfile[strlen(localDataPath) + strlen(PROFILE_BASENAME) + 1];
+ memcpy(multiCoreJitProfile, localDataPath, strlen(localDataPath) + 1);
strncat(multiCoreJitProfile, PROFILE_BASENAME, strlen(PROFILE_BASENAME));
setEnvironmentVariable("COMPlus_MultiCoreJitProfile", multiCoreJitProfile);
setEnvironmentVariable("COMPlus_MultiCoreJitMinNumCpus", "1");
+
+ if (exist(multiCoreJitProfile)) {
+ setEnvironmentVariable("COMPlus_MultiCoreJitNoProfileGather", "1");
+ _INFO("Completed loading of profile data for the %s", appId);
+ } else {
+ setEnvironmentVariable("COMPlus_MultiCoreJitNoProfileGather", "0");
+ // stop profiling and write collected data after delay if env value is set.
+ char *env = getenv("CLR_MCJ_PROFILE_WRITE_DELAY");
+ if (env != nullptr) {
+ int delay = std::atoi(env);
+ // To avoid undefined behavior by out-of-range input(atoi), set max delay value to 100.
+ if (delay > 0) {
+ if (delay > MAX_DELAY_SEC) delay = MAX_DELAY_SEC;
+ stopProfileAfterDelay(delay);
+ }
+ }
+ _INFO("Create the profile data for the %s", appId);
+ }
}
free(localDataPath);
}
+ if (exist(__pm->getAppRootPath() + "/bin/" + DISABLE_IPV6_FILE)) {
+ setSwitch("System.Net.DisableIPv6", true);
+ }
+
+ setSwitch("Switch.System.Diagnostics.StackTrace.ShowILOffsets", true);
+
vconf_ignore_key_changed(VCONFKEY_LANGSET, langChangedCB);
pluginBeforeExecute();