Print this page
11506 smatch resync

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/check_debug.c
          +++ new/usr/src/tools/smatch/src/check_debug.c
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12   * GNU General Public License for more details.
  13   13   *
  14   14   * You should have received a copy of the GNU General Public License
  15   15   * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
  16   16   */
  17   17  
  18   18  #include "smatch.h"
  19   19  #include "smatch_slist.h"
  20   20  #include "smatch_extra.h"
  21   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 +
  22   27  int local_debug;
  23   28  static int my_id;
  24   29  char *trace_variable;
  25   30  
  26   31  static void match_all_values(const char *fn, struct expression *expr, void *info)
  27   32  {
  28   33          struct stree *stree;
  29   34  
  30   35          stree = get_all_states_stree(SMATCH_EXTRA);
  31   36          __print_stree(stree);
↓ open down ↓ 159 lines elided ↑ open up ↑
 191  196                  sm_msg("implied max: %s = %s", name, sval_to_str(sval));
 192  197          else
 193  198                  sm_msg("implied max: %s = <unknown>", name);
 194  199  
 195  200          free_string(name);
 196  201  }
 197  202  
 198  203  static void match_user_rl(const char *fn, struct expression *expr, void *info)
 199  204  {
 200  205          struct expression *arg;
 201      -        struct range_list *rl;
      206 +        struct range_list *rl = NULL;
 202  207          char *name;
 203  208  
 204  209          arg = get_argument_from_call_expr(expr->args, 0);
 205  210          name = expr_to_str(arg);
 206  211  
 207  212          get_user_rl(arg, &rl);
 208  213          sm_msg("user rl: '%s' = '%s'", name, show_rl(rl));
 209  214  
 210  215          free_string(name);
 211  216  }
