[IMPROVE] add parse message debugs
authorVitaliy Cherepanov <v.cherepanov@samsung.com>
Thu, 4 Jul 2013 13:27:45 +0000 (17:27 +0400)
committerVitaliy Cherepanov <v.cherepanov@samsung.com>
Thu, 4 Jul 2013 13:27:45 +0000 (17:27 +0400)
 - use: enable define (PARSE_DEBUG) in parser_defs.h
 - default state is disabled

driver_new/device_driver.c
parser/msg_buf.c
parser/msg_parser.c
parser/parser_defs.h
parser/swap_msg_parser.c

index 8690ef5..1d619ec 100644 (file)
@@ -275,6 +275,7 @@ static long swap_device_ioctl(struct file *filp, unsigned int cmd,
     switch(cmd) {
         case SWAP_DRIVER_BUFFER_INITIALIZE:
         {
+            print_debug("SWAP_DRIVER_BUFFER_INITIALIZE\n");
             struct buffer_initialize initialize_struct;
 
             result = copy_from_user(&initialize_struct, (void*)arg,
@@ -295,6 +296,7 @@ static long swap_device_ioctl(struct file *filp, unsigned int cmd,
         }
         case SWAP_DRIVER_BUFFER_UNINITIALIZE:
         {
+            print_debug("SWAP_DRIVER_BUFFER_UNINITIALIZE\n");
             result = driver_to_buffer_uninitialize();
             if (result < 0)
                 print_err("Buffer uninitialization failed %d\n"< result);
@@ -303,6 +305,7 @@ static long swap_device_ioctl(struct file *filp, unsigned int cmd,
         }
         case SWAP_DRIVER_NEXT_BUFFER_TO_READ:
         {
+            print_debug("SWAP_DRIVER_NEXT_BUFFER_TO_READ\n");
             /* Use this carefully */
             result = driver_to_buffer_next_buffer_to_read();
             if (result == E_SD_NO_DATA_TO_READ) {
@@ -313,11 +316,13 @@ static long swap_device_ioctl(struct file *filp, unsigned int cmd,
         }
         case SWAP_DRIVER_FLUSH_BUFFER:
         {
+            print_debug("SWAP_DRIVER_FLUSH_BUFFER\n");
             result = driver_to_buffer_flush();
             break;
         }
         default:
         {
+            print_debug("SWAP_DRIVER_BUFFER MESSAGE\n");
             if (msg_handler) {
                 result = msg_handler((void __user *)arg);
             } else {
index dd5fc62..1d3232e 100644 (file)
@@ -1,6 +1,7 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include "msg_buf.h"
+#include "parser_defs.h"
 
 int init_mb(struct msg_buf *mb, size_t size)
 {
@@ -55,6 +56,8 @@ int get_u32(struct msg_buf *mb, u32 *val)
        *val = *((u32 *)mb->ptr);
        mb->ptr += sizeof(*val);
 
+       print_parse_debug("u32->%d;%08X\n", *val, *val);
+
        return 0;
 }
 
@@ -65,6 +68,7 @@ int get_u64(struct msg_buf *mb, u64 *val)
 
        *val = *((u64 *)mb->ptr);
        mb->ptr += sizeof(*val);
+       print_parse_debug("u64->%d; 0x%016lX\n", *val, *val);
 
        return 0;
 }
@@ -86,6 +90,7 @@ int get_string(struct msg_buf *mb, char **str)
        memcpy(*str, mb->ptr, len);
        mb->ptr += len;
 
+       print_parse_debug("str->'%s'\n", *str);
        return 0;
 }
 
index 077d4b6..0b16e9c 100644 (file)
@@ -37,18 +37,23 @@ struct app_info_data *create_app_info(struct msg_buf *mb)
        u32 app_type;
        char *ta_id, *exec_path;
 
+       print_parse_debug("app_info:\n");
+
+       print_parse_debug("type:");
        ret = get_u32(mb, &app_type);
        if (ret) {
                print_err("failed to read target application type\n");
                return NULL;
        }
 
+       print_parse_debug("id:");
        ret = get_string(mb, &ta_id);
        if (ret) {
                print_err("failed to read target application ID\n");
                return NULL;
        }
 
+       print_parse_debug("exec path:");
        ret = get_string(mb, &exec_path);
        if (ret) {
                print_err("failed to read executable path\n");
@@ -134,16 +139,21 @@ struct conf_data *create_conf_data(struct msg_buf *mb)
        u64 uf;
        u32 stp, dmp;
 
+       print_parse_debug("conf_data:\n");
+
+       print_parse_debug("features:");
        if (get_u64(mb, &uf)) {
                print_err("failed to read use_features\n");
                return NULL;
        }
 
+       print_parse_debug("sys trace period:");
        if (get_u32(mb, &stp)) {
                print_err("failed to read sys trace period\n");
                return NULL;
        }
 
+       print_parse_debug("data msg period:");
        if (get_u32(mb, &dmp)) {
                print_err("failed to read data message period\n");
                return NULL;
@@ -181,11 +191,13 @@ struct func_inst_data *create_func_inst_data(struct msg_buf *mb)
        u64 addr;
        char *args;
 
+       print_parse_debug("func addr:");
        if (get_u64(mb, &addr)) {
                print_err("failed to read data function address\n");
                return NULL;
        }
 
+       print_parse_debug("funct args:");
        if (get_string(mb, &args)) {
                print_err("failed to read data function arguments\n");
                return NULL;
@@ -225,11 +237,13 @@ struct lib_inst_data *create_lib_inst_data(struct msg_buf *mb)
        char *path;
        u32 cnt, j, i = 0;
 
+       print_parse_debug("bin path:");
        if (get_string(mb, &path)) {
                print_err("failed to read path of binary\n");
                return NULL;
        }
 
+       print_parse_debug("func count:");
        if (get_u32(mb, &cnt)) {
                print_err("failed to read count of functions\n");
                return NULL;
@@ -255,6 +269,7 @@ struct lib_inst_data *create_lib_inst_data(struct msg_buf *mb)
        }
 
        for (i = 0; i < cnt; ++i) {
+               print_parse_debug("func #%d:\n", i + 1);
                fi = create_func_inst_data(mb);
                if (fi == NULL)
                        goto free_func;
@@ -314,6 +329,7 @@ struct app_inst_data *create_app_inst_data(struct msg_buf *mb)
        if (app_info == NULL)
                return NULL;
 
+       print_parse_debug("func count:");
        if (get_u32(mb, &cnt_func)) {
                print_err("failed to read count of functions\n");
                goto free_app_info;
@@ -338,6 +354,7 @@ struct app_inst_data *create_app_inst_data(struct msg_buf *mb)
        }
 
        for (i_func = 0; i_func < cnt_func; ++i_func) {
+               print_parse_debug("func #%d:\n", i_func + 1);
                func = create_func_inst_data(mb);
                if (func == NULL)
                        goto free_func;
@@ -345,6 +362,7 @@ struct app_inst_data *create_app_inst_data(struct msg_buf *mb)
                app_inst->func[i_func] = func;
        }
 
+       print_parse_debug("lib count:");
        if (get_u32(mb, &cnt_lib)) {
                print_err("failed to read count of libraries\n");
                goto free_func;
@@ -363,6 +381,7 @@ struct app_inst_data *create_app_inst_data(struct msg_buf *mb)
        }
 
        for (i_lib = 0; i_lib < cnt_lib; ++i_lib) {
+               print_parse_debug("lib #%d:\n", i_lib + 1);
                lib = create_lib_inst_data(mb);
                if (lib == NULL)
                        goto free_lib;
@@ -425,6 +444,9 @@ struct us_inst_data *create_us_inst_data(struct msg_buf *mb)
        struct app_inst_data *ai;
        u32 cnt, j, i = 0;
 
+       print_parse_debug("us_inst_data:\n");
+
+       print_parse_debug("app count:");
        if (get_u32(mb, &cnt)) {
                print_err("failed to read count of applications\n");
                return NULL;
@@ -449,6 +471,7 @@ struct us_inst_data *create_us_inst_data(struct msg_buf *mb)
        }
 
        for (i = 0; i < cnt; ++i) {
+               print_parse_debug("app #%d:\n",i+1);
                ai = create_app_inst_data(mb);
                if (ai == NULL)
                        goto free_app_inst;
index 0f101ef..c11bf0b 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <linux/kernel.h>
 
+/* #define PARSE_DEBUG */
+
 #define print_debug(msg, args...) \
     printk(KERN_DEBUG "SWAP_PARSER DEBUG : " msg, ##args)
 #define print_msg(msg, args...)   \
 #define print_crit(msg, args...)  \
     printk(KERN_CRIT "SWAP_PARSER CRITICAL : " msg, ##args)
 
+/* debug parse */
+#ifdef PARSE_DEBUG
+#define print_parse_debug(msg, args...) \
+    printk(KERN_DEBUG "SWAP_PARSER DEBUG : " msg, ##args)
+#else
+#define print_parse_debug(msg, args...) \
+   do {} while (0)
+#endif /* PARSE_DEBUG */
+
 #endif /* __SWAP_DRIVER_DEVICE_DEFS_H__ */
index 53a730d..11bda3e 100644 (file)
@@ -51,21 +51,27 @@ static int msg_handler(void __user *msg)
        msg_id = bmf.msg_id;
        switch (msg_id) {
        case MSG_KEEP_ALIVE:
+               print_parse_debug("MSG_KEEP_ALIVE\n");
                ret = msg_keep_alive(&mb);
                break;
        case MSG_START:
+               print_parse_debug("MSG_START\n");
                ret = msg_start(&mb);
                break;
        case MSG_STOP:
+               print_parse_debug("MSG_STOP\n");
                ret = msg_stop(&mb);
                break;
        case MSG_CONFIG:
+               print_parse_debug("MSG_CONFIG\n");
                ret = msg_config(&mb);
                break;
        case MSG_SWAP_INST_ADD:
+               print_parse_debug("MSG_SWAP_INST_ADD\n");
                ret = msg_swap_inst_add(&mb);
                break;
        case MSG_SWAP_INST_REMOVE:
+               print_parse_debug("MSG_SWAP_INST_REMOVE\n");
                ret = msg_swap_inst_remove(&mb);
                break;
        default: