set environment for debugging by env_list 61/184261/3
authorWoongsuk Cho <ws77.cho@samsung.com>
Tue, 17 Jul 2018 00:22:03 +0000 (09:22 +0900)
committerWoongsuk Cho <ws77.cho@samsung.com>
Tue, 24 Jul 2018 11:13:16 +0000 (20:13 +0900)
Change-Id: If360563f29bb7ec6ff336d318fea2e361bfb3549

NativeLauncher/launcher/dotnet/dotnet_launcher.cc

index 676029c..d11c8f0 100644 (file)
@@ -20,6 +20,7 @@
 #include <string>
 #include <fstream>
 #include <vector>
+#include <sstream>
 
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -36,6 +37,7 @@
 #include "log_manager.h"
 
 #define PLUGIN_PATH "/usr/share/dotnet.tizen/lib/libdotnet_plugin.so"
+#define ENV_FILE_PATH "/usr/share/dotnet.tizen/lib/coreclr_env.list"
 
 namespace tizen {
 namespace runtime {
@@ -83,6 +85,37 @@ static std::string getExtraNativeLibDirs(const std::string& appRoot)
        return candidate;
 }
 
+
+static std::vector<std::string> __envList;
+
+static void setEnvFromFile()
+{
+       std::string envList;
+       std::ifstream inFile(ENV_FILE_PATH);
+
+       __envList.clear();
+
+       if (inFile) {
+               _INFO("coreclr_env.list is found");
+               inFile >> envList;
+
+               std::istringstream ss(envList);
+               std::string token;
+
+               while (std::getline(ss, token, ':')) {
+                       if (!token.empty()) {
+                               __envList.push_back(token);
+                       }
+               }
+
+               for (unsigned int i = 0; i < __envList.size(); i++) {
+                       putenv(const_cast<char *>(__envList[i].c_str()));
+               }
+       } else {
+               _INFO("coreclr_env.list file is not found. skip");
+       }
+}
+
 CoreRuntime::CoreRuntime(const char* mode) :
        initializeClr(nullptr),
        executeAssembly(nullptr),
@@ -136,6 +169,9 @@ int CoreRuntime::initialize(bool standalone)
        putenv(const_cast<char *>("UNW_ARM_UNWIND_METHOD=6"));
 #endif // __arm__
 
+       // read string from external file and set them to environment value.
+       setEnvFromFile();
+
        if (initializePathManager(std::string(), std::string(), std::string()) < 0) {
                _ERR("Failed to initialize PathManager");
                return -1;
@@ -267,6 +303,8 @@ void CoreRuntime::dispose()
        finalizePluginManager();
        finalizePathManager();
 
+       __envList.clear();
+
        _DBG("Dotnet runtime disposed");
 }