↓ open down ↓ 165 lines elided ↑ open up ↑
 377  382          free_string(name);
 378  383  }
 379  384  
 380  385  static void match_buf_size(const char *fn, struct expression *expr, void *info)
 381  386  {
 382  387          struct expression *arg, *comp;
 383  388          struct range_list *rl;
 384  389          int elements, bytes;
 385  390          char *name;
 386  391          char buf[256] = "";
      392 +        int limit_type;
 387  393          int n;
 388  394          sval_t sval;
 389  395  
 390  396          arg = get_argument_from_call_expr(expr->args, 0);
 391  397  
 392  398          elements = get_array_size(arg);
 393  399          bytes = get_array_size_bytes_max(arg);
 394  400          rl = get_array_size_bytes_rl(arg);
 395      -        comp = get_size_variable(arg);
      401 +        comp = get_size_variable(arg, &limit_type);
 396  402  
 397  403          name = expr_to_str(arg);
 398  404          n = snprintf(buf, sizeof(buf), "buf size: '%s' %d elements, %d bytes", name, elements, bytes);
 399  405          free_string(name);
 400  406  
 401  407          if (!rl_to_sval(rl, &sval))
 402  408                  n += snprintf(buf + n, sizeof(buf) - n, " (rl = %s)", show_rl(rl));
 403  409  
 404  410          if (comp) {
 405  411                  name = expr_to_str(comp);
 406      -                snprintf(buf + n, sizeof(buf) - n, "[size_var=%s]", name);
      412 +                snprintf(buf + n, sizeof(buf) - n, "[size_var=%s %s]", limit_type_str(limit_type), name);
 407  413                  free_string(name);
 408  414          }
 409  415          sm_msg("%s", buf);
 410  416  }
 411  417  
 412  418  static void match_note(const char *fn, struct expression *expr, void *info)
 413  419  {
 414  420          struct expression *arg_expr;
 415  421  
 416  422          arg_expr = get_argument_from_call_expr(expr->args, 0);
↓ open down ↓ 80 lines elided ↑ open up ↑
 497  503  static void match_local_debug_on(const char *fn, struct expression *expr, void *info)
 498  504  {
 499  505          local_debug = 1;
 500  506  }
 501  507  
 502  508  static void match_local_debug_off(const char *fn, struct expression *expr, void *info)
 503  509  {
 504  510          local_debug = 0;
 505  511  }
 506  512  
 507      -static void match_debug_implied_on(const char *fn, struct expression *expr, void *info)
 508      -{
 509      -        option_debug_implied = 1;
 510      -}
 511      -
 512      -static void match_debug_implied_off(const char *fn, struct expression *expr, void *info)
 513      -{
 514      -        option_debug_implied = 0;
 515      -}
 516      -
 517  513  static void match_about(const char *fn, struct expression *expr, void *info)
 518  514  {
 519  515          struct expression *arg;
 520  516          struct sm_state *sm;
 521  517          char *name;
 522  518  
 523  519          sm_msg("---- about ----");
 524  520          match_print_implied(fn, expr, NULL);
 525  521          match_buf_size(fn, expr, NULL);
 526  522          match_strlen(fn, expr, NULL);
↓ open down ↓ 110 lines elided ↑ open up ↑
 637  633  static void match_print_stree_id(const char *fn, struct expression *expr, void *info)
 638  634  {
 639  635          sm_msg("stree_id %d", __stree_id);
 640  636  }
 641  637  
 642  638  static void match_mtag(const char *fn, struct expression *expr, void *info)
 643  639  {
 644  640          struct expression *arg;
 645  641          char *name;
 646  642          mtag_t tag = 0;
      643 +        int offset = 0;
 647  644  
 648  645          arg = get_argument_from_call_expr(expr->args, 0);
 649  646          name = expr_to_str(arg);
 650      -        get_mtag(arg, &tag);
 651      -        sm_msg("mtag: '%s' => tag: %lld", name, tag);
      647 +        expr_to_mtag_offset(arg, &tag, &offset);
      648 +        sm_msg("mtag: '%s' => tag: %llu %d", name, tag, offset);
 652  649          free_string(name);
 653  650  }
 654  651  
 655  652  static void match_mtag_data_offset(const char *fn, struct expression *expr, void *info)
 656  653  {
 657  654          struct expression *arg;
 658  655          char *name;
 659  656          mtag_t tag = 0;
 660  657          int offset = -1;
 661  658  
 662  659          arg = get_argument_from_call_expr(expr->args, 0);
 663  660          name = expr_to_str(arg);
 664  661          expr_to_mtag_offset(arg, &tag, &offset);
 665  662          sm_msg("mtag: '%s' => tag: %lld, offset: %d", name, tag, offset);
 666  663          free_string(name);
 667  664  }
 668  665  
      666 +static void match_container(const char *fn, struct expression *expr, void *info)
      667 +{
      668 +        struct expression *container, *x;
      669 +        char *cont, *name, *str;
      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 +
 669  682  static void match_state_count(const char *fn, struct expression *expr, void *info)
 670  683  {
 671  684          sm_msg("state_count = %d\n", sm_state_counter);
 672  685  }
 673  686  
 674  687  static void match_mem(const char *fn, struct expression *expr, void *info)
 675  688  {
 676  689          show_sname_alloc();
 677  690          show_ptrlist_alloc();
 678  691          sm_msg("%lu pools", get_pool_count());
↓ open down ↓ 68 lines elided ↑ open up ↑
 747  760          add_function_hook("__smatch_strlen", &match_strlen, NULL);
 748  761          add_function_hook("__smatch_buf_size", &match_buf_size, NULL);
 749  762          add_function_hook("__smatch_note", &match_note, NULL);
 750  763          add_function_hook("__smatch_dump_related", &match_dump_related, NULL);
 751  764          add_function_hook("__smatch_compare", &match_compare, NULL);
 752  765          add_function_hook("__smatch_debug_on", &match_debug_on, NULL);
 753  766          add_function_hook("__smatch_debug_check", &match_debug_check, NULL);
 754  767          add_function_hook("__smatch_debug_off", &match_debug_off, NULL);
 755  768          add_function_hook("__smatch_local_debug_on", &match_local_debug_on, NULL);
 756  769          add_function_hook("__smatch_local_debug_off", &match_local_debug_off, NULL);
 757      -        add_function_hook("__smatch_debug_implied_on", &match_debug_implied_on, NULL);
 758      -        add_function_hook("__smatch_debug_implied_off", &match_debug_implied_off, NULL);
 759  770          add_function_hook("__smatch_intersection", &match_intersection, NULL);
 760  771          add_function_hook("__smatch_type", &match_type, NULL);
 761  772          add_implied_return_hook("__smatch_type_rl_helper", &match_type_rl_return, NULL);
 762  773          add_function_hook("__smatch_merge_tree", &match_print_merge_tree, NULL);
 763  774          add_function_hook("__smatch_stree_id", &match_print_stree_id, NULL);
 764  775          add_function_hook("__smatch_mtag", &match_mtag, NULL);
 765  776          add_function_hook("__smatch_mtag_data", &match_mtag_data_offset, NULL);
 766  777          add_function_hook("__smatch_state_count", &match_state_count, NULL);
 767  778          add_function_hook("__smatch_mem", &match_mem, NULL);
 768  779          add_function_hook("__smatch_exit", &match_exit, NULL);
      780 +        add_function_hook("__smatch_container", &match_container, NULL);
 769  781  
 770  782          add_hook(free_old_stree, AFTER_FUNC_HOOK);
 771  783          add_hook(trace_var, STMT_HOOK_AFTER);
 772  784  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX