smatch_implied: only print the nr_children message once.
[smatch.git] / check_debug.c
bloba564cb0b57ba5fb58d7d7bbee90ebfd198376b4d
1 /*
2 * sparse/check_debug.c
4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include "smatch.h"
11 #include "smatch_slist.h" // blast this was supposed to be internal only stuff
13 static int my_id;
15 static void match_all_values(const char *fn, struct expression *expr, void *info)
17 struct state_list *slist;
19 slist = get_all_states(SMATCH_EXTRA);
20 __print_slist(slist);
21 free_slist(&slist);
24 static void match_print_value(const char *fn, struct expression *expr, void *info)
26 struct state_list *slist;
27 struct sm_state *tmp;
28 struct expression *arg_expr;
30 arg_expr = get_argument_from_call_expr(expr->args, 0);
31 if (arg_expr->type != EXPR_STRING) {
32 smatch_msg("error: the argument to %s is supposed to be a string literal", fn);
33 return;
36 slist = get_all_states(SMATCH_EXTRA);
37 FOR_EACH_PTR(slist, tmp) {
38 if (!strcmp(tmp->name, arg_expr->string->data))
39 smatch_msg("%s = %s", tmp->name, tmp->state->name);
40 } END_FOR_EACH_PTR(tmp);
41 free_slist(&slist);
45 void check_debug(int id)
47 my_id = id;
48 add_function_hook("__smatch_all_values", &match_all_values, NULL);
49 add_function_hook("__smatch_print_value", &match_print_value, NULL);