From ef1576a92d02831b3c2713fe8fed6bba63679ec4 Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Mon, 17 Jul 2017 15:43:31 +0900 Subject: [PATCH 01/16] Revert "Add signal handler" This reverts commit 9923c6c1a7c00678b59cc15f2047be7e98be553f. Change-Id: Ie04614e1ca81955149c42d42a98e25579bbeae0f --- NativeLauncher/CMakeLists.txt | 5 - NativeLauncher/launcher/dotnet_signal_handler.cc | 146 ----------------------- NativeLauncher/launcher/dotnet_signal_handler.h | 23 ---- NativeLauncher/launcher/main.cc | 3 - packaging/dotnet-launcher.spec | 6 - 5 files changed, 183 deletions(-) delete mode 100644 NativeLauncher/launcher/dotnet_signal_handler.cc delete mode 100644 NativeLauncher/launcher/dotnet_signal_handler.h diff --git a/NativeLauncher/CMakeLists.txt b/NativeLauncher/CMakeLists.txt index abbf4c2..e453d9a 100644 --- a/NativeLauncher/CMakeLists.txt +++ b/NativeLauncher/CMakeLists.txt @@ -46,10 +46,6 @@ IF(USE_MANAGED_LAUNCHER STREQUAL "ENABLE") ADD_DEFINITIONS("-DUSE_MANAGED_LAUNCHER") ENDIF(USE_MANAGED_LAUNCHER) -IF(RAISE_DEFAULT_SIGNAL_HANDLER STREQUAL "ENABLE") - ADD_DEFINITIONS("-DRAISE_DEFAULT_SIGNAL_HANDLER") -ENDIF(RAISE_DEFAULT_SIGNAL_HANDLER) - OPTION(NOT_USE_FUNCTION "Remove build warning" OFF) IF(NOT_USE_FUNCTION) ADD_DEFINITIONS("-DNOT_USE_FUNCTION") @@ -78,7 +74,6 @@ SET(${DOTNET_LAUNCHER}_SOURCE_FILES launcher/main.cc util/utils.cc launcher/launcher.cc - launcher/dotnet_signal_handler.cc launcher/dotnet/dotnet_launcher.cc ) ADD_EXECUTABLE(${DOTNET_LAUNCHER} ${${DOTNET_LAUNCHER}_SOURCE_FILES}) diff --git a/NativeLauncher/launcher/dotnet_signal_handler.cc b/NativeLauncher/launcher/dotnet_signal_handler.cc deleted file mode 100644 index 783f6c7..0000000 --- a/NativeLauncher/launcher/dotnet_signal_handler.cc +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include "dotnet_signal_handler.h" - -#include "log.h" - -#include -#include - -#include -#include -#include -#include - -using namespace std; - -#define CALLSTACK_SIZE 30 - -std::vector backtraceStr; -char **backtraceStrings; -int backtracePtrs; - -static void printBacktrace() -{ - if (backtraceStr.size() > 0) { - _ERR("Backtrace returned %d addresses :", backtraceStr.size()); - - for (unsigned int i = 0; i < backtraceStr.size(); i++) { - _ERR("[Backtrace #%d] : %s", i, backtraceStr[i].c_str()); - } - } - - backtraceStr.clear(); -} - -static bool nativeCrashCheck() -{ - int i; - void *buf[CALLSTACK_SIZE + 1]; - - backtracePtrs = backtrace(buf, CALLSTACK_SIZE); - if (backtracePtrs == 0) { - _ERR("No backtrace captured"); - return false; - } - - backtraceStrings = backtrace_symbols(buf, backtracePtrs); - - if (backtraceStrings == NULL) { - _ERR("No backtrace captured"); - return false; - } - - backtraceStr.clear(); - - for (i = backtracePtrs - 1; i >= 0; i--) { - if (strstr(backtraceStrings[i], "__default_rt_sa_restorer") != NULL) - return backtraceStr.size() > 0; - - backtraceStr.push_back(std::string(backtraceStrings[i])); - } - - return true; -} - -static void onSigabrt(int signum) -{ - _ERR("<<< SIGABRT %d >>>", signum); - - backtracePtrs = 0; - backtraceStrings = NULL; - - if (nativeCrashCheck()) { - printBacktrace(); -#ifdef RAISE_DEFAULT_SIGNAL_HANDLER - SIG_DFL(signum); -#endif - } else { - _ERR("Crash from managed code"); - } - - if (backtraceStrings != NULL) { - free(backtraceStrings); - backtraceStrings = NULL; - } - - exit(0); -} - -static void onSigsegv(int signum) -{ - _ERR("<<< SIGSEGV %d >>>", signum); - - backtracePtrs = 0; - backtraceStrings = NULL; - - if (nativeCrashCheck()) { - printBacktrace(); -#ifdef RAISE_DEFAULT_SIGNAL_HANDLER - SIG_DFL(signum); -#endif - } else { - _ERR("Crash from managed code"); - } - - if (backtraceStrings != NULL) { - free(backtraceStrings); - backtraceStrings = NULL; - } - - exit(0); -} - -static void onSigtrap(int signum) -{ - _ERR("<<< SIGTRAP %d >>>", signum); - - exit(0); -} - -void registerSignalHandler() -{ - _DBG("Register signal handler"); - - if (SIG_ERR == signal(SIGABRT, &onSigabrt) || - SIG_ERR == signal(SIGSEGV, &onSigsegv) || - SIG_ERR == signal(SIGTRAP, &onSigtrap)) { - perror("[dotnet-launcher] signal register error\n"); - _ERR("Signal register error"); - } -} diff --git a/NativeLauncher/launcher/dotnet_signal_handler.h b/NativeLauncher/launcher/dotnet_signal_handler.h deleted file mode 100644 index 9cbb62e..0000000 --- a/NativeLauncher/launcher/dotnet_signal_handler.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef __DOTNET_SIGNAL_HANDLER__ -#define __DOTNET_SIGNAL_HANDLER__ - -void registerSignalHandler(); - -#endif /* __DOTNET_SIGNAL_HANDLER__ */ diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index b5fdb17..c23e16f 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -15,7 +15,6 @@ */ #include "dotnet/dotnet_launcher.h" -#include "dotnet_signal_handler.h" #include "utils.h" #include "log.h" @@ -41,8 +40,6 @@ static std::string StandaloneOption("--standalone"); int main(int argc, char *argv[]) { - registerSignalHandler(); - int i; bool standalone = false; const char* standalonePath = nullptr; diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index d41993a..6d4216e 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -63,11 +63,6 @@ launching dotnet apps without dotent runtime installed %define USE_MANAGED_LAUNCHER ENABLE %endif -%define raise_default_signal_handler 0 -%if %{raise_default_signal_handler} - %define RAISE_DEFAULT_SIGNAL_HANDLER ENABLE -%endif - %build cmake \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ @@ -87,7 +82,6 @@ cmake \ -DINSTALL_MDPLUGIN_DIR=%{_install_mdplugin_dir} \ -DVERSION=%{version} \ -DUSE_MANAGED_LAUNCHER=%{?USE_MANAGED_LAUNCHER:%USE_MANAGED_LAUNCHER} \ - -DRAISE_DEFAULT_SIGNAL_HANDLER=%{?RAISE_DEFAULT_SIGNAL_HANDLER:%RAISE_DEFAULT_SIGNAL_HANDLER} \ -DNATIVE_LIB_DIR=%{_native_lib_dir} \ NativeLauncher -- 2.7.4 From cc9146e37b31738fba3ef3ef88fae623568525e0 Mon Sep 17 00:00:00 2001 From: CHUNSEOK LEE Date: Thu, 20 Jul 2017 07:36:39 +0900 Subject: [PATCH 02/16] remove Self-Contained Deployment launcher Change-Id: I88bb4540725a62cbe331225654a55be0dd2702b3 Signed-off-by: CHUNSEOK LEE --- NativeLauncher/CMakeLists.txt | 17 +- NativeLauncher/launcher/dotnet/scd_launcher.cc | 580 ------------------------- packaging/dotnet-launcher.spec | 16 - 3 files changed, 1 insertion(+), 612 deletions(-) delete mode 100644 NativeLauncher/launcher/dotnet/scd_launcher.cc diff --git a/NativeLauncher/CMakeLists.txt b/NativeLauncher/CMakeLists.txt index e453d9a..6d78c6f 100644 --- a/NativeLauncher/CMakeLists.txt +++ b/NativeLauncher/CMakeLists.txt @@ -7,7 +7,7 @@ IF(DEFINED NO_TIZEN) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DNO_TIZEN") ELSE(DEFINED NO_TIZEN) INCLUDE(FindPkgConfig) - PKG_CHECK_MODULES(${PROJECT_NAME} REQUIRED aul pkgmgr-info pkgmgr-installer dlog ecore bundle dlog launchpad elementary glib-2.0 capi-appfw-app-control capi-appfw-service-application) + PKG_CHECK_MODULES(${PROJECT_NAME} REQUIRED aul pkgmgr-info pkgmgr-installer dlog ecore bundle dlog launchpad elementary glib-2.0) ENDIF(DEFINED NO_TIZEN) FOREACH(flag ${${PROJECT_NAME}_CFLAGS}) @@ -80,20 +80,6 @@ ADD_EXECUTABLE(${DOTNET_LAUNCHER} ${${DOTNET_LAUNCHER}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER} PROPERTIES COMPILE_FLAGS "-fPIE") -SET(SCD_LAUNCHER "scd-launcher") -SET(${SCD_LAUNCHER}_SOURCE_FILES - launcher/dotnet/scd_launcher.cc -) -ADD_EXECUTABLE(${SCD_LAUNCHER} ${${SCD_LAUNCHER}_SOURCE_FILES}) -SET_TARGET_PROPERTIES(${SCD_LAUNCHER} PROPERTIES COMPILE_FLAGS "-fPIE") - - -IF(NOT DEFINED NO_TIZEN) - TARGET_LINK_LIBRARIES(${SCD_LAUNCHER} capi-appfw-app-control dlog appcore-agent) -ENDIF(NOT DEFINED NO_TIZEN) -TARGET_LINK_LIBRARIES(${SCD_LAUNCHER} ${${PROJECT_NAME}_LDFLAGS} "-pie -ldl -lpthread") - - IF(NOT DEFINED NO_TIZEN) TARGET_LINK_LIBRARIES(${DOTNET_LAUNCHER} aul) ENDIF(NOT DEFINED NO_TIZEN) @@ -137,7 +123,6 @@ TARGET_LINK_LIBRARIES(${PREFER_DOTNET_AOT_PLUGIN} ${${PROJECT_NAME}_LDFLAGS}) IF(NOT DEFINED NO_TIZEN) INSTALL(TARGETS ${DOTNET_LAUNCHER} DESTINATION ${BINDIR}) - INSTALL(TARGETS ${SCD_LAUNCHER} DESTINATION ${BINDIR}) INSTALL(TARGETS ${NITOOL} DESTINATION ${BINDIR}) # INSTALL(TARGETS ${INSTALLER_PLUGIN} DESTINATION ${INSTALL_PLUGIN_DIR}) INSTALL(TARGETS ${PREFER_DOTNET_AOT_PLUGIN} DESTINATION ${INSTALL_MDPLUGIN_DIR}) diff --git a/NativeLauncher/launcher/dotnet/scd_launcher.cc b/NativeLauncher/launcher/dotnet/scd_launcher.cc deleted file mode 100644 index 7bbd883..0000000 --- a/NativeLauncher/launcher/dotnet/scd_launcher.cc +++ /dev/null @@ -1,580 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -// for serive_app -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "dotnet_launcher.h" - -using namespace std; - - -bool isDebugMode = false; -char *coreclrGdbjit[PATH_MAX]; -char *rootPath; - -bool service_app_create(void *data) -{ - // Todo: add your code here. - return true; -} - -void service_app_terminate(void *data) -{ - // Todo: add your code here. - - return; -} - -void service_app_control(app_control_h appControl, void *data) -{ - // Get _DEBUG_ value - char* buf[82]; - int ret = app_control_get_extra_data(appControl, "_SCD_DEBUG_", buf); - - if (ret == APP_CONTROL_ERROR_NONE) - if (strcmp(*buf, "1") == 0) - isDebugMode = true; - - if (isDebugMode) - ret = app_control_get_extra_data(appControl, "_SCD_CORECLR_GDBJIT_", coreclrGdbjit); - - service_app_exit(); - return; -} - - -// -// A simple CoreCLR host that runs a managed binary with the same name as this executable but with the *.dll extension -// The dll binary must contain a main entry point. -// - -#ifndef SUCCEEDED -#define SUCCEEDED(Status) ((Status) >= 0) -#endif // !SUCCEEDED - -static const char * const __CORECLR_DLL = "libcoreclr.so"; -// Name of the environment variable controlling server GC. -// If set to 1, server GC is enabled on startup. If 0, server GC is -// disabled. Server GC is off by default. -static const char* __SERVER_GC_VAR = "CORECLR_SERVER_GC"; -#define symlinkEntrypointExecutable "/proc/self/exe" - -bool getEntrypointExecutableabsolutePath(std::string& entrypointExecutable) -{ - bool result = false; - - entrypointExecutable.clear(); - - // Get path to the executable for the current process using - // platform specific means. - - // On Linux, fetch the entry point EXE absolute path, inclusive of filename. - char exe[PATH_MAX]; - ssize_t res = readlink(symlinkEntrypointExecutable, exe, PATH_MAX - 1); - if (res != -1) { - exe[res] = '\0'; - entrypointExecutable.assign(exe); - result = true; - } else { - result = false; - } - - return result; -} - -bool getabsolutePath(const char* path, std::string& absolutePath) -{ - bool result = false; - - char realPath[PATH_MAX]; - if (realpath(path, realPath) != nullptr && realPath[0] != '\0') { - absolutePath.assign(realPath); - // realpath should return canonicalized path without the trailing slash - assert(absolutePath.back() != '/'); - - result = true; - } - - return result; -} - -bool getDirectory(const char* absolutePath, std::string& directory) -{ - directory.assign(absolutePath); - size_t lastSlash = directory.rfind('/'); - if (lastSlash != std::string::npos) { - directory.erase(lastSlash); - return true; - } - - return false; -} - -bool getClrFilesabsolutePath(const char* currentExePath, const char* clrFilesPath, std::string& clrFilesAbsolutePath) -{ - std::string clrFilesRelativePath; - const char* clrFilesPathLocal = clrFilesPath; - if (clrFilesPathLocal == nullptr) { - // There was no CLR files path specified, use the folder of the corerun/coreconsole - if (!getDirectory(currentExePath, clrFilesRelativePath)) { - perror("Failed to get directory from argv[0]"); - return false; - } - - clrFilesPathLocal = clrFilesRelativePath.c_str(); - - // TODO: consider using an env variable (if defined) as a fall-back. - // The windows version of the corerun uses core_root env variable - } - - if (!getabsolutePath(clrFilesPathLocal, clrFilesAbsolutePath)) { - perror("Failed to convert CLR files path to absolute path"); - return false; - } - - return true; -} - -void addFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList) -{ - const char * const tpaExtensions[] = { - ".ni.dll", // Probe for .ni.dll first so that it's preferred if ni and il coexist in the same dir - ".dll", - ".ni.exe", - ".exe", - }; - - DIR* dir = opendir(directory); - if (dir == nullptr) - return; - - std::set addedAssemblies; - - // Walk the directory for each extension separately so that we first get files with .ni.dll extension, - // then files with .dll extension, etc. - for (unsigned int extIndex = 0; extIndex < sizeof(tpaExtensions) / sizeof(tpaExtensions[0]); extIndex++) { - const char* ext = tpaExtensions[extIndex]; - int extLength = strlen(ext); - - struct dirent* entry; - - // For all entries in the directory - while ((entry = readdir(dir)) != nullptr) { - // We are interested in files only - switch (entry->d_type) { - case DT_REG: - break; - - // Handle symlinks and file systems that do not support d_type - case DT_LNK: - case DT_UNKNOWN: - { - std::string fullFileName; - - fullFileName.append(directory); - fullFileName.append("/"); - fullFileName.append(entry->d_name); - - struct stat sb; - if (stat(fullFileName.c_str(), &sb) == -1) - continue; - - if (!S_ISREG(sb.st_mode)) - continue; - } - break; - - default: - continue; - } - - std::string fileName(entry->d_name); - - // Check if the extension matches the one we are looking for - int extPos = fileName.length() - extLength; - if ((extPos <= 0) || (fileName.compare(extPos, extLength, ext) != 0)) - continue; - - std::string fileNameWithoutExt(fileName.substr(0, extPos)); - - // Make sure if we have an assembly with multiple extensions present, - // we insert only one version of it. - if (addedAssemblies.find(fileNameWithoutExt) == addedAssemblies.end()) { - addedAssemblies.insert(fileNameWithoutExt); - - tpaList.append(directory); - tpaList.append("/"); - tpaList.append(fileName); - tpaList.append(":"); - } - } - - // Rewind the directory stream to be able to iterate over it for the next extension - rewinddir(dir); - } - - closedir(dir); -} - -int executeManagedAssembly(const char* currentExeAbsolutePath, - const char* clrFilesAbsolutePath, - const char* managedAssemblyAbsolutePath, - int managedAssemblyArgc, - const char** managedAssemblyArgv) -{ - // Indicates failure - int exitCode = -1; - -#ifdef __arm__ - // libunwind library is used to unwind stack frame, but libunwind for ARM - // does not support ARM vfpv3/NEON registers in DWARF format correctly. - // Therefore let's disable stack unwinding using DWARF information - // See https://github.com/dotnet/coreclr/issues/6698 - // - // libunwind use following methods to unwind stack frame. - // UNW_ARM_METHOD_ALL 0xFF - // UNW_ARM_METHOD_DWARF 0x01 - // UNW_ARM_METHOD_FRAME 0x02 - // UNW_ARM_METHOD_EXIDX 0x04 - putenv(const_cast("UNW_ARM_UNWIND_METHOD=6")); -#endif // __arm__ - - std::string coreClrDllPath(clrFilesAbsolutePath); - coreClrDllPath.append("/"); - coreClrDllPath.append(__CORECLR_DLL); - - if (coreClrDllPath.length() >= PATH_MAX) { - fprintf(stderr, "Absolute path to libcoreclr.so too long\n"); - return -1; - } - - // Get just the path component of the managed assembly path - std::string appPath; - getDirectory(managedAssemblyAbsolutePath, appPath); - - std::string tpaList; - // Construct native search directory paths - std::string nativeDllSearchDirs(appPath); - char *coreLibraries = getenv("CORE_LIBRARIES"); - if (coreLibraries) { - nativeDllSearchDirs.append(":"); - nativeDllSearchDirs.append(coreLibraries); - if (std::strcmp(coreLibraries, clrFilesAbsolutePath) != 0) - addFilesFromDirectoryToTpaList(coreLibraries, tpaList); - } - nativeDllSearchDirs.append(":"); - nativeDllSearchDirs.append(clrFilesAbsolutePath); - - addFilesFromDirectoryToTpaList(clrFilesAbsolutePath, tpaList); - - void* __coreclrLib = dlopen(coreClrDllPath.c_str(), RTLD_NOW | RTLD_LOCAL); - if (__coreclrLib != nullptr) { - coreclr_initialize_ptr initializeCoreCLR = (coreclr_initialize_ptr)dlsym(__coreclrLib, "coreclr_initialize"); - coreclr_execute_assembly_ptr executeAssembly = (coreclr_execute_assembly_ptr)dlsym(__coreclrLib, "coreclr_execute_assembly"); - coreclr_shutdown_ptr shutdownCoreCLR = (coreclr_shutdown_ptr)dlsym(__coreclrLib, "coreclr_shutdown"); - - if (initializeCoreCLR == nullptr) { - fprintf(stderr, "Function coreclr_initialize not found in the libcoreclr.so\n"); - } else if (executeAssembly == nullptr) { - fprintf(stderr, "Function coreclr_execute_assembly not found in the libcoreclr.so\n"); - } else if (shutdownCoreCLR == nullptr) { - fprintf(stderr, "Function coreclr_shutdown not found in the libcoreclr.so\n"); - } else { - // Check whether we are enabling server GC (off by default) - const char* useServerGc = std::getenv(__SERVER_GC_VAR); - if (useServerGc == nullptr) - useServerGc = "0"; - - // CoreCLR expects strings "true" and "false" instead of "1" and "0". - useServerGc = std::strcmp(useServerGc, "1") == 0 ? "true" : "false"; - - // Allowed property names: - // APPBASE - // - The base path of the application from which the exe and other assemblies will be loaded - // - // TRUSTED_PLATFORM_ASSEMBLIES - // - The list of complete paths to each of the fully trusted assemblies - // - // APP_PATHS - // - The list of paths which will be probed by the assembly loader - // - // APP_NI_PATHS - // - The list of additional paths that the assembly loader will probe for ngen images - // - // NATIVE_DLL_SEARCH_DIRECTORIES - // - The list of paths that will be probed for native DLLs called by PInvoke - // - const char *propertyKeys[] = { - "TRUSTED_PLATFORM_ASSEMBLIES", - "APP_PATHS", - "APP_NI_PATHS", - "NATIVE_DLL_SEARCH_DIRECTORIES", - "System.GC.Server", - }; - const char *propertyValues[] = { - // TRUSTED_PLATFORM_ASSEMBLIES - tpaList.c_str(), - // APP_PATHS - appPath.c_str(), - // APP_NI_PATHS - appPath.c_str(), - // NATIVE_DLL_SEARCH_DIRECTORIES - nativeDllSearchDirs.c_str(), - // System.GC.Server - useServerGc, - }; - - void* hostHandle; - unsigned int domainId; - - int st = initializeCoreCLR(currentExeAbsolutePath, - "unixcorerun", - sizeof(propertyKeys) / sizeof(propertyKeys[0]), - propertyKeys, - propertyValues, - &hostHandle, - &domainId); - - if (!SUCCEEDED(st)) { - fprintf(stderr, "coreclr_initialize failed - status: 0x%08x\n", st); - exitCode = -1; - } else { - st = executeAssembly(hostHandle, - domainId, - managedAssemblyArgc, - managedAssemblyArgv, - managedAssemblyAbsolutePath, - (unsigned int*)&exitCode); - - if (!SUCCEEDED(st)) { - fprintf(stderr, "coreclr_execute_assembly failed - status: 0x%08x\n", st); - exitCode = -1; - } - - st = shutdownCoreCLR(hostHandle, domainId); - if (!SUCCEEDED(st)) { - fprintf(stderr, "coreclr_shutdown failed - status: 0x%08x\n", st); - exitCode = -1; - } - } - } - - if (dlclose(__coreclrLib) != 0) { - fprintf(stderr, "Warning - dlclose failed\n"); - } - } else { - const char* error = dlerror(); - fprintf(stderr, "dlopen failed to open the libcoreclr.so with error %s\n", error); - } - - return exitCode; -} - - -// Display the help text -void displayUsage() -{ - fprintf(stderr, - "Runs executables on CoreCLR\n\n" - "Usage: [OPTIONS] [ARGUMENTS]\n" - "Runs .dll on CoreCLR.\n\n" - "Options:\n" - "-_c path to libcoreclr.so and the managed CLR assemblies.\n" - "-_h show this help message. \n"); -} - -// Parse the command line arguments -bool parseArguments(const int argc, - const char* argv[], - const char** clrFilesPath, - int* managedAssemblyArgc, - const char*** managedAssemblyArgv) -{ - bool success = true; - - *clrFilesPath = nullptr; - *managedAssemblyArgv = nullptr; - *managedAssemblyArgc = 0; - - for (int i = 1; i < argc; i++) { - // Check for options. Options to the Unix coreconsole are prefixed with '-_' to match the convention - // used in the Windows version of coreconsole. - if (strncmp(argv[i], "-_", 2) == 0) { - // Path to the libcoreclr.so and the managed CLR assemblies - if (strcmp(argv[i], "-_c") == 0) { - i++; - if (i < argc) { - *clrFilesPath = argv[i]; - } else { - fprintf(stderr, "Option %s: missing path\n", argv[i - 1]); - success = false; - break; - } - } else if (strcmp(argv[i], "-_h") == 0) { - displayUsage(); - success = false; - break; - } else { - fprintf(stderr, "Unknown option %s\n", argv[i]); - success = false; - break; - } - } else { - // We treat everything starting from the first non-option argument as arguments - // to the managed assembly. - *managedAssemblyArgc = argc - i; - if (*managedAssemblyArgc != 0) - *managedAssemblyArgv = &argv[i]; - - break; - } - } - - return success; -} - -int main(const int argc, const char* argv[]) -{ - /// service_app_begin - char *rootPath = getenv("AUL_ROOT_PATH"); - char *secondPass = getenv("SECONDPASS"); - - // This routine check whether _SCD_DEBUG_ flag is set(1) or not. - // In second pass, this routine is skipped. - if (secondPass == NULL) { - // run service_app routine to extract _SCD_DEBUG_ - char ad[50] = {0, }; - service_app_lifecycle_callback_s eventCallback; - eventCallback.create = service_app_create; - eventCallback.terminate = service_app_terminate; - eventCallback.app_control = service_app_control; - // FIXME: casting of argv is safe ? - service_app_main(argc, (char**)argv, &eventCallback, ad); - - char buf[PATH_MAX]; - vector vargs; - int status = 0; - - if (isDebugMode) { - dlog_print(DLOG_INFO, "dotnet", "debugmode on\n"); - setenv("CORECLR_GDBJIT", *coreclrGdbjit, 1); - - string curPath(getenv("PATH")); - string newPath("/home/owner/share/tmp/sdk_tools/lldb/bin:"); - newPath.append(curPath); - setenv("PATH", newPath.c_str(), 1); - - vargs.push_back("/home/owner/share/tmp/sdk_tools/lldb/bin/lldb-server"); - vargs.push_back("g"); - vargs.push_back("--platform=host"); - vargs.push_back("*:1234"); - vargs.push_back("--"); - } - snprintf(buf, sizeof(buf), "%s/bin/%s", rootPath, basename(rootPath)); - vargs.push_back(buf); - - // Pass app argument to lldb-server as it is - for (int i = 1; i < argc; i++) - vargs.push_back(argv[i]); - - const char** newArgs = &vargs[0]; - setenv("SECONDPASS", "1", 1); - status = execvp(newArgs[0], (char *const *)newArgs); - if (status == -1) - dlog_print(DLOG_ERROR, "dotnet", "execvp error"); - dlog_print(DLOG_INFO, "dotnet", "something wrong errno: %d\n", errno); - } - /// service_app_end - - // Make sure we have a full path for argv[0]. - std::string argv0AbsolutePath; - std::string entryPointExecutablePath; - - if (!getEntrypointExecutableabsolutePath(entryPointExecutablePath)) { - perror("Could not get full path to current executable"); - return -1; - } - - if (!getabsolutePath(entryPointExecutablePath.c_str(), argv0AbsolutePath)) { - perror("Could not normalize full path to current executable"); - return -1; - } - - // We will try to load the managed assembly with the same name as this executable - // but with the .dll extension. - std::string programPath(argv0AbsolutePath); - programPath.append(".dll"); - const char* managedAssemblyAbsolutePath = programPath.c_str(); - - // Check if the specified managed assembly file exists - struct stat sb; - if (stat(managedAssemblyAbsolutePath, &sb) == -1) { - perror("Managed assembly not found"); - return -1; - } - - // Verify that the managed assembly path points to a file - if (!S_ISREG(sb.st_mode)) { - fprintf(stderr, "The specified managed assembly is not a file\n"); - return -1; - } - - const char* clrFilesPath; - const char** managedAssemblyArgv; - int managedAssemblyArgc; - if (!parseArguments(argc, argv, &clrFilesPath, &managedAssemblyArgc, &managedAssemblyArgv)) - return -1; - - std::string clrFilesAbsolutePath; - if (!getClrFilesabsolutePath(argv0AbsolutePath.c_str(), clrFilesPath, clrFilesAbsolutePath)) - return -1; - - int exitCode = executeManagedAssembly(argv0AbsolutePath.c_str(), - clrFilesAbsolutePath.c_str(), - managedAssemblyAbsolutePath, - managedAssemblyArgc, - managedAssemblyArgv); - - return exitCode; -} diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index 6d4216e..7f4d46c 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -20,14 +20,6 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: aul-devel BuildRequires: dotnet-build-tools -# Required by scd-launcher -BuildRequires: appcore-agent -BuildRequires: pkgconfig(appcore-agent) -BuildRequires: pkgconfig(capi-appfw-app-control) -BuildRequires: pkgconfig(capi-appfw-application) -BuildRequires: pkgconfig(capi-appfw-service-application) - - Requires: aul Requires(post): /sbin/ldconfig @@ -49,11 +41,6 @@ ExcludeArch: aarch64 %description Launchpad plugin for launching dotnet apps -%package -n scd-launcher -Summary: self-contained dotnet launcher -%description -n scd-launcher -launching dotnet apps without dotent runtime installed - %prep %setup -q @@ -112,6 +99,3 @@ ln -sf %{_libdir}/libsqlite3.so.0 %{buildroot}%{_native_lib_dir}/libsqlite3.so %{_bindir}/Tizen.Runtime.dll %endif %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/dotnet-launcher - -%files -n scd-launcher -%caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/scd-launcher -- 2.7.4 From 6d179f13ad595875a0843741036930b1bf683760 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Wed, 19 Jul 2017 19:47:31 +0900 Subject: [PATCH 03/16] remove getenv Change-Id: Ia1c1c021ba8d31060643d44bf94aa6928761e957 --- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 15 --------------- NativeLauncher/launcher/main.cc | 15 +++++++++------ NativeLauncher/util/utils.cc | 1 + 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index 6724558..6adff4b 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -112,21 +112,6 @@ int CoreRuntime::initialize(bool standalone) putenv(const_cast("UNW_ARM_UNWIND_METHOD=6")); #endif // __arm__ - if (standalone) { - const char *deviceApiDirectory = getenv("__deviceAPIDirectory"); - const char *runtimeDirectory = getenv("__runtimeDirectory"); - if (deviceApiDirectory != nullptr) - __deviceAPIDirectory = deviceApiDirectory; - if (runtimeDirectory != nullptr) - __runtimeDirectory = runtimeDirectory; - -#ifdef USE_MANAGED_LAUNCHER - const char *launcherAssembly = getenv("__launcherAssembly"); - if (launcherAssembly != nullptr) - __launcherAssembly = launcherAssembly; -#endif - } - if (__deviceAPIDirectory.empty()) { _ERR("Empty Device API Directory"); return 1; diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index c23e16f..b5e566c 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -25,6 +25,8 @@ #include #include #include +#include +#include #define __XSTR(x) #x #define __STR(x) __XSTR(x) @@ -76,19 +78,20 @@ int main(int argc, char *argv[]) if (standalone) { _DBG("##### Run it standalone #########"); - const char* appId = getenv("AUL_APPID"); - _DBG("AUL_APPID : %s", appId); + char appId[1024] = {0,}; std::string appRoot; - if (appId != nullptr) { + if (AUL_R_OK == aul_app_get_appid_bypid(getpid(), appId, sizeof(appId))) { const char* appRootPath = aul_get_app_root_path(); if (appRootPath != nullptr) appRoot = std::string(appRootPath); } else { - appId = "dotnet-launcher"; + // If appId is not set, it is executed directly by cmdline. + // In this case, appRoot is passed as an argument. + snprintf(appId, 16, "%s", "dotnet-launcher"); + appRoot = baseName(baseName(standalonePath)); } + _DBG("AUL_APPID : %s", appId); - if (appRoot.empty()) - appRoot = baseName(baseName(standalonePath)); if (runtime->initialize(true) != 0) { _ERR("Failed to initialize"); return 1; diff --git a/NativeLauncher/util/utils.cc b/NativeLauncher/util/utils.cc index d5cf5d3..92440f1 100644 --- a/NativeLauncher/util/utils.cc +++ b/NativeLauncher/util/utils.cc @@ -145,6 +145,7 @@ static bool extCheckAndGetFileNameIfExist(const std::string& dir, const std::str if (fName.length() < ext.length() || fHame.compare(fName.length() - ext.length(), ext.length(), ext) != 0) { return false; + } std::string fullName = concatPath(dir, entry->d_name); switch (entry->d_type) { -- 2.7.4 From c9e5d8e142aa02dfeffe1d31ff819fffd899ae5a Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 1 Aug 2017 18:28:14 +0900 Subject: [PATCH 04/16] temporal patch for setting LANG environment value Change-Id: I0999f2ef62119d9d1d6278d09be915399ba6b0a1 --- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index 6adff4b..b268357 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -21,6 +21,8 @@ #include #include +#include + #include "utils.h" #include "log.h" #include "launcher.h" @@ -288,8 +290,27 @@ void CoreRuntime::dispose() _DBG("Dotnet runtime disposed"); } +static void setLang() +{ + char *lang; + lang = vconf_get_str(VCONFKEY_LANGSET); + if (lang) { + _DBG("setenv for language setting : %s", lang); + setenv("LANG", lang, 1); + setenv("LC_MESSAGES", lang, 1); + } +} + int CoreRuntime::launch(const char* appId, const char* root, const char* path, int argc, char* argv[]) { + // temporal patch to set LANG for coreclr. + // below code will be removed after applying appfw patch. + setLang(); + + vconf_notify_key_changed(VCONFKEY_LANGSET, [](keynode_t* node, void* user_data) { + setLang(); + }, NULL); + if (path == nullptr) { _ERR("executable path is null"); return 1; -- 2.7.4 From 03ce03422d3d65f8a5ead86e2bb14b364e6a5ce4 Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Thu, 24 Aug 2017 16:17:40 +0900 Subject: [PATCH 05/16] Add requires to launchpad Change-Id: I69d11c13bc633e296833160cb52cf946b57778bf --- packaging/dotnet-launcher.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index 7f4d46c..c9b0b7c 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -21,6 +21,7 @@ BuildRequires: aul-devel BuildRequires: dotnet-build-tools Requires: aul +Requires: launchpad Requires(post): /sbin/ldconfig Requires(post): /usr/bin/systemctl -- 2.7.4 From ab0c34497889634785b9c2c7efbbc5067363c18f Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Mon, 28 Aug 2017 19:01:38 +0900 Subject: [PATCH 06/16] Add null check Change-Id: I94bb4d6f6a3b56e71bc25b7f2a9bf5ba6f233b2c --- NativeLauncher/installer-plugin/common.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc index 8ba2a09..74b6f18 100644 --- a/NativeLauncher/installer-plugin/common.cc +++ b/NativeLauncher/installer-plugin/common.cc @@ -132,6 +132,10 @@ static void crossgen(const char* dllPath, const char* appPath) // get reference API directory ([DEVICE_API_DIR]/ref) int len = strlen(__DEVICE_API_DIR); char* refAPIDir = (char*)calloc(len + 4, 1); + if (!refAPIDir) { + printf("fail to allocate memory for reference API directory\n"); + return; + } snprintf(refAPIDir, len + 4, "%s%s", __DEVICE_API_DIR, "/ref"); tpaDir.push_back(refAPIDir); -- 2.7.4 From 91c9d05a8aa766d359443f478f6b00fbf4359c93 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Wed, 30 Aug 2017 15:25:45 +0900 Subject: [PATCH 07/16] change cmdline to executable path for standalone mode. after adapting this change, crash dump will be generated with executable name not dotnet-launcher Change-Id: I1052f2d8740f6d51dff978871252e2cbe10a1d63 --- NativeLauncher/launcher/main.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index b5e566c..b532832 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -44,7 +44,8 @@ int main(int argc, char *argv[]) { int i; bool standalone = false; - const char* standalonePath = nullptr; + char* standalonePath = nullptr; + int cmdlineSize = 0; std::vector vargs; @@ -61,10 +62,11 @@ int main(int argc, char *argv[]) return 1; } i++; - standalonePath = argv[i]; + standalonePath = strdup(argv[i]); } else { vargs.push_back(argv[i]); } + cmdlineSize += (strlen(argv[i]) +1); } using tizen::runtime::LauncherInterface; @@ -97,6 +99,10 @@ int main(int argc, char *argv[]) return 1; } + // change cmdline from dotnet-launcher to executable path + memset(argv[0], '\0', cmdlineSize); + snprintf(argv[0], cmdlineSize, "%s", standalonePath); + int argsLen = vargs.size(); char** args = &vargs[0]; if (runtime->launch(appId, appRoot.c_str(), standalonePath, argsLen, args)) { @@ -126,6 +132,10 @@ int main(int argc, char *argv[]) Launchpad.loaderMain(argc, argv); } + if (standalonePath != nullptr) { + free(standalonePath); + } + runtime->dispose(); return 0; } -- 2.7.4 From 8564ec92b5775026190ed190e81b272324fda4de Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 5 Sep 2017 08:58:51 +0900 Subject: [PATCH 08/16] bug-fix: to pass argument, change exectuable name to appid Change-Id: I1873bec7879c97c449060b98c895d8437a3a45f4 --- NativeLauncher/launcher/main.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index b532832..a3ad62b 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -37,6 +37,8 @@ #define LAUNCHER_VERSION_STR __STR(VERSION) #endif +#define CMD_LINE_SIZE 24 // sizeof("/usr/bin/dotnet-launcher") + static std::string VersionOption("--version"); static std::string StandaloneOption("--standalone"); @@ -45,7 +47,6 @@ int main(int argc, char *argv[]) int i; bool standalone = false; char* standalonePath = nullptr; - int cmdlineSize = 0; std::vector vargs; @@ -62,11 +63,10 @@ int main(int argc, char *argv[]) return 1; } i++; - standalonePath = strdup(argv[i]); + standalonePath = argv[i]; } else { vargs.push_back(argv[i]); } - cmdlineSize += (strlen(argv[i]) +1); } using tizen::runtime::LauncherInterface; @@ -100,8 +100,8 @@ int main(int argc, char *argv[]) } // change cmdline from dotnet-launcher to executable path - memset(argv[0], '\0', cmdlineSize); - snprintf(argv[0], cmdlineSize, "%s", standalonePath); + memset(argv[0], '\0', CMD_LINE_SIZE); + snprintf(argv[0], CMD_LINE_SIZE - 1, "%s", appId); int argsLen = vargs.size(); char** args = &vargs[0]; @@ -132,10 +132,6 @@ int main(int argc, char *argv[]) Launchpad.loaderMain(argc, argv); } - if (standalonePath != nullptr) { - free(standalonePath); - } - runtime->dispose(); return 0; } -- 2.7.4 From 02b56823ba57974509ecdee6f93903f8e3a2a42e Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 5 Sep 2017 08:58:51 +0900 Subject: [PATCH 09/16] bug-fix: to pass argument, change exectuable name to appid Change-Id: I1873bec7879c97c449060b98c895d8437a3a45f4 (cherry picked from commit 8564ec92b5775026190ed190e81b272324fda4de) --- NativeLauncher/launcher/main.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index b532832..a3ad62b 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -37,6 +37,8 @@ #define LAUNCHER_VERSION_STR __STR(VERSION) #endif +#define CMD_LINE_SIZE 24 // sizeof("/usr/bin/dotnet-launcher") + static std::string VersionOption("--version"); static std::string StandaloneOption("--standalone"); @@ -45,7 +47,6 @@ int main(int argc, char *argv[]) int i; bool standalone = false; char* standalonePath = nullptr; - int cmdlineSize = 0; std::vector vargs; @@ -62,11 +63,10 @@ int main(int argc, char *argv[]) return 1; } i++; - standalonePath = strdup(argv[i]); + standalonePath = argv[i]; } else { vargs.push_back(argv[i]); } - cmdlineSize += (strlen(argv[i]) +1); } using tizen::runtime::LauncherInterface; @@ -100,8 +100,8 @@ int main(int argc, char *argv[]) } // change cmdline from dotnet-launcher to executable path - memset(argv[0], '\0', cmdlineSize); - snprintf(argv[0], cmdlineSize, "%s", standalonePath); + memset(argv[0], '\0', CMD_LINE_SIZE); + snprintf(argv[0], CMD_LINE_SIZE - 1, "%s", appId); int argsLen = vargs.size(); char** args = &vargs[0]; @@ -132,10 +132,6 @@ int main(int argc, char *argv[]) Launchpad.loaderMain(argc, argv); } - if (standalonePath != nullptr) { - free(standalonePath); - } - runtime->dispose(); return 0; } -- 2.7.4 From b72b8f28e67769724ad661e7a3ef1744627559a4 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Thu, 7 Sep 2017 10:43:51 +0900 Subject: [PATCH 10/16] update launching time measure tool Change-Id: Ie8c1e2ea9cb8d89f8d8ddaf2cf6485f902147a88 --- tools/performance_test.sh | 10 +++++----- tools/timestamp.sh | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/performance_test.sh b/tools/performance_test.sh index 43b7962..ed289fb 100755 --- a/tools/performance_test.sh +++ b/tools/performance_test.sh @@ -132,7 +132,7 @@ execute_time_stamp_auto () echo "" #execute dlogstreamer sdb shell "dlogutil -c" - sdb shell "dlogutil -v time AUL APP_CORE_UI_BASE|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|appcore_ui_base_window_on_show.*[EVENT_TEST][EVENT]'" >> $STREAM_LOG_FILE & + sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done]'" >> $STREAM_LOG_FILE & DLOG_STREAMER_PID=$! #execute timestamp /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE & @@ -145,7 +145,7 @@ execute_time_stamp_auto_memory () echo "[>] Start performance test that applciation launching memory" echo "" sdb shell "dlogutil -c" - sdb shell "dlogutil -v time AUL APP_CORE_UI_BASE|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|appcore_ui_base_window_on_show.*[EVENT_TEST][EVENT]'" >> $STREAM_LOG_FILE & + sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|Launching:done'" >> $STREAM_LOG_FILE & DLOG_STREAMER_PID=$! #execute timestamp /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE & @@ -164,7 +164,7 @@ execute_time_stamp_manual () rm $STREAM_LOG_FILE touch $STREAM_LOG_FILE sdb shell "dlogutil -c" - sdb shell "dlogutil -v time AUL APP_CORE_UI_BASE|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|appcore_ui_base_window_on_show.*[EVENT_TEST][EVENT]'" >> $STREAM_LOG_FILE & + sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done'" >> $STREAM_LOG_FILE & DLOG_STREAMER_PID=$! #execute timestamp /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE @@ -181,7 +181,7 @@ execute_time_stamp_manual_trace () rm $STREAM_LOG_FILE touch $STREAM_LOG_FILE sdb shell "dlogutil -c" - sdb shell "dlogutil -v time AUL APP_CORE_UI_BASE|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|appcore_ui_base_window_on_show.*[EVENT_TEST][EVENT]'" >> $STREAM_LOG_FILE & + sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|Launching:done'" >> $STREAM_LOG_FILE & DLOG_STREAMER_PID=$! #execute timestamp /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE & @@ -202,7 +202,7 @@ execute_time_stamp_manual_memory () rm $STREAM_LOG_FILE touch $STREAM_LOG_FILE sdb shell "dlogutil -c" - sdb shell "dlogutil -v time AUL APP_CORE_UI_BASE|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|appcore_ui_base_window_on_show.*[EVENT_TEST][EVENT]'" >> $STREAM_LOG_FILE & + sdb shell "dlogutil -v time AUL LAUNCH|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|Launching:done'" >> $STREAM_LOG_FILE & DLOG_STREAMER_PID=$! #execute timestamp /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE & diff --git a/tools/timestamp.sh b/tools/timestamp.sh index 8d94aad..5b6ae2b 100755 --- a/tools/timestamp.sh +++ b/tools/timestamp.sh @@ -35,9 +35,9 @@ while inotifywait -qqre modify "$LOG_FILE"; do fi fi - if [[ $GET_LOG == *APP_CORE* ]] && [ "$IS_START" = true ] + if [[ $GET_LOG == *"LAUNCH"* ]] && [ "$IS_START" = true ] then - END_T=$(echo "$GET_LOG" | grep SHOW | awk '{print $2}') + END_T=$(echo "$GET_LOG" | grep Launching | awk '{print $2}') END_T=${END_T%%+0900} END_T=$(echo $END_T | sed "s/:/./g") -- 2.7.4 From 6467e185cd4a1b721ad71ac419697e381eb8115d Mon Sep 17 00:00:00 2001 From: woongsuk cho Date: Wed, 13 Sep 2017 01:43:57 +0000 Subject: [PATCH 11/16] Revert "temporal patch for setting LANG environment value" This reverts commit c9e5d8e142aa02dfeffe1d31ff819fffd899ae5a. Change-Id: I0f09e4cedbbd0c1889d59f1d2a98c45261a7a6b8 --- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index b268357..6adff4b 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -21,8 +21,6 @@ #include #include -#include - #include "utils.h" #include "log.h" #include "launcher.h" @@ -290,27 +288,8 @@ void CoreRuntime::dispose() _DBG("Dotnet runtime disposed"); } -static void setLang() -{ - char *lang; - lang = vconf_get_str(VCONFKEY_LANGSET); - if (lang) { - _DBG("setenv for language setting : %s", lang); - setenv("LANG", lang, 1); - setenv("LC_MESSAGES", lang, 1); - } -} - int CoreRuntime::launch(const char* appId, const char* root, const char* path, int argc, char* argv[]) { - // temporal patch to set LANG for coreclr. - // below code will be removed after applying appfw patch. - setLang(); - - vconf_notify_key_changed(VCONFKEY_LANGSET, [](keynode_t* node, void* user_data) { - setLang(); - }, NULL); - if (path == nullptr) { _ERR("executable path is null"); return 1; -- 2.7.4 From 3f04bea75943d9cb11c1bf861ade7993e0ff74d4 Mon Sep 17 00:00:00 2001 From: Youngjae Shin Date: Mon, 25 Sep 2017 16:15:23 +0900 Subject: [PATCH 12/16] fix build warning Change-Id: I67138414a61ba4594920830b4ad95e3f72b62e23 --- NativeLauncher/installer-plugin/common.cc | 2 ++ Tizen.Runtime/CoreClr/AssemblyManager.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc index 74b6f18..4d5feeb 100644 --- a/NativeLauncher/installer-plugin/common.cc +++ b/NativeLauncher/installer-plugin/common.cc @@ -64,6 +64,7 @@ static const char* __JIT_PATH = __STR(RUNTIME_DIR)"/libclrjit.so"; #undef __XSTR +#if 0 static std::string replace(std::string &str, const std::string& from, const std::string& to) { size_t startPos = 0; @@ -73,6 +74,7 @@ static std::string replace(std::string &str, const std::string& from, const std: } return str; } +#endif static void smack_(const char* dllPath, const char* label) { diff --git a/Tizen.Runtime/CoreClr/AssemblyManager.cs b/Tizen.Runtime/CoreClr/AssemblyManager.cs index d8b19f5..60b3e54 100644 --- a/Tizen.Runtime/CoreClr/AssemblyManager.cs +++ b/Tizen.Runtime/CoreClr/AssemblyManager.cs @@ -96,8 +96,8 @@ namespace Tizen.Runtime.Coreclr { try { - /// Set UnhandledException handler with reflection - /// we must replace this to no reflection method after AppDomain is comming in used net standard + // Set UnhandledException handler with reflection + // we must replace this to no reflection method after AppDomain is comming in used net standard TypeInfo appdomainType = Type.GetType("System.AppDomain").GetTypeInfo(); PropertyInfo currentDomain = appdomainType.GetProperty("CurrentDomain", BindingFlags.Public | BindingFlags.Static); -- 2.7.4 From 8880e9c986ae1d0037ef812e0b2f59981a96e804 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Thu, 12 Oct 2017 14:01:10 +0900 Subject: [PATCH 13/16] add plugin api to set coreclr info Change-Id: I83f76c7cfbb939e6b397150db1675c41e264b7fb --- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 6 ++++++ NativeLauncher/launcher/dotnet/dotnet_launcher.h | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index 6adff4b..7734df5 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -46,6 +46,7 @@ CoreRuntime::CoreRuntime() : pluginInitialize(nullptr), pluginPreload(nullptr), pluginSetAppInfo(nullptr), + pluginSetCoreclrInfo(nullptr), pluginGetDllPath(nullptr), pluginBeforeExecute(nullptr), pluginFinalize(nullptr) @@ -79,6 +80,7 @@ CoreRuntime::CoreRuntime() : pluginInitialize = (plugin_initialize_ptr)dlsym(__pluginLib, "plugin_initialize"); pluginPreload = (plugin_preload_ptr)dlsym(__pluginLib, "plugin_preload"); pluginSetAppInfo = (plugin_set_app_info_ptr)dlsym(__pluginLib, "plugin_set_app_info"); + pluginSetCoreclrInfo = (plugin_set_coreclr_info_ptr)dlsym(__pluginLib, "plugin_set_coreclr_info"); pluginGetDllPath = (plugin_get_dll_path_ptr)dlsym(__pluginLib, "plugin_get_dll_path"); pluginBeforeExecute = (plugin_before_execute_ptr)dlsym(__pluginLib, "plugin_before_execute"); pluginFinalize = (plugin_finalize_ptr)dlsym(__pluginLib, "plugin_finalize"); @@ -211,6 +213,9 @@ bool CoreRuntime::initializeCoreClr(const char* appId, return false; } + if (pluginSetCoreclrInfo) + pluginSetCoreclrInfo(__hostHandle, __domainId); + _DBG("Initialize core clr success"); return true; } @@ -280,6 +285,7 @@ void CoreRuntime::dispose() pluginInitialize = nullptr; pluginPreload = nullptr; pluginSetAppInfo = nullptr; + pluginSetCoreclrInfo = nullptr; pluginGetDllPath = nullptr; pluginBeforeExecute = nullptr; pluginFinalize = nullptr; diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.h b/NativeLauncher/launcher/dotnet/dotnet_launcher.h index 931846c..aaaa9d8 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.h +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.h @@ -56,7 +56,11 @@ extern "C" typedef void (*plugin_set_app_info_ptr)( const char* appId, - const char* hostHandle); + const char* managedAssemblyPath); + + typedef void (*plugin_set_coreclr_info_ptr)( + void* hostHandle, + unsigned int domainId); typedef char* (*plugin_get_dll_path_ptr)(); @@ -103,6 +107,7 @@ class CoreRuntime : public tizen::runtime::LauncherInterface plugin_initialize_ptr pluginInitialize; plugin_preload_ptr pluginPreload; plugin_set_app_info_ptr pluginSetAppInfo; + plugin_set_coreclr_info_ptr pluginSetCoreclrInfo; plugin_get_dll_path_ptr pluginGetDllPath; plugin_before_execute_ptr pluginBeforeExecute; plugin_finalize_ptr pluginFinalize; -- 2.7.4 From 5df12f517493615cd2aee051add7bb307c500d1c Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 17 Oct 2017 09:20:23 +0900 Subject: [PATCH 14/16] remove unneccessary log to remove warning message Change-Id: Icc79f0550ce69e266b00f1c95aeb029ea6579807 --- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 2 -- NativeLauncher/launcher/launcher.cc | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index 6adff4b..682d532 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -166,8 +166,6 @@ int CoreRuntime::initialize(bool standalone) #undef CORELIB_RETURN_IF_NOSYM _DBG("libcoreclr dlopen and dlsym success"); - _DBG("this addr : %x", this); - _DBG("coreclr_initialize : %x", initializeClr); if (!standalone && pluginPreload) pluginPreload(); diff --git a/NativeLauncher/launcher/launcher.cc b/NativeLauncher/launcher/launcher.cc index 91ccb02..aaeefd6 100644 --- a/NativeLauncher/launcher/launcher.cc +++ b/NativeLauncher/launcher/launcher.cc @@ -143,7 +143,7 @@ static void preloadLibsAndWindow(bundle *extra, int type, void *userData) for (i = 0; i < len; i++) { handle = dlopen(soArray[i], RTLD_NOW); - _DBG("preload %s# - handle : %x", soArray[i], handle); + _DBG("preload %s#", soArray[i]); } // Precreate window -- 2.7.4 From 1a2aa15b1a961dcd54c46883356351e8b84bc8fb Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Thu, 2 Nov 2017 19:10:41 +0900 Subject: [PATCH 15/16] big-fix: add reference dll for NI Change-Id: Ia974ecd5469ff152204f6cf7c8adaa693b488088 (cherry picked from commit 195453317830e9b517950a6153e078f91f1e7500) --- NativeLauncher/installer-plugin/common.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc index 4d5feeb..f84e79c 100644 --- a/NativeLauncher/installer-plugin/common.cc +++ b/NativeLauncher/installer-plugin/common.cc @@ -133,12 +133,12 @@ static void crossgen(const char* dllPath, const char* appPath) // get reference API directory ([DEVICE_API_DIR]/ref) int len = strlen(__DEVICE_API_DIR); - char* refAPIDir = (char*)calloc(len + 4, 1); + char* refAPIDir = (char*)calloc(len + 5, 1); if (!refAPIDir) { printf("fail to allocate memory for reference API directory\n"); return; } - snprintf(refAPIDir, len + 4, "%s%s", __DEVICE_API_DIR, "/ref"); + snprintf(refAPIDir, len + 5, "%s%s", __DEVICE_API_DIR, "/ref"); tpaDir.push_back(refAPIDir); std::string tpa; -- 2.7.4 From 2257c6b542c3bbf76619f60093fb9ee78631735f Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Wed, 23 Aug 2017 11:33:23 +0900 Subject: [PATCH 16/16] comment out unused code and change log Change-Id: I944f7ad3320bd5a15d20332ba1934fc60b162a42 --- NativeLauncher/installer-plugin/common.cc | 1 - NativeLauncher/launcher/main.cc | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc index f84e79c..f7fc71b 100644 --- a/NativeLauncher/installer-plugin/common.cc +++ b/NativeLauncher/installer-plugin/common.cc @@ -63,7 +63,6 @@ static const char* __JIT_PATH = __STR(RUNTIME_DIR)"/libclrjit.so"; #undef __STR #undef __XSTR - #if 0 static std::string replace(std::string &str, const std::string& from, const std::string& to) { diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index a3ad62b..0922908 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) std::vector vargs; // start index 1 to avoid passing executable name "dotnet-launcher" as a parameter - for (i = 1; i launch(appId, appRoot.c_str(), standalonePath, argsLen, args)) { _ERR("Failed to launch"); - return 0; + return 1; } } else { Launchpad.onCreate = [&runtime]() { @@ -118,7 +118,7 @@ int main(int argc, char *argv[]) }; Launchpad.onTerminate = [&runtime](const AppInfo& appInfo, int argc, char** argv) { - _DBG("terminated with app path : %s", appInfo.path.c_str()); + _DBG("launch request with app path : %s", appInfo.path.c_str()); _DBG("appId : %s", appInfo.id.c_str()); _DBG("pkg : %s", appInfo.pkg.c_str()); _DBG("type : %s", appInfo.type.c_str()); -- 2.7.4