From e5d79f58e3ad5801e41147fa6259521e681f0c2b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 19 Dec 2013 18:18:09 +0300 Subject: [PATCH] debug: introduce __smatch_buf_size_rl() which is more verbose This is like __smatch_buf_size() but more verbose. Signed-off-by: Dan Carpenter --- check_debug.c | 18 ++++++++++++++++++ check_debug.h | 1 + 2 files changed, 19 insertions(+) diff --git a/check_debug.c b/check_debug.c index 5af5d95a..e10b8353 100644 --- a/check_debug.c +++ b/check_debug.c @@ -306,6 +306,23 @@ static void match_buf_size(const char *fn, struct expression *expr, void *info) free_string(name); } +static void match_buf_size_rl(const char *fn, struct expression *expr, void *info) +{ + struct expression *arg; + struct range_list *rl; + int elements, bytes; + char *name; + + arg = get_argument_from_call_expr(expr->args, 0); + rl = get_array_size_bytes_rl(arg); + elements = get_array_size(arg); + bytes = get_array_size_bytes(arg); + + name = expr_to_str(arg); + sm_msg("buf size: '%s' %s %d elements, %d bytes", name, show_rl(rl), elements, bytes); + free_string(name); +} + static void match_note(const char *fn, struct expression *expr, void *info) { struct expression *arg_expr; @@ -420,6 +437,7 @@ void check_debug(int id) add_function_hook("__smatch_cur_slist", &match_cur_slist, NULL); add_function_hook("__smatch_strlen", &match_strlen, NULL); add_function_hook("__smatch_buf_size", &match_buf_size, NULL); + add_function_hook("__smatch_buf_size_rl", &match_buf_size_rl, NULL); add_function_hook("__smatch_note", &match_note, NULL); add_function_hook("__smatch_dump_related", &match_dump_related, NULL); add_function_hook("__smatch_compare", &match_compare, NULL); diff --git a/check_debug.h b/check_debug.h index 7e4e4cde..2f9e3e40 100644 --- a/check_debug.h +++ b/check_debug.h @@ -25,6 +25,7 @@ static inline void __smatch_print_value(const char *unused){} static inline void __smatch_strlen(const void *buf){} static inline void __smatch_buf_size(const void *buf){} +static inline void __smatch_buf_size_rl(const void *buf){} static inline void __smatch_note(const char *note){} -- 2.11.4.GIT