Print this page
12724 update smatch to 0.6.1-rc1-il-5

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 ↓ 70 lines elided ↑ open up ↑
  71   71                  found = 1;
  72   72          } END_FOR_EACH_SM(sm);
  73   73  
  74   74          if (!found)
  75   75                  sm_msg("%s '%s' not found", check_arg->string->data, state_arg->string->data);
  76   76  }
  77   77  
  78   78  static void match_states(const char *fn, struct expression *expr, void *info)
  79   79  {
  80   80          struct expression *check_arg;
  81      -        struct sm_state *sm;
  82      -        int found = 0;
  83   81  
  84   82          check_arg = get_argument_from_call_expr(expr->args, 0);
  85   83          if (check_arg->type != EXPR_STRING) {
  86   84                  sm_error("the check_name argument to %s is supposed to be a string literal", fn);
  87   85                  return;
  88   86          }
  89   87  
  90      -        FOR_EACH_SM(__get_cur_stree(), sm) {
  91      -                if (!strstr(check_name(sm->owner), check_arg->string->data))
  92      -                        continue;
  93      -                sm_msg("%s", show_sm(sm));
  94      -                found = 1;
  95      -        } END_FOR_EACH_SM(sm);
  96      -
  97      -        if (found)
       88 +        if (__print_states(check_arg->string->data))
  98   89                  return;
  99   90  
 100   91          if (!id_from_name(check_arg->string->data))
 101   92                  sm_msg("invalid check name '%s'", check_arg->string->data);
 102   93          else
 103   94                  sm_msg("%s: no states", check_arg->string->data);
 104   95  }
 105   96  
 106   97  static void match_print_value(const char *fn, struct expression *expr, void *info)
 107   98  {
↓ open down ↓ 95 lines elided ↑ open up ↑
 203  194          free_string(name);
 204  195  }
 205  196  
 206  197  static void match_user_rl(const char *fn, struct expression *expr, void *info)
 207  198  {
 208  199          struct expression *arg;
 209  200          struct range_list *rl = NULL;
 210  201          bool capped = false;
 211  202          char *name;
 212  203  
      204 +        if (option_project != PROJ_KERNEL)
      205 +                sm_msg("no user data for project = '%s'", option_project_str);
      206 +
 213  207          arg = get_argument_from_call_expr(expr->args, 0);
 214  208          name = expr_to_str(arg);
 215  209  
 216  210          get_user_rl(arg, &rl);
 217  211          if (rl)
 218  212                  capped = user_rl_capped(arg);
 219  213          sm_msg("user rl: '%s' = '%s'%s", name, show_rl(rl), capped ? " (capped)" : "");
 220  214  
 221  215          free_string(name);
 222  216  }
