From 74110aa404df790c39b44685db1eb9ca33fd97da Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 8 Nov 2012 11:52:04 +0300 Subject: [PATCH] sval: add __smatch_sval_info() to check_debug.c I would be better if this handled range_lists as well, but it's good enough for now. Signed-off-by: Dan Carpenter --- check_debug.c | 20 ++++++++++++++++++++ check_debug.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/check_debug.c b/check_debug.c index 2248eb7c..f4efe76b 100644 --- a/check_debug.c +++ b/check_debug.c @@ -126,6 +126,25 @@ static void match_print_absolute_max(const char *fn, struct expression *expr, vo free_string(name); } +static void match_sval_info(const char *fn, struct expression *expr, void *info) +{ + struct expression *arg; + sval_t sval; + char *name; + + arg = get_argument_from_call_expr(expr->args, 0); + name = get_variable_from_expr_complex(arg, NULL); + + if (!get_implied_value_sval(arg, &sval)) { + sm_msg("no sval for '%s'", name); + goto free; + } + + sm_msg("implied: %s %c%d ->value = %llx", name, sval_unsigned(sval) ? 'u' : 's', sval_bits(sval), sval.value); +free: + free_string(name); +} + static void print_possible(struct sm_state *sm) { struct sm_state *tmp; @@ -231,6 +250,7 @@ void check_debug(int id) add_function_hook("__smatch_implied_max", &match_print_implied_max, NULL); 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_possible", &match_possible, NULL); add_function_hook("__smatch_cur_slist", &match_cur_slist, NULL); add_function_hook("__smatch_buf_size", &match_buf_size, NULL); diff --git a/check_debug.h b/check_debug.h index c9fced43..66c4dc5a 100644 --- a/check_debug.h +++ b/check_debug.h @@ -11,6 +11,8 @@ static inline void __smatch_implied_max(long long val){} static inline void __smatch_absolute_min(long long val){} static inline void __smatch_absolute_max(long long val){} +static inline void __smatch_sval_info(long long val){} + static inline void __smatch_possible(const char *unused){} static inline void __smatch_print_value(const char *unused){} -- 2.11.4.GIT