static void test_on_ir_transformed(struct kedr_core_hooks *hooks, struct kedr_i13n *i13n, struct kedr_ifunc *func, struct list_head *ir) { struct kedr_ir_node *node; struct kedr_ir_node *start = NULL; if (strcmp(target_function, func->name) != 0) return; debug_util_print_string("IR:\n"); /* Print the entry nodes first (they do not belong to any group). */ list_for_each_entry(node, ir, list) { if (node->orig_addr != 0) break; print_ir_node(func, node, NULL); } /* Print the groups of nodes. */ list_for_each_entry(node, ir, list) { if (node->orig_addr == 0) continue; print_ir_node_group(func, node, &start); } }
/* IR printing functions */ void print_ir_list(FILE *out, IrList *irl) { fprintf(out, "\n/*\n"); fprintf(out, " *** Start IR List ***\n"); irl->cur = irl->head; while (irl->cur != NULL) { print_ir_node(out, irl->cur); irl->cur = irl->cur->next; } fprintf(out, " *** End IR List ***\n"); fprintf(out, " */\n"); }
/* Prints the group of nodes for a given reference node, i.e the nodes * from ref_node->first to ref_node->last. * Updates the pointer to the start of the current block ('*pstart'). */ static void print_ir_node_group(struct kedr_ifunc *func, struct kedr_ir_node *ref_node, struct kedr_ir_node **pstart) { struct list_head *pos; struct kedr_ir_node *node; if (ref_node->block_starts) { *pstart = ref_node; debug_util_print_ulong((unsigned long)ref_node->cb_type, "Block (type: %lu)"); debug_util_print_string("\n"); } for (pos = &ref_node->first->list; pos != ref_node->last->list.next; pos = pos->next) { node = list_entry(pos, struct kedr_ir_node, list); print_ir_node(func, node, *pstart); } }