Merge branch 'swap_protocol' of 106.109.8.71:/srv/git/sdk/dynamic-analysis-manager...
authorVitaliy Cherepanov <v.cherepanov@samsung.com>
Wed, 3 Jul 2013 14:15:12 +0000 (18:15 +0400)
committerVitaliy Cherepanov <v.cherepanov@samsung.com>
Wed, 3 Jul 2013 14:15:12 +0000 (18:15 +0400)
Conflicts:
daemon/da_protocol.c
daemon/transfer_thread.c

1  2 
daemon/buffer.c
daemon/da_data.c
daemon/da_protocol.c
daemon/da_protocol.h
daemon/daemon.c
daemon/daemon.h
daemon/main.c
daemon/sys_stat.c
daemon/threads.c
daemon/transfer_thread.c
daemon/utils.c

diff --cc daemon/buffer.c
Simple merge
Simple merge
  #include "da_protocol.h"
  #include "daemon.h"
  #include "sys_stat.h"
+ #include "transfer_thread.h"
  #include "elf.h"
 +#include "ioctl_commands.h"
 +#include "debug.h"
  
 +#include <sys/stat.h>
 +#include <fcntl.h>
 +#include <unistd.h>
  
  #define SYSTEM_INFO_DEBUG
  #define parse_deb_on
@@@ -716,40 -635,10 +640,41 @@@ static char *parse_msg_binary_info(cha
        return p;
  }
  
 +
 +//This function concat 2 user space lists
 +// this function clean "from" pointer
 +static void concat_add_user_space_inst(struct user_space_inst_t *from,
 +                                                              struct user_space_inst_t *to)
 +{
 +      struct app_inst_t *new_app_inst_list = NULL;
 +      uint32_t size;
 +      char *p;
 +
 +      if (from->app_num == 0)
 +              return;
 +
 +      new_app_inst_list = malloc((from->app_num + to->app_num) * sizeof(*new_app_inst_list));
 +      p = new_app_inst_list;
 +
 +      size = from->app_num * sizeof(*new_app_inst_list);
 +      memcpy(p, from->app_inst_list, size);
 +      p +=size;
 +
 +      size = to->app_num * sizeof(*new_app_inst_list);
 +      memcpy(p, to->app_inst_list, size);
 +      p +=size;
 +
 +      free(to->app_inst_list);
 +      to->app_inst_list = new_app_inst_list;
 +
 +      to->app_num += from->app_num;
 +      return;
 +}
 +
  void reset_msg(struct msg_t *msg)
  {
-       free(msg->payload);
+       if (msg->len)
+               free(msg->payload);
  }
  
  static void reset_app_info(struct app_info_t *app_info)
@@@ -932,11 -884,10 +920,11 @@@ static int sendACKToHost(enum HostMessa
  
  int host_message_handler(struct msg_t *msg)
  {
-       char *answer = 0;
-       uint32_t answer_len = 0;
        struct app_info_t app_info;
+       struct target_info_t target_info;
        struct msg_t *msg_reply;
 +      struct user_space_inst_t user_space_inst;
+       struct conf_t conf;
  
        LOGI("MY HANDLE %s (%X)\n", msg_ID_str(msg->id), msg->id);
  
                sendACKToHost(msg->id, ERR_NO, 0, 0);
                break;
        case NMSG_START:
-               if (!parse_prof_session(msg->payload, &prof_session)) {
+               if (parse_prof_session(msg->payload, &prof_session) != 0) {
                        LOGE("prof session parsing error\n");
                        sendACKToHost(msg->id, ERR_WRONG_MESSAGE_FORMAT, 0, 0);
-                       return 1;
+                       return -1;
                }
  
 +              // TODO: launch translator thread
                if (start_transfer() != 0) {
                        LOGE("Cannot start transfer\n");
                        return -1;
                }
  
-               // TODO: kill app
- /* #ifdef RUN_APP_LOADER */
- /*            kill_app(manager.appPath); */
- /* #else */
- /*            kill_app(execPath); */
- /* #endif */
 +
                // TODO: apply_prof_session()
                if (0) {
                        sendACKCodeToHost(MSG_NOTOK, ERR_CANNOT_START_PROFILING);
                        return -1;
                }
  
-               // TODO: exec app
                // TODO: start app launch timer
  
 +              //write to device
 +              //ioctl_send_msg(msg);
 +
                // success
                sendACKToHost(msg->id, ERR_NO, 0, 0);
                break;
        case NMSG_STOP:
                terminate_all();
+               stop_profiling();
                reset_prof_session(&prof_session);
                stop_transfer();
 +              //write to device
 +              ioctl_send_msg(msg);
 +              //send ack to host
                sendACKToHost(msg->id, ERR_NO, 0, 0);
                break;
        case NMSG_CONFIG:
-               if (!parse_msg_config(msg->payload, &prof_session.conf)) {
+               if (!parse_msg_config(msg->payload, &conf)) {
                        LOGE("config parsing error\n");
                        sendACKToHost(msg->id, ERR_WRONG_MESSAGE_FORMAT, 0, 0);
-                       return 1;
+                       return -1;
+               }
+               if (!reconfigure(conf)) {
+                       LOGE("Cannot change configuration\n");
+                       return -1;
                }
 +              //write to device
 +              ioctl_send_msg(msg);
 +              //send ack to host
                sendACKToHost(msg->id,ERR_NO,0,0);
                break;
        case NMSG_BINARY_INFO:
                break;
        case NMSG_SWAP_INST_ADD:
                if (!parse_user_space_inst(msg->payload,
 -                                         &prof_session.user_space_inst)) {
 +                                         &user_space_inst)) {
                        LOGE("user space inst parsing error\n");
                        sendACKToHost(msg->id, ERR_WRONG_MESSAGE_FORMAT, 0, 0);
-                       return 1;
+                       return -1;
                }
                // TODO: apply_prof_session()
 +              // warning concat_add_user_space_inst free user_space_inst
 +              // so, data will not be availible
 +              concat_add_user_space_inst(&user_space_inst, &prof_session.user_space_inst);
 +              //write to device
 +              ioctl_send_msg(msg);
 +              //send ack to host
                sendACKToHost(msg->id, ERR_NO, 0, 0);
 +              // TODO release user_space_inst
                break;
        case NMSG_SWAP_INST_REMOVE:
                if (!parse_user_space_inst(msg->payload,
        return 0;
  }
  
- // use sequence:
- /* receive_msg_header */
- /* receive_msg_payload */
- /* handle_msg */
- /* dispose_payload */
  // testing
 -#include <sys/stat.h>
 -#include <fcntl.h>
 -#include <unistd.h>
 +
  static void print_app_info( struct app_info_t *app_info)
  {
        LOGI("application info=\n");
Simple merge
diff --cc daemon/daemon.c
Simple merge
diff --cc daemon/daemon.h
Simple merge
diff --cc daemon/main.c
Simple merge
Simple merge
  
  #include "da_protocol.h"
  #include "da_data.h"
 +#include "debug.h"
  
  //#define DEBUG_GSI
- #define TIMER_INTERVAL_SEC                    1
- #define TIMER_INTERVAL_USEC                   0
  
  static void* recvThread(void* data)
  {
@@@ -3,10 -3,9 +3,11 @@@
  #include <unistd.h>
  #include <errno.h>
  #include <string.h>
 +
  #include "daemon.h"
  #include "buffer.h"
 +#include "debug.h"
+ #include "transfer_thread.h"
  
  #define BUF_SIZE 4096
  
diff --cc daemon/utils.c
Simple merge