Print this page
11506 smatch resync

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/smatch_data/db/smdb.py
          +++ new/usr/src/tools/smatch/src/smatch_data/db/smdb.py
↓ open down ↓ 9 lines elided ↑ open up ↑
  10   10  
  11   11  try:
  12   12      con = sqlite3.connect('smatch_db.sqlite')
  13   13  except sqlite3.Error, e:
  14   14      print "Error %s:" % e.args[0]
  15   15      sys.exit(1)
  16   16  
  17   17  def usage():
  18   18      print "%s" %(sys.argv[0])
  19   19      print "<function> - how a function is called"
       20 +    print "info <type> - how a function is called, filtered by type"
  20   21      print "return_states <function> - what a function returns"
  21   22      print "call_tree <function> - show the call tree"
  22   23      print "where <struct_type> <member> - where a struct member is set"
  23   24      print "type_size <struct_type> <member> - how a struct member is allocated"
  24   25      print "data_info <struct_type> <member> - information about a given data type"
  25   26      print "function_ptr <function> - which function pointers point to this"
  26   27      print "trace_param <function> <param> - trace where a parameter came from"
  27   28      print "locals <file> - print the local values in a file."
  28   29      sys.exit(1)
  29   30  
↓ open down ↓ 18 lines elided ↑ open up ↑
  48   49      searched_ptrs = [func]
  49   50      get_function_pointers_helper(func)
  50   51      return function_ptrs
  51   52  
  52   53  db_types = {   0: "INTERNAL",
  53   54               101: "PARAM_CLEARED",
  54   55               103: "PARAM_LIMIT",
  55   56               104: "PARAM_FILTER",
  56   57              1001: "PARAM_VALUE",
  57   58              1002: "BUF_SIZE",
  58      -            1003: "USER_DATA",
  59   59              1004: "CAPPED_DATA",
  60   60              1005: "RETURN_VALUE",
  61   61              1006: "DEREFERENCE",
  62   62              1007: "RANGE_CAP",
  63   63              1008: "LOCK_HELD",
  64   64              1009: "LOCK_RELEASED",
  65   65              1010: "ABSOLUTE_LIMITS",
  66   66              1012: "PARAM_ADD",
  67   67              1013: "PARAM_FREED",
  68   68              1014: "DATA_SOURCE",
↓ open down ↓ 3 lines elided ↑ open up ↑
  72   72              1018: "CAPABLE",
  73   73              1019: "NS_CAPABLE",
  74   74              1022: "TYPE_LINK",
  75   75              1023: "UNTRACKED_PARAM",
  76   76              1024: "CULL_PATH",
  77   77              1025: "PARAM_SET",
  78   78              1026: "PARAM_USED",
  79   79              1027: "BYTE_UNITS",
  80   80              1028: "COMPARE_LIMIT",
  81   81              1029: "PARAM_COMPARE",
  82      -            8017: "USER_DATA2",
       82 +            1030: "EXPECTS_TYPE",
       83 +            1031: "CONSTRAINT",
       84 +            1032: "PASSES_TYPE",
       85 +            1033: "CONSTRAINT_REQUIRED",
       86 +            1034: "BIT_INFO",
       87 +            1035: "NOSPEC",
       88 +            1036: "NOSPEC_WB",
       89 +            1037: "STMT_CNT",
       90 +            1038: "TERMINATED",
       91 +            1039: "SLEEP",
       92 +            1040: "NO_SLEEP_CNT",
       93 +            1041: "SMALLISH",
       94 +            1042: "FRESH_MTAG",
       95 +
       96 +            8017: "USER_DATA",
       97 +            9017: "USER_DATA_SET",
  83   98              8018: "NO_OVERFLOW",
  84   99              8019: "NO_OVERFLOW_SIMPLE",
  85  100              8020: "LOCKED",
  86  101              8021: "UNLOCKED",
  87  102              8023: "ATOMIC_INC",
  88  103              8024: "ATOMIC_DEC",
  89  104  };
  90  105  
  91  106  def add_range(rl, min_val, max_val):
  92  107      check_next = 0
↓ open down ↓ 97 lines elided ↑ open up ↑
 190  205      elif txt == "s16min":
 191  206          return -(2**15)
 192  207      elif txt == "s64max":
 193  208          return 2**63 - 1
 194  209      elif txt == "s32max":
 195  210          return 2**31 - 1
 196  211      elif txt == "s16max":
 197  212          return 2**15 - 1
 198  213      elif txt == "u64max":
 199  214          return 2**64 - 1
      215 +    elif txt == "ptr_max":
      216 +        return 2**64 - 1
 200  217      elif txt == "u32max":
 201  218          return 2**32 - 1
 202  219      elif txt == "u16max":
 203  220          return 2**16 - 1
 204  221      else:
 205  222          try:
 206  223              return int(txt)
 207  224          except ValueError:
 208  225              return 0
 209  226  
↓ open down ↓ 372 lines elided ↑ open up ↑
 582  599      cur.execute("select * from constraints_required where data like '(struct %s)->%s' or bound like '(struct %s)->%s';" %(struct_type, member, struct_type, member))
 583  600      for txt in cur:
 584  601          print "%-30s | %-30s | %s | %s" %(txt[0], txt[1], txt[2], txt[3])
 585  602  
 586  603  if len(sys.argv) < 2:
 587  604      usage()
 588  605  
 589  606  if len(sys.argv) == 2:
 590  607      func = sys.argv[1]
 591  608      print_caller_info("", func)
      609 +elif sys.argv[1] == "info":
      610 +    my_type = ""
      611 +    if len(sys.argv) == 4:
      612 +        my_type = sys.argv[3]
      613 +    func = sys.argv[2]
      614 +    print_caller_info("", func, my_type)
 592  615  elif sys.argv[1] == "call_info":
 593  616      if len(sys.argv) != 4:
 594  617          usage()
 595  618      filename = sys.argv[2]
 596  619      func = sys.argv[3]
 597  620      caller_info_values(filename, func)
 598  621      print_caller_info(filename, func)
 599      -elif sys.argv[1] == "user_data":
 600      -    func = sys.argv[2]
 601      -    print_caller_info(filename, func, "USER_DATA")
 602      -elif sys.argv[1] == "param_value":
 603      -    func = sys.argv[2]
 604      -    print_caller_info(filename, func, "PARAM_VALUE")
 605  622  elif sys.argv[1] == "function_ptr" or sys.argv[1] == "fn_ptr":
 606  623      func = sys.argv[2]
 607  624      print_fn_ptrs(func)
 608  625  elif sys.argv[1] == "return_states":
 609  626      func = sys.argv[2]
 610  627      print_return_states(func)
 611  628      print "================================================"
 612  629      print_return_implies(func)
 613  630  elif sys.argv[1] == "return_implies":
 614  631      func = sys.argv[2]
↓ open down ↓ 54 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX