GOT patcher: add profiling by apps comm 35/96635/2
authorAlexander Aksenov <a.aksenov@samsung.com>
Wed, 9 Nov 2016 12:34:58 +0000 (15:34 +0300)
committerAlexander Aksenov <a.aksenov@samsung.com>
Wed, 9 Nov 2016 13:41:58 +0000 (16:41 +0300)
Change-Id: I5c07280b566e6fab29bfe83ed7aa7bb852df2cc3
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
daemon/da_inst.c

index 6591139..77917d6 100644 (file)
@@ -863,39 +863,77 @@ static int write_bins_to_preload(struct user_space_inst_t *us_inst)
 
 
 
-#define GTP_ADD_BIN "/sys/kernel/debug/swap/got_patcher/by_path/add"
+#define GTP_ADD_BY_PATH "/sys/kernel/debug/swap/got_patcher/by_path/add"
+#define GTP_ADD_BY_PID "/sys/kernel/debug/swap/got_patcher/by_pid/add"
+#define GTP_ADD_BY_ID "/sys/kernel/debug/swap/got_patcher/by_id/add"
 
 static int add_bins_to_gtp(struct user_space_inst_t *us_inst)
 {
        struct app_list_t *app = us_inst->app_inst_list;
        uint32_t total_maps_count = 0;
        char real_path_buf[PATH_MAX];
-       char *resolved;
+       char *to_write;
        FILE *gtp_p;
 
-       gtp_p = fopen(GTP_ADD_BIN, "w");
-       if (gtp_p == NULL)
-               return -EINVAL;
-
        while (app != NULL) {
-               resolved = realpath((const char *)app->app->exe_path, real_path_buf);
-               if (resolved != NULL) {
-                       total_maps_count++;
-                       fwrite(resolved, strlen(resolved) + 1, 1, gtp_p);
-                       fflush(gtp_p);
+               switch (app->app->app_type) {
+               case APP_TYPE_TIZEN:
+               case APP_TYPE_COMMON:
+                       gtp_p = fopen(GTP_ADD_BY_PATH, "w");
+                       if (gtp_p == NULL) {
+                               LOGE("Cannot open <%s> to write!",
+                                    GTP_ADD_BY_PATH);
+                               break;
+                       }
 
-                       LOGI("app #%u <%s>\n", total_maps_count, resolved);
+                       to_write = realpath((const char *)app->app->exe_path,
+                                           real_path_buf);
+                       if (to_write != NULL) {
+                               total_maps_count++;
+                               fwrite(to_write, strlen(to_write) + 1, 1,
+                                      gtp_p);
+                               fflush(gtp_p);
+
+                               LOGI("app #%u <%s>\n", total_maps_count,
+                                    to_write);
+                       }
+                       fclose(gtp_p);
+                       break;
+               case APP_TYPE_RUNNING:
+                       /* TODO Support already running */
+                       break;
+               case APP_TYPE_WEB:
+                       gtp_p = fopen(GTP_ADD_BY_ID, "w");
+                       if (gtp_p == NULL) {
+                               LOGE("Cannot open <%s> to write!",
+                                    GTP_ADD_BY_ID);
+                               break;
+                       }
+
+                       to_write = app->app->app_id;
+                       if (to_write != NULL) {
+                               total_maps_count++;
+                               fwrite(to_write, strlen(to_write) + 1, 1,
+                                      gtp_p);
+                               fflush(gtp_p);
+
+                               LOGI("app #%u <%s>\n", total_maps_count,
+                                    to_write);
+                       }
+                       fclose(gtp_p);
+                       break;
                }
 
                app = (struct app_list_t *)app->next;
        }
 
-       fclose(gtp_p);
 
        return 0;
 }
 
-#undef GTP_ADD_BIN
+#undef GTP_ADD_BY_ID
+#undef GTP_ADD_BY_PID
+#undef GTP_ADD_BY_PATH
 
 #define GTP_CLEAN "/sys/kernel/debug/swap/got_patcher/del_all"