[REFACTOR] Preload flags 77/39077/5
authorAlexander Aksenov <a.aksenov@samsung.com>
Tue, 17 Mar 2015 13:00:42 +0000 (16:00 +0300)
committerVitaliy Cherepanov <v.cherepanov@samsung.com>
Wed, 27 May 2015 12:58:05 +0000 (15:58 +0300)
Change-Id: Ie3b9ef3a10d069e2f7ae2acae5ee579e7cede738
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
parser/msg_parser.c
preload/preload_control.c
preload/preload_module.c
preload/preload_probe.h

index 4c327ba..f9b51f5 100644 (file)
@@ -340,7 +340,7 @@ void put_retprobe(struct probe_info *pi)
 int get_preload_probe(struct msg_buf *mb, struct probe_info *pi)
 {
        u64 handler;
-       u8 type;
+       u8 flags;
 
        print_parse_debug("funct handler:");
        if (get_u64(mb, &handler)) {
@@ -348,8 +348,8 @@ int get_preload_probe(struct msg_buf *mb, struct probe_info *pi)
                return -EINVAL;
        }
 
-       print_parse_debug("collect events type:");
-       if (get_u8(mb, &type)) {
+       print_parse_debug("collect events flag:");
+       if (get_u8(mb, &flags)) {
                print_err("failed to read collect events type\n");
                return -EINVAL;
        }
@@ -357,7 +357,7 @@ int get_preload_probe(struct msg_buf *mb, struct probe_info *pi)
        pi->probe_type = SWAP_PRELOAD_PROBE;
        pi->size = sizeof(pi->pl_i) + sizeof(pi->probe_type) + sizeof(pi->size);
        pi->pl_i.handler = handler;
-       pi->pl_i.type = type;
+       pi->pl_i.flags = flags;
 
        return 0;
 }
index cf29979..93bdfd3 100644 (file)
@@ -216,7 +216,7 @@ enum preload_call_type preload_control_call_type(struct us_ip *ip, void *caller)
        if (__is_instrumented(caller))
                return INTERNAL_CALL;
 
-       if (ip->info->pl_i.type & SWAP_PRELOAD_ALWAYS)
+       if (ip->info->pl_i.flags & SWAP_PRELOAD_ALWAYS_RUN)
                return EXTERNAL_CALL;
 
        return NOT_INSTRUMENTED;
index ba73bd4..b26f116 100644 (file)
@@ -284,7 +284,7 @@ static inline struct vm_area_struct *__get_vma_by_addr(struct task_struct *task,
 
 static inline bool __is_probe_non_block(struct us_ip *ip)
 {
-       if (!(ip->info->pl_i.type & (0x1 << 1)))
+       if (ip->info->pl_i.flags & SWAP_PRELOAD_NON_BLOCK_PROBE)
                return true;
 
        return false;
@@ -428,7 +428,7 @@ static int preload_us_entry(struct uretprobe_instance *ri, struct pt_regs *regs)
 
                        /* jump only if caller is instumented and it is not a system lib -
                         * this leads to some errors */
-                       if (__not_system_caller(current, cvma) && ct &&
+                       if (__not_system_caller(current, cvma) && ct != NOT_INSTRUMENTED &&
                            !__is_handlers_call(cvma)) {
                                if (preload_threads_set_data(current,
                                                             caddr, ct,
index 7b7a32a..5d1f71c 100644 (file)
 #ifndef __PRELOAD_PROBE_H__
 #define __PRELOAD_PROBE_H__
 
-/* Probe type, specifies when probe should be ran. */
-enum preload_probe_type_t {
-       SWAP_PRELOAD_INTERNAL_CALL = 0,     /* Run probe only when it is called from
-                                              target binaries. */
-       SWAP_PRELOAD_ALWAYS = 1,            /* Run probe always. */
-       SWAP_PRELOAD_DISABLE_HANDLING = 2   /* Disable handlers execution. */
+/* Probe flags description:
+ *
+ *    0 - handler is ran only when probe has fired from a target binary;
+ *    1 - handler is always ran;
+ *
+ *   00 - probe is disabling internal probes;
+ *   10 - probe is non blocking one;
+ */
+
+enum {
+       SWAP_PRELOAD_ALWAYS_RUN =       (1 << 0),
+       SWAP_PRELOAD_NON_BLOCK_PROBE =  (1 << 1)
 };
 
 /* Preload probe info. */
 struct preload_info {
        unsigned long handler;              /* Handler offset in probe library. */
-       enum preload_probe_type_t type;     /* Preload probe type. */
+       unsigned char flags;                /* Preload probe flags. */
 };
 
 /* Get caller probe info */