Print this page
new smatch

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/graph.c
          +++ new/usr/src/tools/smatch/src/graph.c
↓ open down ↓ 66 lines elided ↑ open up ↑
  67   67                  int ret = 0;
  68   68                  const char * s = ", ls=\"[";
  69   69  
  70   70                  /* Node for the bb */
  71   71                  printf("    bb%p [shape=ellipse,label=%d,line=%d,col=%d",
  72   72                         bb, bb->pos.line, bb->pos.line, bb->pos.pos);
  73   73  
  74   74  
  75   75                  /* List loads and stores */
  76   76                  FOR_EACH_PTR(bb->insns, insn) {
       77 +                        if (!insn->bb)
       78 +                                continue;
  77   79                          switch(insn->opcode) {
  78   80                          case OP_STORE:
  79      -                                if (insn->symbol->type == PSEUDO_SYM) {
  80      -                                  printf("%s store(%s)", s, show_ident(insn->symbol->sym->ident));
       81 +                                if (insn->src->type == PSEUDO_SYM) {
       82 +                                  printf("%s store(%s)", s, show_ident(insn->src->sym->ident));
  81   83                                    s = ",";
  82   84                                  }
  83   85                                  break;
  84   86  
  85   87                          case OP_LOAD:
  86      -                                if (insn->symbol->type == PSEUDO_SYM) {
  87      -                                  printf("%s load(%s)", s, show_ident(insn->symbol->sym->ident));
       88 +                                if (insn->src->type == PSEUDO_SYM) {
       89 +                                  printf("%s load(%s)", s, show_ident(insn->src->sym->ident));
  88   90                                    s = ",";
  89   91                                  }
  90   92                                  break;
  91   93  
  92   94                          case OP_RET:
  93   95                                  ret = 1;
  94   96                                  break;
  95   97  
  96   98                          }
  97   99                  } END_FOR_EACH_PTR(insn);
↓ open down ↓ 25 lines elided ↑ open up ↑
 123  125          show_ident(ep->name->ident);
 124  126          stream_name(ep->entry->bb->pos.stream);
 125  127  
 126  128          FOR_EACH_PTR(ep->bbs, bb) {
 127  129                  if (!bb)
 128  130                          continue;
 129  131                  if (!bb->parents && !bb->children && !bb->insns && verbose < 2)
 130  132                          continue;
 131  133  
 132  134                  FOR_EACH_PTR(bb->insns, insn) {
      135 +                        if (!insn->bb)
      136 +                                continue;
 133  137                          if (insn->opcode == OP_CALL &&
 134  138                              internal == !(insn->func->sym->ctype.modifiers & MOD_EXTERN)) {
 135  139  
 136  140                                  /* Find the symbol for the callee's definition */
 137  141                                  struct symbol * sym;
 138  142                                  if (insn->func->type == PSEUDO_SYM) {
 139  143                                          for (sym = insn->func->sym->ident->symbols;
 140  144                                               sym; sym = sym->next_id) {
 141  145                                                  if (sym->namespace & NS_SYMBOL && sym->ep)
 142  146                                                          break;
↓ open down ↓ 22 lines elided ↑ open up ↑
 165  169          struct symbol *sym;
 166  170  
 167  171          struct symbol_list *fsyms, *all_syms=NULL;
 168  172  
 169  173          printf("digraph call_graph {\n");
 170  174          fsyms = sparse_initialize(argc, argv, &filelist);
 171  175          concat_symbol_list(fsyms, &all_syms);
 172  176  
 173  177          /* Linearize all symbols, graph internal basic block
 174  178           * structures and intra-file calls */
 175      -        FOR_EACH_PTR_NOTAG(filelist, file) {
      179 +        FOR_EACH_PTR(filelist, file) {
 176  180  
 177  181                  fsyms = sparse(file);
 178  182                  concat_symbol_list(fsyms, &all_syms);
 179  183  
 180  184                  FOR_EACH_PTR(fsyms, sym) {
 181  185                          expand_symbol(sym);
 182  186                          linearize_symbol(sym);
 183  187                  } END_FOR_EACH_PTR(sym);
 184  188  
 185  189                  FOR_EACH_PTR(fsyms, sym) {
 186  190                          if (sym->ep) {
 187  191                                  graph_ep(sym->ep);
 188  192                                  graph_calls(sym->ep, 1);
 189  193                          }
 190      -                } END_FOR_EACH_PTR_NOTAG(sym);
      194 +                } END_FOR_EACH_PTR(sym);
 191  195  
 192      -        } END_FOR_EACH_PTR_NOTAG(file);
      196 +        } END_FOR_EACH_PTR(file);
 193  197  
 194  198          /* Graph inter-file calls */
 195  199          FOR_EACH_PTR(all_syms, sym) {
 196  200                  if (sym->ep)
 197  201                          graph_calls(sym->ep, 0);
 198      -        } END_FOR_EACH_PTR_NOTAG(sym);
      202 +        } END_FOR_EACH_PTR(sym);
 199  203  
 200  204          printf("}\n");
 201  205          return 0;
 202  206  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX