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