debug: add __smatch_member_name()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 19 Dec 2013 15:16:47 +0000 (19 18:16 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Thu, 19 Dec 2013 15:16:47 +0000 (19 18:16 +0300)
Just to make sure this feature is working correctly.  It seems like it's
basically ok actually.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
check_debug.c
check_debug.h

index 94ea88d..5af5d95 100644 (file)
@@ -233,6 +233,19 @@ free:
        free_string(name);
 }
 
+static void match_member_name(const char *fn, struct expression *expr, void *info)
+{
+       struct expression *arg;
+       char *name, *member_name;
+
+       arg = get_argument_from_call_expr(expr->args, 0);
+       name = expr_to_str(arg);
+       member_name = get_member_name(arg);
+       sm_msg("member name: '%s => %s'", name, member_name);
+       free_string(member_name);
+       free_string(name);
+}
+
 static void print_possible(struct sm_state *sm)
 {
        struct sm_state *tmp;
@@ -402,6 +415,7 @@ void check_debug(int id)
        add_function_hook("__smatch_absolute_min", &match_print_absolute_min, NULL);
        add_function_hook("__smatch_absolute_max", &match_print_absolute_max, NULL);
        add_function_hook("__smatch_sval_info", &match_sval_info, NULL);
+       add_function_hook("__smatch_member_name", &match_member_name, NULL);
        add_function_hook("__smatch_possible", &match_possible, NULL);
        add_function_hook("__smatch_cur_slist", &match_cur_slist, NULL);
        add_function_hook("__smatch_strlen", &match_strlen, NULL);
index be7a3eb..7e4e4cd 100644 (file)
@@ -18,6 +18,8 @@ static inline void __smatch_absolute_max(long long val){}
 
 static inline void __smatch_sval_info(long long val){}
 
+static inline void __smatch_member_name(long long val){}
+
 static inline void __smatch_possible(const char *unused){}
 static inline void __smatch_print_value(const char *unused){}