1 /*
2 * Copyright (C) 2009 Dan Carpenter.
3 *
4 * This program is free software; you can redistribute it and/or
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
45 static void match_state(const char *fn, struct expression *expr, void *info)
46 {
47 struct expression *check_arg, *state_arg;
48 struct sm_state *sm;
49 int found = 0;
50
51 check_arg = get_argument_from_call_expr(expr->args, 0);
52 if (check_arg->type != EXPR_STRING) {
53 sm_error("the check_name argument to %s is supposed to be a string literal", fn);
54 return;
55 }
56 state_arg = get_argument_from_call_expr(expr->args, 1);
57 if (!state_arg || state_arg->type != EXPR_STRING) {
58 sm_error("the state_name argument to %s is supposed to be a string literal", fn);
59 return;
60 }
61
62 FOR_EACH_SM(__get_cur_stree(), sm) {
63 if (strcmp(check_name(sm->owner), check_arg->string->data) != 0)
64 continue;
65 if (strcmp(sm->name, state_arg->string->data) != 0)
66 continue;
67 sm_msg("'%s' = '%s'", sm->name, sm->state->name);
68 found = 1;
69 } END_FOR_EACH_SM(sm);
70
71 if (!found)
72 sm_msg("%s '%s' not found", check_arg->string->data, state_arg->string->data);
73 }
74
75 static void match_states(const char *fn, struct expression *expr, void *info)
76 {
77 struct expression *check_arg;
78 struct sm_state *sm;
79 int found = 0;
80
81 check_arg = get_argument_from_call_expr(expr->args, 0);
82 if (check_arg->type != EXPR_STRING) {
83 sm_error("the check_name argument to %s is supposed to be a string literal", fn);
84 return;
85 }
86
87 FOR_EACH_SM(__get_cur_stree(), sm) {
88 if (strcmp(check_name(sm->owner), check_arg->string->data) != 0)
89 continue;
90 sm_msg("%s", show_sm(sm));
91 found = 1;
92 } END_FOR_EACH_SM(sm);
93
94 if (found)
95 return;
96
97 if (!id_from_name(check_arg->string->data))
98 sm_msg("invalid check name '%s'", check_arg->string->data);
99 else
100 sm_msg("%s: no states", check_arg->string->data);
101 }
102
103 static void match_print_value(const char *fn, struct expression *expr, void *info)
104 {
105 struct stree *stree;
106 struct sm_state *tmp;
107 struct expression *arg_expr;
108
109 arg_expr = get_argument_from_call_expr(expr->args, 0);
110 if (arg_expr->type != EXPR_STRING) {
111 sm_error("the argument to %s is supposed to be a string literal", fn);
112 return;
113 }
114
115 stree = __get_cur_stree();
116 FOR_EACH_MY_SM(SMATCH_EXTRA, stree, tmp) {
117 if (!strcmp(tmp->name, arg_expr->string->data))
118 sm_msg("%s = %s", tmp->name, tmp->state->name);
119 } END_FOR_EACH_SM(tmp);
120 }
121
122 static void match_print_known(const char *fn, struct expression *expr, void *info)
123 {
124 struct expression *arg;
125 struct range_list *rl = NULL;
126 char *name;
127 int known = 0;
128 sval_t sval;
129
130 arg = get_argument_from_call_expr(expr->args, 0);
131 if (get_value(arg, &sval))
132 known = 1;
133
134 get_implied_rl(arg, &rl);
135
136 name = expr_to_str(arg);
137 sm_msg("known: '%s' = '%s'. implied = '%s'", name, known ? sval_to_str(sval) : "<unknown>", show_rl(rl));
138 free_string(name);
139 }
140
141 static void match_print_implied(const char *fn, struct expression *expr, void *info)
142 {
143 struct expression *arg;
144 struct range_list *rl = NULL;
145 char *name;
146
147 arg = get_argument_from_call_expr(expr->args, 0);
148 get_implied_rl(arg, &rl);
149
150 name = expr_to_str(arg);
151 sm_msg("implied: %s = '%s'", name, show_rl(rl));
152 free_string(name);
153 }
154
155 static void match_real_absolute(const char *fn, struct expression *expr, void *info)
156 {
157 struct expression *arg;
158 struct range_list *rl = NULL;
159 char *name;
160
161 arg = get_argument_from_call_expr(expr->args, 0);
162 get_real_absolute_rl(arg, &rl);
163
164 name = expr_to_str(arg);
165 sm_msg("real absolute: %s = '%s'", name, show_rl(rl));
166 free_string(name);
167 }
168
169 static void match_print_implied_min(const char *fn, struct expression *expr, void *info)
170 {
171 struct expression *arg;
172 sval_t sval;
173 char *name;
174
175 arg = get_argument_from_call_expr(expr->args, 0);
176 name = expr_to_str(arg);
177
178 if (get_implied_min(arg, &sval))
179 sm_msg("implied min: %s = %s", name, sval_to_str(sval));
180 else
181 sm_msg("implied min: %s = <unknown>", name);
182
183 free_string(name);
184 }
185
186 static void match_print_implied_max(const char *fn, struct expression *expr, void *info)
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;
234
235 arg = get_argument_from_call_expr(expr->args, 0);
236 name = expr_to_str(arg);
237
238 if (get_hard_max(arg, &sval))
239 sm_msg("hard max: %s = %s", name, sval_to_str(sval));
240 else
241 sm_msg("hard max: %s = <unknown>", name);
242
243 free_string(name);
244 }
245
246 static void match_print_fuzzy_max(const char *fn, struct expression *expr, void *info)
247 {
248 struct expression *arg;
249 sval_t sval;
250 char *name;
251
252 arg = get_argument_from_call_expr(expr->args, 0);
253 name = expr_to_str(arg);
254
255 if (get_fuzzy_max(arg, &sval))
256 sm_msg("fuzzy max: %s = %s", name, sval_to_str(sval));
257 else
258 sm_msg("fuzzy max: %s = <unknown>", name);
259
260 free_string(name);
261 }
262
263 static void match_print_absolute(const char *fn, struct expression *expr, void *info)
264 {
265 struct expression *arg;
266 struct range_list *rl;
267 char *name;
268
269 arg = get_argument_from_call_expr(expr->args, 0);
270 name = expr_to_str(arg);
271
272 get_absolute_rl(arg, &rl);
273 sm_msg("absolute: %s = %s", name, show_rl(rl));
274
275 free_string(name);
276 }
277
278 static void match_print_absolute_min(const char *fn, struct expression *expr, void *info)
279 {
280 struct expression *arg;
281 sval_t sval;
282 char *name;
283
284 arg = get_argument_from_call_expr(expr->args, 0);
285 name = expr_to_str(arg);
286
287 if (get_absolute_min(arg, &sval))
288 sm_msg("absolute min: %s = %s", name, sval_to_str(sval));
289 else
290 sm_msg("absolute min: %s = <unknown>", name);
291
292 free_string(name);
293 }
294
295 static void match_print_absolute_max(const char *fn, struct expression *expr, void *info)
296 {
297 struct expression *arg;
298 sval_t sval;
299 char *name;
300
301 arg = get_argument_from_call_expr(expr->args, 0);
302 get_absolute_max(arg, &sval);
303
304 name = expr_to_str(arg);
305 sm_msg("absolute max: %s = %s", name, sval_to_str(sval));
306 free_string(name);
307 }
308
309 static void match_sval_info(const char *fn, struct expression *expr, void *info)
310 {
311 struct expression *arg;
312 sval_t sval;
313 char *name;
314
315 arg = get_argument_from_call_expr(expr->args, 0);
316 name = expr_to_str(arg);
317
318 if (!get_implied_value(arg, &sval)) {
319 sm_msg("no sval for '%s'", name);
320 goto free;
321 }
322
323 sm_msg("implied: %s %c%d ->value = %llx", name, sval_unsigned(sval) ? 'u' : 's', sval_bits(sval), sval.value);
324 free:
325 free_string(name);
326 }
327
328 static void match_member_name(const char *fn, struct expression *expr, void *info)
329 {
330 struct expression *arg;
331 char *name, *member_name;
332
333 arg = get_argument_from_call_expr(expr->args, 0);
334 name = expr_to_str(arg);
335 member_name = get_member_name(arg);
336 sm_msg("member name: '%s => %s'", name, member_name);
337 free_string(member_name);
338 free_string(name);
339 }
340
341 static void print_possible(struct sm_state *sm)
342 {
343 struct sm_state *tmp;
344
345 sm_msg("Possible values for %s", sm->name);
346 FOR_EACH_PTR(sm->possible, tmp) {
347 printf("%s\n", tmp->state->name);
348 } END_FOR_EACH_PTR(tmp);
349 sm_msg("===");
350 }
351
352 static void match_possible(const char *fn, struct expression *expr, void *info)
353 {
354 struct stree *stree;
355 struct sm_state *tmp;
356 struct expression *arg_expr;
357
358 arg_expr = get_argument_from_call_expr(expr->args, 0);
359 if (arg_expr->type != EXPR_STRING) {
360 sm_error("the argument to %s is supposed to be a string literal", fn);
361 return;
362 }
363
364 stree = __get_cur_stree();
365 FOR_EACH_MY_SM(SMATCH_EXTRA, stree, tmp) {
366 if (!strcmp(tmp->name, arg_expr->string->data))
367 print_possible(tmp);
368 } END_FOR_EACH_SM(tmp);
369 }
370
371 static void match_strlen(const char *fn, struct expression *expr, void *info)
372 {
373 struct expression *arg;
374 struct range_list *rl;
375 char *name;
376
377 arg = get_argument_from_call_expr(expr->args, 0);
378 get_implied_strlen(arg, &rl);
379
380 name = expr_to_str(arg);
381 sm_msg("strlen: '%s' %s characters", name, show_rl(rl));
382 free_string(name);
383 }
384
385 static void match_buf_size(const char *fn, struct expression *expr, void *info)
386 {
387 struct expression *arg, *comp;
388 struct range_list *rl;
389 int elements, bytes;
390 char *name;
391 char buf[256] = "";
392 int limit_type;
393 int n;
394 sval_t sval;
395
396 arg = get_argument_from_call_expr(expr->args, 0);
397
398 elements = get_array_size(arg);
399 bytes = get_array_size_bytes_max(arg);
400 rl = get_array_size_bytes_rl(arg);
401 comp = get_size_variable(arg, &limit_type);
402
403 name = expr_to_str(arg);
404 n = snprintf(buf, sizeof(buf), "buf size: '%s' %d elements, %d bytes", name, elements, bytes);
405 free_string(name);
406
407 if (!rl_to_sval(rl, &sval))
408 n += snprintf(buf + n, sizeof(buf) - n, " (rl = %s)", show_rl(rl));
409
410 if (comp) {
411 name = expr_to_str(comp);
412 snprintf(buf + n, sizeof(buf) - n, "[size_var=%s %s]", limit_type_str(limit_type), name);
413 free_string(name);
414 }
415 sm_msg("%s", buf);
416 }
417
418 static void match_note(const char *fn, struct expression *expr, void *info)
419 {
420 struct expression *arg_expr;
421
422 arg_expr = get_argument_from_call_expr(expr->args, 0);
423 if (arg_expr->type != EXPR_STRING) {
424 sm_error("the argument to %s is supposed to be a string literal", fn);
425 return;
426 }
427 sm_msg("%s", arg_expr->string->data);
428 }
429
430 static void print_related(struct sm_state *sm)
431 {
432 struct relation *rel;
433
434 if (!estate_related(sm->state))
435 return;
436
437 sm_prefix();
438 sm_printf("%s: ", sm->name);
439 FOR_EACH_PTR(estate_related(sm->state), rel) {
440 sm_printf("%s ", rel->name);
441 } END_FOR_EACH_PTR(rel);
442 sm_printf("\n");
443 }
444
445 static void match_dump_related(const char *fn, struct expression *expr, void *info)
446 {
447 struct stree *stree;
448 struct sm_state *tmp;
449
450 stree = __get_cur_stree();
451 FOR_EACH_MY_SM(SMATCH_EXTRA, stree, tmp) {
452 print_related(tmp);
453 } END_FOR_EACH_SM(tmp);
454 }
455
456 static void match_compare(const char *fn, struct expression *expr, void *info)
457 {
458 struct expression *one, *two;
459 char *one_name, *two_name;
460 int comparison;
461 char buf[16];
462
463 one = get_argument_from_call_expr(expr->args, 0);
464 two = get_argument_from_call_expr(expr->args, 1);
465
466 comparison = get_comparison(one, two);
467 if (!comparison)
468 snprintf(buf, sizeof(buf), "<none>");
469 else
470 snprintf(buf, sizeof(buf), "%s", show_special(comparison));
471
472 one_name = expr_to_str(one);
473 two_name = expr_to_str(two);
474
475 sm_msg("%s %s %s", one_name, buf, two_name);
476
477 free_string(one_name);
478 free_string(two_name);
479 }
480
481 static void match_debug_on(const char *fn, struct expression *expr, void *info)
482 {
483 option_debug = 1;
484 }
485
486 static void match_debug_check(const char *fn, struct expression *expr, void *info)
487 {
488 struct expression *arg;
489
490 arg = get_argument_from_call_expr(expr->args, 0);
491 if (!arg || arg->type != EXPR_STRING)
492 return;
493 option_debug_check = arg->string->data;
494 sm_msg("arg = '%s'", option_debug_check);
495 }
496
497 static void match_debug_off(const char *fn, struct expression *expr, void *info)
498 {
499 option_debug_check = (char *)"";
500 option_debug = 0;
501 }
502
503 static void match_local_debug_on(const char *fn, struct expression *expr, void *info)
504 {
505 local_debug = 1;
506 }
507
508 static void match_local_debug_off(const char *fn, struct expression *expr, void *info)
509 {
510 local_debug = 0;
511 }
512
513 static void match_about(const char *fn, struct expression *expr, void *info)
514 {
515 struct expression *arg;
516 struct sm_state *sm;
517 char *name;
518
519 sm_msg("---- about ----");
520 match_print_implied(fn, expr, NULL);
521 match_buf_size(fn, expr, NULL);
522 match_strlen(fn, expr, NULL);
523 match_real_absolute(fn, expr, NULL);
524
525 arg = get_argument_from_call_expr(expr->args, 0);
526 name = expr_to_str(arg);
527 if (!name) {
528 sm_msg("info: not a straight forward variable.");
529 return;
530 }
531
532 FOR_EACH_SM(__get_cur_stree(), sm) {
533 if (strcmp(sm->name, name) != 0)
534 continue;
535 sm_msg("%s", show_sm(sm));
536 } END_FOR_EACH_SM(sm);
537 }
538
539 static void match_intersection(const char *fn, struct expression *expr, void *info)
540 {
541 struct expression *one, *two;
542 struct range_list *one_rl, *two_rl;
543 struct range_list *res;
544
545 one = get_argument_from_call_expr(expr->args, 0);
546 two = get_argument_from_call_expr(expr->args, 1);
547
548 get_absolute_rl(one, &one_rl);
549 get_absolute_rl(two, &two_rl);
550
551 res = rl_intersection(one_rl, two_rl);
552 sm_msg("'%s' intersect '%s' is '%s'", show_rl(one_rl), show_rl(two_rl), show_rl(res));
553 }
554
555 static void match_type(const char *fn, struct expression *expr, void *info)
556 {
557 struct expression *one;
558 struct symbol *type;
559 char *name;
560
561 one = get_argument_from_call_expr(expr->args, 0);
562 type = get_type(one);
563 name = expr_to_str(one);
564 sm_msg("type of '%s' is: '%s'", name, type_to_str(type));
565 free_string(name);
566 }
567
568 static int match_type_rl_return(struct expression *call, void *unused, struct range_list **rl)
569 {
570 struct expression *one, *two;
571 struct symbol *type;
572
573 one = get_argument_from_call_expr(call->args, 0);
574 type = get_type(one);
575
576 two = get_argument_from_call_expr(call->args, 1);
577 if (!two || two->type != EXPR_STRING) {
578 sm_msg("expected: __smatch_type_rl(type, \"string\")");
579 return 0;
580 }
581 call_results_to_rl(call, type, two->string->data, rl);
582 return 1;
583 }
584
585 static void print_left_right(struct sm_state *sm)
586 {
587 if (!sm)
588 return;
589 if (!sm->left && !sm->right)
590 return;
591
592 sm_printf("[ ");
593 if (sm->left)
594 sm_printf("(%d: %s->'%s')", get_stree_id(sm->left->pool), sm->left->name, sm->left->state->name);
595 else
596 sm_printf(" - ");
597
598
599 print_left_right(sm->left);
600
601 if (sm->right)
602 sm_printf("(%d: %s->'%s')", get_stree_id(sm->right->pool), sm->right->name, sm->right->state->name);
603 else
604 sm_printf(" - ");
605
606 print_left_right(sm->right);
607 }
608
609 static void match_print_merge_tree(const char *fn, struct expression *expr, void *info)
610 {
611 struct sm_state *sm;
612 struct expression *arg;
613 char *name;
614
615 arg = get_argument_from_call_expr(expr->args, 0);
616 name = expr_to_str(arg);
617
618 sm = get_sm_state_expr(SMATCH_EXTRA, arg);
619 if (!sm) {
620 sm_msg("no sm state for '%s'", name);
621 goto free;
622 }
623
624 sm_prefix();
625 sm_printf("merge tree: %s -> %s", name, sm->state->name);
626 print_left_right(sm);
627 sm_printf("\n");
628
629 free:
630 free_string(name);
631 }
632
633 static void match_print_stree_id(const char *fn, struct expression *expr, void *info)
634 {
635 sm_msg("stree_id %d", __stree_id);
636 }
637
638 static void match_mtag(const char *fn, struct expression *expr, void *info)
639 {
640 struct expression *arg;
641 char *name;
642 mtag_t tag = 0;
643 int offset = 0;
644
645 arg = get_argument_from_call_expr(expr->args, 0);
646 name = expr_to_str(arg);
647 expr_to_mtag_offset(arg, &tag, &offset);
648 sm_msg("mtag: '%s' => tag: %llu %d", name, tag, offset);
649 free_string(name);
650 }
651
652 static void match_mtag_data_offset(const char *fn, struct expression *expr, void *info)
653 {
654 struct expression *arg;
655 char *name;
656 mtag_t tag = 0;
657 int offset = -1;
658
659 arg = get_argument_from_call_expr(expr->args, 0);
660 name = expr_to_str(arg);
661 expr_to_mtag_offset(arg, &tag, &offset);
662 sm_msg("mtag: '%s' => tag: %lld, offset: %d", name, tag, offset);
663 free_string(name);
664 }
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
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;
710 if (__inline_fn)
711 return;
712
713 FOR_EACH_SM(__get_cur_stree(), sm) {
714 if (strcmp(sm->name, trace_variable) != 0)
715 continue;
716 old = get_sm_state_stree(old_stree, sm->owner, sm->name, sm->sym);
717 if (old && old->state == sm->state)
718 continue;
719 sm_msg("[%d] %s '%s': '%s' => '%s'", stmt->type,
720 check_name(sm->owner),
721 sm->name, old ? old->state->name : "<none>", sm->state->name);
722 printed = 1;
723 } END_FOR_EACH_SM(sm);
724
725 if (printed) {
726 free_stree(&old_stree);
727 old_stree = clone_stree(__get_cur_stree());
728 }
729 }
730
731 static void free_old_stree(struct symbol *sym)
732 {
733 free_stree(&old_stree);
734 }
735
736 void check_debug(int id)
737 {
738 my_id = id;
739 add_function_hook("__smatch_about", &match_about, NULL);
740 add_function_hook("__smatch_all_values", &match_all_values, NULL);
741 add_function_hook("__smatch_state", &match_state, NULL);
742 add_function_hook("__smatch_states", &match_states, NULL);
743 add_function_hook("__smatch_value", &match_print_value, NULL);
744 add_function_hook("__smatch_known", &match_print_known, NULL);
745 add_function_hook("__smatch_implied", &match_print_implied, NULL);
746 add_function_hook("__smatch_implied_min", &match_print_implied_min, NULL);
747 add_function_hook("__smatch_implied_max", &match_print_implied_max, NULL);
748 add_function_hook("__smatch_user_rl", &match_user_rl, NULL);
749 add_function_hook("__smatch_capped", &match_capped, NULL);
750 add_function_hook("__smatch_hard_max", &match_print_hard_max, NULL);
751 add_function_hook("__smatch_fuzzy_max", &match_print_fuzzy_max, NULL);
752 add_function_hook("__smatch_absolute", &match_print_absolute, NULL);
753 add_function_hook("__smatch_absolute_min", &match_print_absolute_min, NULL);
754 add_function_hook("__smatch_absolute_max", &match_print_absolute_max, NULL);
755 add_function_hook("__smatch_real_absolute", &match_real_absolute, NULL);
756 add_function_hook("__smatch_sval_info", &match_sval_info, NULL);
757 add_function_hook("__smatch_member_name", &match_member_name, NULL);
758 add_function_hook("__smatch_possible", &match_possible, NULL);
759 add_function_hook("__smatch_cur_stree", &match_cur_stree, NULL);
760 add_function_hook("__smatch_strlen", &match_strlen, NULL);
761 add_function_hook("__smatch_buf_size", &match_buf_size, NULL);
762 add_function_hook("__smatch_note", &match_note, NULL);
763 add_function_hook("__smatch_dump_related", &match_dump_related, NULL);
764 add_function_hook("__smatch_compare", &match_compare, NULL);
765 add_function_hook("__smatch_debug_on", &match_debug_on, NULL);
766 add_function_hook("__smatch_debug_check", &match_debug_check, NULL);
767 add_function_hook("__smatch_debug_off", &match_debug_off, NULL);
768 add_function_hook("__smatch_local_debug_on", &match_local_debug_on, NULL);
769 add_function_hook("__smatch_local_debug_off", &match_local_debug_off, NULL);
770 add_function_hook("__smatch_intersection", &match_intersection, NULL);
771 add_function_hook("__smatch_type", &match_type, NULL);
772 add_implied_return_hook("__smatch_type_rl_helper", &match_type_rl_return, NULL);
773 add_function_hook("__smatch_merge_tree", &match_print_merge_tree, NULL);
774 add_function_hook("__smatch_stree_id", &match_print_stree_id, NULL);
775 add_function_hook("__smatch_mtag", &match_mtag, NULL);
776 add_function_hook("__smatch_mtag_data", &match_mtag_data_offset, NULL);
777 add_function_hook("__smatch_state_count", &match_state_count, NULL);
778 add_function_hook("__smatch_mem", &match_mem, NULL);
779 add_function_hook("__smatch_exit", &match_exit, NULL);
780 add_function_hook("__smatch_container", &match_container, NULL);
781
782 add_hook(free_old_stree, AFTER_FUNC_HOOK);
783 add_hook(trace_var, STMT_HOOK_AFTER);
784 }