From b5f5bc812e408f8cabfce1cb25e624d5a0284dd6 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 6 Nov 2014 15:28:35 +0300 Subject: [PATCH] debug: add __smatch_type() which prints the type of the argument It displays the type of the argument. You can't pass it a struct, you have to pass it a struct pointer instead. Signed-off-by: Dan Carpenter --- check_debug.c | 14 ++++++++++++++ check_debug.h | 1 + 2 files changed, 15 insertions(+) diff --git a/check_debug.c b/check_debug.c index 274a930c..91b0c2f2 100644 --- a/check_debug.c +++ b/check_debug.c @@ -475,6 +475,19 @@ static void match_intersection(const char *fn, struct expression *expr, void *in sm_msg("'%s' intersect '%s' is '%s'", show_rl(one_rl), show_rl(two_rl), show_rl(res)); } +static void match_type(const char *fn, struct expression *expr, void *info) +{ + struct expression *one; + struct symbol *type; + char *name; + + one = get_argument_from_call_expr(expr->args, 0); + type = get_type(one); + name = expr_to_str(one); + sm_msg("type of '%s' is: '%s'", name, type_to_str(type)); + free_string(name); +} + void check_debug(int id) { my_id = id; @@ -508,4 +521,5 @@ void check_debug(int id) add_function_hook("__smatch_debug_implied_on", &match_debug_implied_on, NULL); add_function_hook("__smatch_debug_implied_off", &match_debug_implied_off, NULL); add_function_hook("__smatch_intersection", &match_intersection, NULL); + add_function_hook("__smatch_type", &match_type, NULL); } diff --git a/check_debug.h b/check_debug.h index e130b999..ef21a5a5 100644 --- a/check_debug.h +++ b/check_debug.h @@ -46,5 +46,6 @@ static inline void __smatch_debug_implied_on(void){} static inline void __smatch_debug_implied_off(void){} static inline void __smatch_intersection(long long one, long long two){} +static inline void __smatch_type(long long one){} #endif -- 2.11.4.GIT