From 8564ec92b5775026190ed190e81b272324fda4de Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 5 Sep 2017 08:58:51 +0900 Subject: [PATCH 01/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 02/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 03/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 04/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 05/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 06/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 07/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 08/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 09/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 From 14af36a2752af7008cb985f6e60e700e25b8282c Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Wed, 23 Aug 2017 15:24:40 +0900 Subject: [PATCH 10/16] check return value of loaderMain to avoid crash Change-Id: Ib5a740a34c7f8b171fb890dc1f97c51e93ad647d --- NativeLauncher/launcher/launcher.cc | 7 ++++--- NativeLauncher/launcher/launcher.h | 2 +- NativeLauncher/launcher/main.cc | 6 +++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/NativeLauncher/launcher/launcher.cc b/NativeLauncher/launcher/launcher.cc index aaeefd6..91c24a1 100644 --- a/NativeLauncher/launcher/launcher.cc +++ b/NativeLauncher/launcher/launcher.cc @@ -53,7 +53,7 @@ class LaunchpadAdapterImpl : public LaunchpadAdapter launcher(nullptr), __isLaunched(false) { } - void loaderMain(int argc, char* argv[]) override; + int loaderMain(int argc, char* argv[]) override; std::map handlers; @@ -161,7 +161,7 @@ static void preloadLibsAndWindow(bundle *extra, int type, void *userData) elm_win_precreated_object_set(__win); } -void LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) +int LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) { __argc = argc; __argv = argv; @@ -189,7 +189,6 @@ void LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) return 0; }; callbacks.terminate = [](int argc, char **argv, void* userData) -> int { - _DBG("Terminate!!"); WITH_SELF(userData) { if (self->onTerminate != nullptr) self->onTerminate(self->appInfo, argc, argv); @@ -210,6 +209,8 @@ void LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) _DBG("launchpad_loader_main is start"); int r = launchpad_loader_main(argc, argv, &(this->callbacks), &(this->adapter), this); _DBG("launchpad_loader_main is finished with [%d]", r); + + return r; } #undef WITH_SELF diff --git a/NativeLauncher/launcher/launcher.h b/NativeLauncher/launcher/launcher.h index 41ed2ac..ce91241 100644 --- a/NativeLauncher/launcher/launcher.h +++ b/NativeLauncher/launcher/launcher.h @@ -43,7 +43,7 @@ struct AppInfo { class LaunchpadAdapter { public: - virtual void loaderMain(int argc, char* argv[]) = 0; + virtual int loaderMain(int argc, char* argv[]) = 0; std::function onCreate = nullptr; std::function onLaunch = nullptr; std::function onTerminate = nullptr; diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index 0922908..6fcfb9b 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -129,7 +129,11 @@ int main(int argc, char *argv[]) if (runtime->launch(appInfo.id.c_str(), appInfo.root.c_str(), appInfo.path.c_str(), argc-1, argv+1)) _ERR("Failed to launch"); }; - Launchpad.loaderMain(argc, argv); + int ret = Launchpad.loaderMain(argc, argv); + if (ret < 0) { + _DBG("fail to start loaderMain. candidate process is not created."); + return 1; + } } runtime->dispose(); -- 2.7.4 From 2169c2f2e0c92929f20ba81c4eb0dcd43819a71c Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Fri, 8 Sep 2017 11:24:07 +0900 Subject: [PATCH 11/16] bug-patch:support -am option Change-Id: I3e71bef55eea848e52bf4b417ddcab582b3421f0 --- tools/performance_test.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/performance_test.sh b/tools/performance_test.sh index ed289fb..3519cc4 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 LAUNCH|grep -E 'launch.*app_request_to_launchpad_for_uid.*request.*appid|Launching:done]'" >> $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 LAUNCH|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|Launching:done'" >> $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 LAUNCH|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|Launching:done'" >> $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 & @@ -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 LAUNCH|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|Launching:done'" >> $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 & -- 2.7.4 From b8364639ea341f44381271cc186c4299c317f5a3 Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Wed, 19 Jul 2017 14:49:39 +0900 Subject: [PATCH 12/16] Remove caps due to security issue. Apply caps directly in security-config Change-Id: I476d6928065762427d360e22518bf8330266808f --- packaging/dotnet-launcher.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index c9b0b7c..d4045f2 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -99,4 +99,3 @@ ln -sf %{_libdir}/libsqlite3.so.0 %{buildroot}%{_native_lib_dir}/libsqlite3.so %if %{use_managed_launcher} %{_bindir}/Tizen.Runtime.dll %endif -%caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/dotnet-launcher -- 2.7.4 From 1f4fe78e4b16ccff778af75592a77f85cca11d5b Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Fri, 3 Nov 2017 13:30:12 +0900 Subject: [PATCH 13/16] add dotnet-launcher to files list to remove build error Change-Id: I88b3dab1dff4a7e30bfe1e6dfaee06b2d8edaf6b --- packaging/dotnet-launcher.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index d4045f2..1bebcca 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -99,3 +99,4 @@ ln -sf %{_libdir}/libsqlite3.so.0 %{buildroot}%{_native_lib_dir}/libsqlite3.so %if %{use_managed_launcher} %{_bindir}/Tizen.Runtime.dll %endif +%{_bindir}/dotnet-launcher \ No newline at end of file -- 2.7.4 From 74702a30ffb1af33dc4c50ccf8c2c7e9ef19db60 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Fri, 3 Nov 2017 13:48:30 +0900 Subject: [PATCH 14/16] add cap_sys_admin and cap_setgid to dotnet-launcher to use candidate process Change-Id: I5034c7cca0d967708b69f3495d6665a4f49cf847 --- packaging/dotnet-launcher.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index 1bebcca..369d243 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -99,4 +99,4 @@ ln -sf %{_libdir}/libsqlite3.so.0 %{buildroot}%{_native_lib_dir}/libsqlite3.so %if %{use_managed_launcher} %{_bindir}/Tizen.Runtime.dll %endif -%{_bindir}/dotnet-launcher \ No newline at end of file +%caps(cap_sys_admin,cap_setgid=ei) %{_bindir}/dotnet-launcher -- 2.7.4 From 3e3d508f3fa04835c34edc480f1cb9be4d3f8867 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 14 Nov 2017 15:32:31 +0900 Subject: [PATCH 15/16] add exception handling code for null return Change-Id: I41834f55e6d8d9e33a8d76bead8b281aec2c1a65 --- NativeLauncher/launcher/launcher.cc | 5 ++++- NativeLauncher/launcher/main.cc | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/NativeLauncher/launcher/launcher.cc b/NativeLauncher/launcher/launcher.cc index 91c24a1..e0b5ed0 100644 --- a/NativeLauncher/launcher/launcher.cc +++ b/NativeLauncher/launcher/launcher.cc @@ -177,7 +177,10 @@ int LaunchpadAdapterImpl::loaderMain(int argc, char* argv[]) const char* appId, const char* pkgId, const char* pkgType, void* userData) -> int { WITH_SELF(userData) { - self->appInfo.root = std::string(aul_get_app_root_path()); + const char* appRootPath = aul_get_app_root_path(); + if (appRootPath != nullptr) { + self->appInfo.root = std::string(appRootPath); + } self->appInfo.path = appPath; self->appInfo.id = appId; self->appInfo.pkg = pkgId; diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index 6fcfb9b..6c1ac12 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -123,11 +123,15 @@ int main(int argc, char *argv[]) _DBG("pkg : %s", appInfo.pkg.c_str()); _DBG("type : %s", appInfo.type.c_str()); - // The launchpad pass the name of exe file to the first argument. - // For the C# spec, we have to skip this first argument. - - if (runtime->launch(appInfo.id.c_str(), appInfo.root.c_str(), appInfo.path.c_str(), argc-1, argv+1)) - _ERR("Failed to launch"); + // aul_get_app_root_path() can return NULL for error case. + if (appInfo.root.empty()) { + _ERR("Failed to launch. root path is set to NULL"); + } else { + // The launchpad pass the name of exe file to the first argument. + // For the C# spec, we have to skip this first argument. + if (runtime->launch(appInfo.id.c_str(), appInfo.root.c_str(), appInfo.path.c_str(), argc-1, argv+1)) + _ERR("Failed to launch"); + } }; int ret = Launchpad.loaderMain(argc, argv); if (ret < 0) { -- 2.7.4 From b9e2f8612cc34f8b34290ebb7e3c628664b8026f Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 28 Nov 2017 14:04:34 +0900 Subject: [PATCH 16/16] redirect stdout and stderr to dlog Change-Id: I4c5fe9f676e5fa3f5f8009eac910976e933acffd --- NativeLauncher/inc/utils.h | 2 + NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 4 ++ NativeLauncher/util/utils.cc | 69 ++++++++++++++++++++++- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/NativeLauncher/inc/utils.h b/NativeLauncher/inc/utils.h index 034b7f3..ac3816e 100644 --- a/NativeLauncher/inc/utils.h +++ b/NativeLauncher/inc/utils.h @@ -43,4 +43,6 @@ std::string joinStrings(const std::vector& strings, const char* con typedef std::function FileReader; void scanFilesInDir(const char* directory, FileReader reader, unsigned int depth); + +int runLoggingThread(); #endif /* __UTILS_H__ */ diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index db93b4f..f19e5af 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -335,6 +335,10 @@ int CoreRuntime::launch(const char* appId, const char* root, const char* path, i if (pluginBeforeExecute) pluginBeforeExecute(); + if (runLoggingThread() < 0) { + _ERR("Failed to create logging thread"); + } + #ifdef USE_MANAGED_LAUNCHER runManagedLauncher(appId, probePath.c_str(), tpa.c_str()); diff --git a/NativeLauncher/util/utils.cc b/NativeLauncher/util/utils.cc index 92440f1..d4142eb 100644 --- a/NativeLauncher/util/utils.cc +++ b/NativeLauncher/util/utils.cc @@ -14,12 +14,13 @@ * limitations under the License. */ - +#include #include #include #include #include #include +#include #include #include @@ -30,6 +31,10 @@ #include #include "utils.h" +#include "log.h" + +static int pfd[2]; +static pthread_t loggingThread; bool iCompare(const std::string& a, const std::string& b) { @@ -292,4 +297,64 @@ void scanFilesInDir(const char* directory, FileReader reader, unsigned int depth scanFilesInDir(d.c_str(), reader, depth-1); closedir(dir); -} \ No newline at end of file +} + +static void *stdlog(void*) +{ + ssize_t readSize; + char buf[1024]; + + while ((readSize = read(pfd[0], buf, sizeof buf - 1)) > 0) { + if (buf[readSize - 1] == '\n') { + --readSize; + } + + buf[readSize] = 0; + + _INFO("%s", buf); + } + + return 0; +} + +int runLoggingThread() { // run this function to redirect your output to android log + if (setvbuf(stdout, NULL, _IOLBF, 0) < 0) { + _DBG("fail to make stdout line-buffered"); + return -1; + } + + if (setvbuf(stderr, NULL, _IONBF, 0) < 0) { + _DBG("make stderr unbuffered"); + return -1; + } + + /* create the pipe and redirect stdout and stderr */ + if (pipe(pfd) < 0) { + _DBG("fail to create pipe for logging"); + return -1; + } + + if (dup2(pfd[1], fileno(stdout)) == -1) { + _DBG("fail to duplicate fd to stdout"); + return -1; + } + + if (dup2(pfd[1], fileno(stderr)) == -1) { + _DBG("fail to duplicate fd to stderr"); + return -1; + } + + /* spawn the logging thread */ + if (pthread_create(&loggingThread, 0, stdlog, 0) != 0) { + _DBG("fail to create pthread"); + return -1; + } + + if (pthread_detach(loggingThread) != 0) { + _DBG("fail to detach pthread"); + return -1; + } + + return 0; +} + -- 2.7.4