Revert "[IMPROVE] Implement different kind of probes" 73/30273/2
authorDmitry Kovalenko <d.kovalenko@samsung.com>
Thu, 13 Nov 2014 12:26:31 +0000 (04:26 -0800)
committerDmitry Kovalenko <d.kovalenko@samsung.com>
Thu, 13 Nov 2014 12:29:18 +0000 (04:29 -0800)
Still too early

This reverts commit 7a76b43942410512a7f0d767121ae7433ca9bccd.

Change-Id: Ia9cbf8e5cce27e1359856f54c91633d68742919c

daemon/da_inst.c
daemon/da_protocol.h
daemon/da_protocol_inst.c

index 4c16122..78446cd 100644 (file)
@@ -268,27 +268,14 @@ static struct data_list_t *data_list_find_data(struct data_list_t *whered, struc
        return NULL;
 }
 
-// Check whether functions are equal. If so, returns first argument, otherwise - NULL
-static struct probe_list_t *probes_equal(struct probe_list_t *first, struct probe_list_t *second)
-{
-       if (first->size != second->size)
-               return NULL;
-
-       if (first->func->func_addr != second->func->func_addr)
-               return NULL;
-
-       if (first->func->probe_type != second->func->probe_type)
-               return NULL;
-
-       return first;
-}
-
 static struct probe_list_t *find_probe(struct data_list_t *where, struct probe_list_t *probe)
 {
        struct probe_list_t *p ;
        for (p = where->list; p != NULL; p = p->next)
-               if (probes_equal(p, probe))
-                       break;
+               if (p->size == probe->size)
+                       if (p->func->func_addr == probe->func->func_addr)
+                               if (strcmp(p->func->args, probe->func->args) == 0)
+                                       break;
 
        return p;
 }
index 22a2e81..24aeefd 100644 (file)
@@ -148,12 +148,6 @@ enum feature_code{
 
 };
 
-enum probe_type {
-       SWAP_RETPROBE   = 0, //Common retprobe
-       SWAP_FBI_PROBE  = 1, //Function body instrumentation probe
-       SWAP_LD_PROBE   = 2  //Preloaded API probe
-};
-
 #define IS_OPT_SET_IN(OPT, reg) (reg & (OPT))
 #define IS_OPT_SET(OPT) IS_OPT_SET_IN((OPT), prof_session.conf.use_features0)
 
@@ -252,11 +246,11 @@ struct us_func_inst_plane_t {
        //name       | type   | len       | info
        //------------------------------------------
        //func_addr  | uint64 | 8         |
-       //probe_type | char   | 1         |
+       //args       | string | len(args) |end with '\0'
+       //ret_type   | char   | 1         |
        uint64_t func_addr;
-       char probe_type;
-       char probe_info[0];
-} __attribute__ ((packed));
+       char args[0];
+};
 
 struct us_lib_inst_t {
        char *bin_path;
index 2a55702..26ffb35 100644 (file)
@@ -63,56 +63,42 @@ static int parse_us_inst_func(struct msg_buf_t *msg, struct probe_list_t **dest)
        //name       | type   | len       | info
        //------------------------------------------
        //func_addr  | uint64 | 8         |
-       //probe_type | char   | 1         |
+       //args       | string | len(args) |end with '\0'
+       //ret_type   | char   | 1         |
 
        uint32_t size = 0;
-       struct us_func_inst_plane_t *func = NULL;
-       char type;
-       uint64_t addr;
+       struct us_func_inst_plane_t *func;
+       int par_count = 0;
+       char *ret_type = NULL;
 
-       size = sizeof(*func);
-
-       if (!parse_int64(msg, &addr)) {
+       par_count = strlen(msg->cur_pos + sizeof(func->func_addr));
+       size = sizeof(*func) + par_count + 1 +
+              sizeof(char) /* sizeof(char) for ret_type */;
+       func = malloc(size);
+       if (!parse_int64(msg, &(func->func_addr))) {
                LOGE("func addr parsing error\n");
-               return 0;
-       }
-
-       if (!parse_int8(msg, &type)) {
-               LOGE("func type parsing error\n");
-               return 0;
+               goto err_ret;
        }
 
-       switch (type) {
-       case SWAP_RETPROBE:
-               size += strlen(msg->cur_pos) + 1 + sizeof(char);
-               break;
-       case SWAP_FBI_PROBE:
-               size += sizeof(uint32_t) + /* register number */
-                       sizeof(uint64_t) + /* register offset */
-                       sizeof(uint32_t) + /* data size */
-                       sizeof(uint64_t) + /* var id */
-                       sizeof(uint32_t);  /* pointer order */
-               break;
-       case SWAP_LD_PROBE:
-               size += sizeof(uint64_t); /* ld preload handler addr */
-               break;
-       default:
-               LOGE("wrong probe type <%u>\n", type);
+       if (!parse_string_no_alloc(msg, func->args) ||
+           !check_us_inst_func_args(func->args))
+       {
+               LOGE("args format parsing error\n");
                goto err_ret;
        }
 
-       func = malloc(size);
-       if (func == NULL) {
-               LOGE("no memory\n");
-               return 0;
+       //func->args type is char[0]
+       //and we need put ret_type after func->args
+       ret_type = func->args + par_count + 1;
+       if (!parse_int8(msg, (uint8_t *)ret_type) ||
+           !check_us_inst_func_ret_type(*ret_type))
+       {
+               LOGE("return type parsing error\n");
+               goto err_ret;
+       } else {
+               parse_deb("ret type = <%c>\n", *ret_type);
        }
 
-       func->probe_type = type;
-       func->func_addr = addr;
-
-       memcpy(&func->probe_info, msg->cur_pos, size - sizeof(*func));
-       msg->cur_pos += size - sizeof(*func);
-
        *dest = new_probe();
        if (*dest == NULL) {
                LOGE("alloc new_probe error\n");
@@ -121,7 +107,6 @@ static int parse_us_inst_func(struct msg_buf_t *msg, struct probe_list_t **dest)
        (*dest)->size = size;
        (*dest)->func = func;
        return 1;
-
 err_ret:
        free(func);
        return 0;