# HG changeset patch # User Thinker K.F. Li # Date 1283955385 -28800 # Node ID 5502f175d3482b56ee1e545765c2e10cfac996a1 # Parent 7fec19e274118bb4fc14aac4565cc8106477bbfc Show functions being called diff -r 7fec19e27411 -r 5502f175d348 src/cospy.c --- a/src/cospy.c Wed Sep 08 21:35:16 2010 +0800 +++ b/src/cospy.c Wed Sep 08 22:16:25 2010 +0800 @@ -77,21 +77,46 @@ return type_str; } +/*! \brief Show functions that called by a specified function. + * + * \param cgn is cgraph_node of a function. + */ +static void +show_callees(struct cgraph_node *cgn) { + struct cgraph_edge *edge; + struct cgraph_node *callee_cgn; + tree callee, callee_name; + + /* Follow edges to called functions */ + edge = cgn->callees; + while(edge) { + callee_cgn = edge->callee; + callee = callee_cgn->decl; + callee_name = DECL_NAME(callee); + + printf(" call %s\n", IDENTIFIER_POINTER(callee_name)); + + edge = edge->next_callee; + } +} + static void handle_all_passes(void *gcc_data, void *user_data) { tree decl; tree fntype; tree arg, arg_name; tree arg_type; + struct cgraph_node *cgn; char *arg_type_str; function_args_iterator itr; decl = cfun->decl; - - printf("decl %x\n", decl); - printf(" %s:%d:%s\n", current_function_name(), + cgn = cgraph_node(decl); + + printf("%s:%d:%s\n", current_function_name(), DECL_SOURCE_LINE(decl), DECL_SOURCE_FILE(decl)); + show_callees(cgn); arg = DECL_ARGUMENTS(decl); while(arg) { diff -r 7fec19e27411 -r 5502f175d348 src/test.c --- a/src/test.c Wed Sep 08 21:35:16 2010 +0800 +++ b/src/test.c Wed Sep 08 22:16:25 2010 +0800 @@ -5,7 +5,7 @@ } int -main(int argc, const char * const argv[]) { +main(int argc, const char *argv[]) { printf("test %d\n", value(12)); return 0; }