Mercurial > cospy
changeset 8:5502f175d348
Show functions being called
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 08 Sep 2010 22:16:25 +0800 |
parents | 7fec19e27411 |
children | 958c2366e682 |
files | src/cospy.c src/test.c |
diffstat | 2 files changed, 29 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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) {