[PROTO] remove msg process info
authorAnastasia Lyupa <a.lyupa@samsung.com>
Thu, 10 Oct 2013 10:49:13 +0000 (14:49 +0400)
committerNikita Kalyazin <n.kalyazin@samsung.com>
Fri, 11 Oct 2013 05:58:02 +0000 (09:58 +0400)
it is done in modules since now

Change-Id: I18744c5ec729765dbec53b4ab5042703e2643060
Signed-off-by: Anastasia Lyupa <a.lyupa@samsung.com>
daemon/Makefile
daemon/daemon.c
daemon/daemon.h
daemon/main.c
daemon/process_info.c [deleted file]
daemon/process_info.h [deleted file]
daemon/threads.c

index 7ce52517b8031715a66683f331cc433f7bed73ef..3e5c598ae37c6f17ea9bf1d76b82b73e90f6f01c 100644 (file)
@@ -25,7 +25,6 @@ DAEMON_SRCS =                 \
        elf.c                   \
        ioctl_commands.c        \
        main.c                  \
-       process_info.c          \
        sys_stat.c              \
        threads.c               \
        transfer_thread.c       \
index c053d25a6369ac9c0b327dacd02ba7b51d56a7f4..f836de5f1f0347ec998819a6b67635738e0fdc2c 100644 (file)
@@ -62,7 +62,6 @@
 #include "da_inst.h"
 #include "da_data.h"
 #include "debug.h"
-#include "process_info.h"
 
 #define DA_WORK_DIR                            "/home/developer/sdk_tools/da/"
 #define DA_READELF_PATH                        "/home/developer/sdk_tools/da/readelf"
@@ -246,7 +245,6 @@ static void setEmptyTargetSlot(int index)
                manager.target[index].pid = -1;
                manager.target[index].recv_thread = -1;
                manager.target[index].allocmem = 0;
-               manager.target[index].starttime = 0;
                manager.target[index].initial_log = 0;
                if(manager.target[index].event_fd != -1)
                        close(manager.target[index].event_fd);
@@ -338,7 +336,6 @@ static int exec_app(const struct app_info_t *app_info)
        case APP_TYPE_RUNNING:
                // TODO: nothing, it's running
                LOGI("already started\n");
-               write_process_info(atoi(app_info->app_id), 0);
                break;
        case APP_TYPE_COMMON:
                kill_app(app_info->exe_path);
index 044dbbe07d456d6d943ec1b7c617c31c58d31af8..32210f5ab4cead8b3bce33ef4b61198a03085a0c 100644 (file)
@@ -171,7 +171,6 @@ typedef struct
 
 typedef struct
 {
-       uint64_t                starttime;              // written only by recv thread
        int64_t                 allocmem;               // written only by recv thread
        pid_t                           pid;                    // written only by recv thread
        int                             socket;                 // written only by main thread
index 751ac4b3b61369a7da2965f897841f223a7fee0d..ddb071c2f5079f2c9f6f48c698a678f66a2658a5 100644 (file)
@@ -273,8 +273,7 @@ static void inititialize_manager_targets(__da_manager * mng)
                .event_fd = -1,
                .recv_thread = -1,
                .initial_log = 0,
-               .allocmem = 0,
-               .starttime = 0
+               .allocmem = 0
        };
 
        for (index = 0; index < MAX_TARGET_COUNT; index++)