↓ open down ↓ 296 lines elided ↑ open up ↑
 519  513  static void match_debug_db_on(const char *fn, struct expression *expr, void *info)
 520  514  {
 521  515          debug_db = 1;
 522  516  }
 523  517  
 524  518  static void match_debug_db_off(const char *fn, struct expression *expr, void *info)
 525  519  {
 526  520          debug_db = 0;
 527  521  }
 528  522  
      523 +static void mtag_info(struct expression *expr)
      524 +{
      525 +        mtag_t tag = 0;
      526 +        int offset = 0;
      527 +        struct range_list *rl = NULL;
      528 +
      529 +        expr_to_mtag_offset(expr, &tag, &offset);
      530 +        get_mtag_rl(expr, &rl);
      531 +        sm_msg("mtag = %llu offset = %d rl = '%s'", tag, offset, show_rl(rl));
      532 +}
      533 +
 529  534  static void match_about(const char *fn, struct expression *expr, void *info)
 530  535  {
 531  536          struct expression *arg;
 532  537          struct sm_state *sm;
 533  538          char *name;
 534  539  
 535  540          sm_msg("---- about ----");
 536  541          match_print_implied(fn, expr, NULL);
 537  542          match_buf_size(fn, expr, NULL);
 538  543          match_strlen(fn, expr, NULL);
 539  544          match_real_absolute(fn, expr, NULL);
      545 +        mtag_info(expr);
 540  546  
 541  547          arg = get_argument_from_call_expr(expr->args, 0);
 542  548          name = expr_to_str(arg);
 543  549          if (!name) {
 544  550                  sm_msg("info: not a straight forward variable.");
 545  551                  return;
 546  552          }
 547  553  
 548  554          FOR_EACH_SM(__get_cur_stree(), sm) {
 549  555                  if (strcmp(sm->name, name) != 0)
↓ open down ↓ 94 lines elided ↑ open up ↑
 644  650  
 645  651  free:
 646  652          free_string(name);
 647  653  }
 648  654  
 649  655  static void match_print_stree_id(const char *fn, struct expression *expr, void *info)
 650  656  {
 651  657          sm_msg("stree_id %d", __stree_id);
 652  658  }
 653  659  
      660 +static void match_bits(const char *fn, struct expression *expr, void *_unused)
      661 +{
      662 +        struct expression *arg;
      663 +        struct bit_info *info;
      664 +        char *name;
      665 +
      666 +        arg = get_argument_from_call_expr(expr->args, 0);
      667 +        name = expr_to_str(arg);
      668 +
      669 +        info = get_bit_info(arg);
      670 +
      671 +        sm_msg("bit info '%s': definitely set 0x%llx.  possibly set 0x%llx.",
      672 +               name, info->set, info->possible);
      673 +}
      674 +
 654  675  static void match_mtag(const char *fn, struct expression *expr, void *info)
 655  676  {
 656  677          struct expression *arg;
 657  678          char *name;
 658  679          mtag_t tag = 0;
 659  680          int offset = 0;
 660  681  
 661  682          arg = get_argument_from_call_expr(expr->args, 0);
 662  683          name = expr_to_str(arg);
 663  684          expr_to_mtag_offset(arg, &tag, &offset);
↓ open down ↓ 24 lines elided ↑ open up ↑
 688  709          x = get_argument_from_call_expr(expr->args, 1);
 689  710  
 690  711          str = get_container_name(container, x);
 691  712          cont = expr_to_str(container);
 692  713          name = expr_to_str(x);
 693  714          sm_msg("container: '%s' vs '%s' --> '%s'", cont, name, str);
 694  715          free_string(cont);
 695  716          free_string(name);
 696  717  }
 697  718  
      719 +static void match_expr(const char *fn, struct expression *expr, void *info)
      720 +{
      721 +        struct expression *arg, *str, *new;
      722 +        char *name, *new_name;
      723 +
      724 +        str = get_argument_from_call_expr(expr->args, 0);
      725 +        arg = get_argument_from_call_expr(expr->args, 1);
      726 +        if (!arg || !str)
      727 +                return;
      728 +
      729 +        if (str->type != EXPR_STRING)
      730 +                return;
      731 +
      732 +        new = gen_expression_from_key(arg, str->string->data);
      733 +        name = expr_to_str(arg);
      734 +        new_name = expr_to_str(new);
      735 +
      736 +        sm_msg("str = '%s', arg = '%s' expr = '%s'", str->string->data, name, new_name);
      737 +
      738 +        free_string(new_name);
      739 +        free_string(name);
      740 +}
 698  741  static void match_state_count(const char *fn, struct expression *expr, void *info)
 699  742  {
 700  743          sm_msg("state_count = %d\n", sm_state_counter);
 701  744  }
 702  745  
 703  746  static void match_mem(const char *fn, struct expression *expr, void *info)
 704  747  {
 705  748          show_sname_alloc();
 706  749          show_data_range_alloc();
 707  750          show_rl_ptrlist_alloc();
↓ open down ↓ 77 lines elided ↑ open up ↑
 785  828          add_function_hook("__smatch_debug_off", &match_debug_off, NULL);
 786  829          add_function_hook("__smatch_local_debug_on", &match_local_debug_on, NULL);
 787  830          add_function_hook("__smatch_local_debug_off", &match_local_debug_off, NULL);
 788  831          add_function_hook("__smatch_debug_db_on", &match_debug_db_on, NULL);
 789  832          add_function_hook("__smatch_debug_db_off", &match_debug_db_off, NULL);
 790  833          add_function_hook("__smatch_intersection", &match_intersection, NULL);
 791  834          add_function_hook("__smatch_type", &match_type, NULL);
 792  835          add_implied_return_hook("__smatch_type_rl_helper", &match_type_rl_return, NULL);
 793  836          add_function_hook("__smatch_merge_tree", &match_print_merge_tree, NULL);
 794  837          add_function_hook("__smatch_stree_id", &match_print_stree_id, NULL);
      838 +        add_function_hook("__smatch_bits", &match_bits, NULL);
 795  839          add_function_hook("__smatch_mtag", &match_mtag, NULL);
 796  840          add_function_hook("__smatch_mtag_data", &match_mtag_data_offset, NULL);
      841 +        add_function_hook("__smatch_expr", &match_expr, NULL);
 797  842          add_function_hook("__smatch_state_count", &match_state_count, NULL);
 798  843          add_function_hook("__smatch_mem", &match_mem, NULL);
 799  844          add_function_hook("__smatch_exit", &match_exit, NULL);
 800  845          add_function_hook("__smatch_container", &match_container, NULL);
 801  846  
 802  847          add_hook(free_old_stree, AFTER_FUNC_HOOK);
 803  848          add_hook(trace_var, STMT_HOOK_AFTER);
 804  849  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX