Print this page
11506 smatch resync
@@ -17,10 +17,15 @@
#include "smatch.h"
#include "smatch_slist.h"
#include "smatch_extra.h"
+void show_sname_alloc(void);
+void show_data_range_alloc(void);
+void show_ptrlist_alloc(void);
+void show_sm_state_alloc(void);
+
int local_debug;
static int my_id;
char *trace_variable;
static void match_all_values(const char *fn, struct expression *expr, void *info)
@@ -196,11 +201,11 @@
}
static void match_user_rl(const char *fn, struct expression *expr, void *info)
{
struct expression *arg;
- struct range_list *rl;
+ struct range_list *rl = NULL;
char *name;
arg = get_argument_from_call_expr(expr->args, 0);
name = expr_to_str(arg);
@@ -382,19 +387,20 @@
struct expression *arg, *comp;
struct range_list *rl;
int elements, bytes;
char *name;
char buf[256] = "";
+ int limit_type;
int n;
sval_t sval;
arg = get_argument_from_call_expr(expr->args, 0);
elements = get_array_size(arg);
bytes = get_array_size_bytes_max(arg);
rl = get_array_size_bytes_rl(arg);
- comp = get_size_variable(arg);
+ comp = get_size_variable(arg, &limit_type);
name = expr_to_str(arg);
n = snprintf(buf, sizeof(buf), "buf size: '%s' %d elements, %d bytes", name, elements, bytes);
free_string(name);
@@ -401,11 +407,11 @@
if (!rl_to_sval(rl, &sval))
n += snprintf(buf + n, sizeof(buf) - n, " (rl = %s)", show_rl(rl));
if (comp) {
name = expr_to_str(comp);
- snprintf(buf + n, sizeof(buf) - n, "[size_var=%s]", name);
+ snprintf(buf + n, sizeof(buf) - n, "[size_var=%s %s]", limit_type_str(limit_type), name);
free_string(name);
}
sm_msg("%s", buf);
}
@@ -502,20 +508,10 @@
static void match_local_debug_off(const char *fn, struct expression *expr, void *info)
{
local_debug = 0;
}
-static void match_debug_implied_on(const char *fn, struct expression *expr, void *info)
-{
- option_debug_implied = 1;
-}
-
-static void match_debug_implied_off(const char *fn, struct expression *expr, void *info)
-{
- option_debug_implied = 0;
-}
-
static void match_about(const char *fn, struct expression *expr, void *info)
{
struct expression *arg;
struct sm_state *sm;
char *name;
@@ -642,15 +638,16 @@
static void match_mtag(const char *fn, struct expression *expr, void *info)
{
struct expression *arg;
char *name;
mtag_t tag = 0;
+ int offset = 0;
arg = get_argument_from_call_expr(expr->args, 0);
name = expr_to_str(arg);
- get_mtag(arg, &tag);
- sm_msg("mtag: '%s' => tag: %lld", name, tag);
+ expr_to_mtag_offset(arg, &tag, &offset);
+ sm_msg("mtag: '%s' => tag: %llu %d", name, tag, offset);
free_string(name);
}
static void match_mtag_data_offset(const char *fn, struct expression *expr, void *info)
{
@@ -664,10 +661,26 @@
expr_to_mtag_offset(arg, &tag, &offset);
sm_msg("mtag: '%s' => tag: %lld, offset: %d", name, tag, offset);
free_string(name);
}
+static void match_container(const char *fn, struct expression *expr, void *info)
+{
+ struct expression *container, *x;
+ char *cont, *name, *str;
+
+ container = get_argument_from_call_expr(expr->args, 0);
+ x = get_argument_from_call_expr(expr->args, 1);
+
+ str = get_container_name(container, x);
+ cont = expr_to_str(container);
+ name = expr_to_str(x);
+ sm_msg("container: '%s' vs '%s' --> '%s'", cont, name, str);
+ free_string(cont);
+ free_string(name);
+}
+
static void match_state_count(const char *fn, struct expression *expr, void *info)
{
sm_msg("state_count = %d\n", sm_state_counter);
}
@@ -752,12 +765,10 @@
add_function_hook("__smatch_debug_on", &match_debug_on, NULL);
add_function_hook("__smatch_debug_check", &match_debug_check, NULL);
add_function_hook("__smatch_debug_off", &match_debug_off, NULL);
add_function_hook("__smatch_local_debug_on", &match_local_debug_on, NULL);
add_function_hook("__smatch_local_debug_off", &match_local_debug_off, NULL);
- 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);
add_implied_return_hook("__smatch_type_rl_helper", &match_type_rl_return, NULL);
add_function_hook("__smatch_merge_tree", &match_print_merge_tree, NULL);
add_function_hook("__smatch_stree_id", &match_print_stree_id, NULL);
@@ -764,9 +775,10 @@
add_function_hook("__smatch_mtag", &match_mtag, NULL);
add_function_hook("__smatch_mtag_data", &match_mtag_data_offset, NULL);
add_function_hook("__smatch_state_count", &match_state_count, NULL);
add_function_hook("__smatch_mem", &match_mem, NULL);
add_function_hook("__smatch_exit", &match_exit, NULL);
+ add_function_hook("__smatch_container", &match_container, NULL);
add_hook(free_old_stree, AFTER_FUNC_HOOK);
add_hook(trace_var, STMT_HOOK_AFTER);
}