diff --git a/daemon/process_info.c b/daemon/process_info.c
deleted file mode 100644 (file)
index 77dbab0..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- *  DA manager
- *
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- *
- * Nikita Kalyazin    <n.kalyazin@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - Samsung RnD Institute Russia
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "da_protocol.h"
-#include "da_data.h"
-#include "da_inst.h"
-#include "utils.h"
-#include "elf.h"
-#include "debug.h"
-
-#define AWK_START "cat /proc/"
-#define AWK_END_TIME "/stat | awk '{print $22}'"
-#define AWK_END "/maps | grep 'r-x' | awk '{print $1, $6}' | grep ' /'"
-#define AWK_END_PROCESS "/maps | grep 'r-x' | awk '{print $1, $6}' | grep "
-#define AWK_SYSTEM_UP_TIME "cat /proc/uptime  | awk '{print $1}'"
-
-// TODO don't make me cry
-void write_process_info(int pid, uint64_t starttime)
-{
-       // TODO refactor this code
-       char buf[1024];
-       struct msg_data_t *msg = NULL;
-       char *p = msg->payload;
-       char *dep_count_p = NULL;
-       int dep_count = 0;
-       struct app_list_t *app = NULL;
-       struct app_info_t *app_info = NULL;
-       // TODO: add check for unknown type
-       uint32_t binary_type = BINARY_TYPE_UNKNOWN;
-       char binary_path[PATH_MAX];
-       uint64_t start, end;
-       float process_up_time;
-       float sys_up_time;
-       uint32_t up_sec = 0;
-       uint32_t up_nsec = 0;
-       char path[256];
-       int fields;
-       FILE *f;
-
-       app_info = app_info_get_first(&app);
-       if (app_info == NULL) {
-               LOGE("No app info found\n");
-               return;
-       }
-       binary_type = get_binary_type(app_info->exe_path);
-
-       // TODO need check this result and return error
-       dereference_tizen_exe_path(app_info->exe_path, path);
-       get_build_dir(binary_path, app_info->exe_path);
-
-       msg = malloc(64 * 1024);
-       p = msg->payload;
-       fill_data_msg_head(msg, NMSG_PROCESS_INFO, 0, 0);
-
-       sprintf(buf, "%s%d%s%s", AWK_START, pid, AWK_END_PROCESS,path);
-
-       f = popen(buf, "r");
-       if (!f) {
-               LOGW("open maps: %s\n", strerror(errno));
-               free(msg);
-               return;
-       }
-
-       fields = fscanf(f, "%llx-%llx %s", &start, &end, path);
-       if (fields != 3) {
-               start = 0;
-               end = 0;
-               LOGW("cannot find start-end values. fields=%d\n", fields);
-       }
-       pclose(f);
-
-       if (starttime != 0) {
-               up_sec = starttime / (1000 * 1000);
-               up_nsec = starttime % (1000 * 1000) * 1000;
-       } else {
-               //get system uptime
-               sprintf(buf, "%s", AWK_SYSTEM_UP_TIME);
-               f = popen(buf, "r");
-               if (!f) {
-                       LOGW("open uptime: %s\n", strerror(errno));
-                       free(msg);
-                       return;
-               }
-
-               fields = fscanf(f, "%f", &sys_up_time);
-               if (fields != 1) {
-                       sys_up_time = 0;
-               }
-               pclose(f);
-
-               //get process uptime
-               sprintf(buf, "%s%d%s", AWK_START, pid, AWK_END_TIME);
-               f = popen(buf, "r");
-               if (!f) {
-                       LOGW("open stat: %s\n", strerror(errno));
-                       free(msg);
-                       return;
-               }
-
-               fields = fscanf(f, "%f", &process_up_time);
-               if (fields != 1) {
-                       process_up_time = 0;
-               } else {
-                       process_up_time = process_up_time / sysconf(_SC_CLK_TCK) ;
-                       process_up_time = sys_up_time - process_up_time;
-               }
-               pclose(f);
-
-               up_sec = (int) process_up_time;
-               up_nsec =  (int)( (process_up_time - (float) up_sec) * 1000000000 );
-
-               up_sec = msg->sec - up_sec;
-               if (msg->nsec < up_nsec){
-                       up_nsec = (1000000000 + msg->nsec) - up_nsec;
-                       up_sec--;
-               } else {
-                       up_nsec = msg->nsec - up_nsec;
-               }
-       }
-
-       LOGI(" process_up_time =  %f\nsec = %d; usec = %d\n"
-                       , process_up_time, up_sec, up_nsec);
-
-       //Pack message
-       pack_int(p, pid);
-       pack_int(p, up_sec);
-       pack_int(p, up_nsec);
-
-       pack_int(p, start);
-       pack_int(p, end);
-
-       pack_int(p, binary_type);
-
-       pack_str(p, binary_path);
-
-       dep_count_p = p;
-       pack_int(p, pid);
-
-       sprintf(buf, "%s%d%s", AWK_START, pid, AWK_END);
-
-       f = popen(buf, "r");
-       if (!f) {
-               LOGW("open maps: %s\n", strerror(errno));
-               free(msg);
-               return;
-       }
-
-       for (;;) {
-               fields = fscanf(f, "%llx-%llx %s", &start, &end, path);
-               if (fields == EOF) {
-                       break;
-               }
-               if (fields != 3) {
-                       LOGW("error string\n");
-                       break;
-               }
-
-               pack_int(p, start);
-               pack_int(p, end);
-               pack_str(p, path);
-               dep_count++;
-       }
-
-       pack_int(dep_count_p, dep_count);
-       msg->len = p - (char *)&msg->payload;
-       write_to_buf(msg);
-
-       pclose(f);
-
-       free(msg);
-}
diff --git a/daemon/process_info.h b/daemon/process_info.h
deleted file mode 100644 (file)
index 433cf46..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef _PROCESS_INFO_H_
-#define _PROCESS_INFO_H_
-
-/*
- *  DA manager
- *
- * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- *
- * Nikita Kalyazin    <n.kalyazin@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - Samsung RnD Institute Russia
- *
- */
-
-void write_process_info(int pid, uint64_t starttime);
-
-#endif /* _PROCESS_INFO_H_ */
index f554e7f290e1e455c982ff247c0f811b2bc3cc0b..ad4a03efb82da6ae5d1453108a8c5db0546781f0 100644 (file)
@@ -47,7 +47,6 @@
 #include "da_protocol.h"
 #include "da_data.h"
 #include "debug.h"
-#include "process_info.h"
 #include "buffer.h"
 
 static void* recvThread(void* data)
@@ -60,7 +59,6 @@ static void* recvThread(void* data)
 
        // initialize target variable
        manager.target[index].pid = -1;
-       manager.target[index].starttime = 0;
        manager.target[index].allocmem = 0;
 
        while(1)
@@ -133,12 +131,6 @@ static void* recvThread(void* data)
                                barloc[0] = '\0';
                                barloc++;
 
-                               manager.target[index].pid = atoi(log.data);
-                               manager.target[index].starttime = str_to_uint64(barloc);
-
-                               write_process_info(manager.target[index].pid,
-                                                  manager.target[index].starttime);
-
                                event = EVENT_PID;
                                write(manager.target[index].event_fd, &event, sizeof(uint64_t));
                        }