Print this page
11972 resync smatch


   5  * modify it under the terms of the GNU General Public License
   6  * as published by the Free Software Foundation; either version 2
   7  * of the License, or (at your option) any later version.
   8  *
   9  * This program is distributed in the hope that it will be useful,
  10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  * GNU General Public License for more details.
  13  *
  14  * You should have received a copy of the GNU General Public License
  15  * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
  16  */
  17 
  18 #include "smatch.h"
  19 #include "smatch_slist.h"
  20 #include "smatch_extra.h"
  21 
  22 void show_sname_alloc(void);
  23 void show_data_range_alloc(void);
  24 void show_ptrlist_alloc(void);

  25 void show_sm_state_alloc(void);
  26 
  27 int local_debug;
  28 static int my_id;
  29 char *trace_variable;
  30 
  31 static void match_all_values(const char *fn, struct expression *expr, void *info)
  32 {
  33         struct stree *stree;
  34 
  35         stree = get_all_states_stree(SMATCH_EXTRA);
  36         __print_stree(stree);
  37         free_stree(&stree);
  38 }
  39 
  40 static void match_cur_stree(const char *fn, struct expression *expr, void *info)
  41 {
  42         __print_cur_stree();
  43 }
  44 


 187 {
 188         struct expression *arg;
 189         sval_t sval;
 190         char *name;
 191 
 192         arg = get_argument_from_call_expr(expr->args, 0);
 193         name = expr_to_str(arg);
 194 
 195         if (get_implied_max(arg, &sval))
 196                 sm_msg("implied max: %s = %s", name, sval_to_str(sval));
 197         else
 198                 sm_msg("implied max: %s = <unknown>", name);
 199 
 200         free_string(name);
 201 }
 202 
 203 static void match_user_rl(const char *fn, struct expression *expr, void *info)
 204 {
 205         struct expression *arg;
 206         struct range_list *rl = NULL;

 207         char *name;
 208 
 209         arg = get_argument_from_call_expr(expr->args, 0);
 210         name = expr_to_str(arg);
 211 
 212         get_user_rl(arg, &rl);
 213         sm_msg("user rl: '%s' = '%s'", name, show_rl(rl));


 214 
 215         free_string(name);
 216 }
 217 
 218 static void match_capped(const char *fn, struct expression *expr, void *info)
 219 {
 220         struct expression *arg;
 221         char *name;
 222 
 223         arg = get_argument_from_call_expr(expr->args, 0);
 224         name = expr_to_str(arg);
 225         sm_msg("'%s' = '%s'", name, is_capped(arg) ? "capped" : "not capped");
 226         free_string(name);
 227 }
 228 
 229 static void match_print_hard_max(const char *fn, struct expression *expr, void *info)
 230 {
 231         struct expression *arg;
 232         sval_t sval;
 233         char *name;


 670 
 671         container = get_argument_from_call_expr(expr->args, 0);
 672         x = get_argument_from_call_expr(expr->args, 1);
 673 
 674         str = get_container_name(container, x);
 675         cont = expr_to_str(container);
 676         name = expr_to_str(x);
 677         sm_msg("container: '%s' vs '%s' --> '%s'", cont, name, str);
 678         free_string(cont);
 679         free_string(name);
 680 }
 681 
 682 static void match_state_count(const char *fn, struct expression *expr, void *info)
 683 {
 684         sm_msg("state_count = %d\n", sm_state_counter);
 685 }
 686 
 687 static void match_mem(const char *fn, struct expression *expr, void *info)
 688 {
 689         show_sname_alloc();


 690         show_ptrlist_alloc();
 691         sm_msg("%lu pools", get_pool_count());
 692         sm_msg("%d strees", unfree_stree);
 693         show_smatch_state_alloc();
 694         show_sm_state_alloc();
 695 }
 696 
 697 static void match_exit(const char *fn, struct expression *expr, void *info)
 698 {
 699         exit(0);
 700 }
 701 
 702 static struct stree *old_stree;
 703 static void trace_var(struct statement *stmt)
 704 {
 705         struct sm_state *sm, *old;
 706         int printed = 0;
 707 
 708         if (!trace_variable)
 709                 return;




   5  * modify it under the terms of the GNU General Public License
   6  * as published by the Free Software Foundation; either version 2
   7  * of the License, or (at your option) any later version.
   8  *
   9  * This program is distributed in the hope that it will be useful,
  10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  * GNU General Public License for more details.
  13  *
  14  * You should have received a copy of the GNU General Public License
  15  * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
  16  */
  17 
  18 #include "smatch.h"
  19 #include "smatch_slist.h"
  20 #include "smatch_extra.h"
  21 
  22 void show_sname_alloc(void);
  23 void show_data_range_alloc(void);
  24 void show_ptrlist_alloc(void);
  25 void show_rl_ptrlist_alloc(void);
  26 void show_sm_state_alloc(void);
  27 
  28 int local_debug;
  29 static int my_id;
  30 char *trace_variable;
  31 
  32 static void match_all_values(const char *fn, struct expression *expr, void *info)
  33 {
  34         struct stree *stree;
  35 
  36         stree = get_all_states_stree(SMATCH_EXTRA);
  37         __print_stree(stree);
  38         free_stree(&stree);
  39 }
  40 
  41 static void match_cur_stree(const char *fn, struct expression *expr, void *info)
  42 {
  43         __print_cur_stree();
  44 }
  45 


 188 {
 189         struct expression *arg;
 190         sval_t sval;
 191         char *name;
 192 
 193         arg = get_argument_from_call_expr(expr->args, 0);
 194         name = expr_to_str(arg);
 195 
 196         if (get_implied_max(arg, &sval))
 197                 sm_msg("implied max: %s = %s", name, sval_to_str(sval));
 198         else
 199                 sm_msg("implied max: %s = <unknown>", name);
 200 
 201         free_string(name);
 202 }
 203 
 204 static void match_user_rl(const char *fn, struct expression *expr, void *info)
 205 {
 206         struct expression *arg;
 207         struct range_list *rl = NULL;
 208         bool capped = false;
 209         char *name;
 210 
 211         arg = get_argument_from_call_expr(expr->args, 0);
 212         name = expr_to_str(arg);
 213 
 214         get_user_rl(arg, &rl);
 215         if (rl)
 216                 capped = user_rl_capped(arg);
 217         sm_msg("user rl: '%s' = '%s'%s", name, show_rl(rl), capped ? " (capped)" : "");
 218 
 219         free_string(name);
 220 }
 221 
 222 static void match_capped(const char *fn, struct expression *expr, void *info)
 223 {
 224         struct expression *arg;
 225         char *name;
 226 
 227         arg = get_argument_from_call_expr(expr->args, 0);
 228         name = expr_to_str(arg);
 229         sm_msg("'%s' = '%s'", name, is_capped(arg) ? "capped" : "not capped");
 230         free_string(name);
 231 }
 232 
 233 static void match_print_hard_max(const char *fn, struct expression *expr, void *info)
 234 {
 235         struct expression *arg;
 236         sval_t sval;
 237         char *name;


 674 
 675         container = get_argument_from_call_expr(expr->args, 0);
 676         x = get_argument_from_call_expr(expr->args, 1);
 677 
 678         str = get_container_name(container, x);
 679         cont = expr_to_str(container);
 680         name = expr_to_str(x);
 681         sm_msg("container: '%s' vs '%s' --> '%s'", cont, name, str);
 682         free_string(cont);
 683         free_string(name);
 684 }
 685 
 686 static void match_state_count(const char *fn, struct expression *expr, void *info)
 687 {
 688         sm_msg("state_count = %d\n", sm_state_counter);
 689 }
 690 
 691 static void match_mem(const char *fn, struct expression *expr, void *info)
 692 {
 693         show_sname_alloc();
 694         show_data_range_alloc();
 695         show_rl_ptrlist_alloc();
 696         show_ptrlist_alloc();
 697         sm_msg("%lu pools", get_pool_count());
 698         sm_msg("%d strees", unfree_stree);
 699         show_smatch_state_alloc();
 700         show_sm_state_alloc();
 701 }
 702 
 703 static void match_exit(const char *fn, struct expression *expr, void *info)
 704 {
 705         exit(0);
 706 }
 707 
 708 static struct stree *old_stree;
 709 static void trace_var(struct statement *stmt)
 710 {
 711         struct sm_state *sm, *old;
 712         int printed = 0;
 713 
 714         if (!trace_variable)
 715                 return;