Solution -------- In this assignment we would understand the call graph (cgraph_node and cgraph_edge) structure in GCC. 1. The code to print the callers is explained below. /* Check if the node i.e. a function has callers */ if(node->callers) { /* Print the first caller */ fprintf (dump_file,"%s",cgraph_node_name(node->callers->caller)); /* Extract the next caller */ edge = node->callers->next_caller; /* Iterate over all the remaining callers */ while(edge) { fprintf (dump_file,"%s",cgraph_node_name(edge->caller)); edge = edge->next_caller; } } 2. Code to identify the `main' function is explained below. if (MAIN_NAME_P(DECL_NAME (node->decl))) { /* Main function is found */ }