# HG changeset patch # User Thinker K.F. Li # Date 1283939189 -28800 # Node ID 8855f7d934aedd488b5e2ba29b843a6184412ec2 # Parent 92347d3a3bf346184c49d9d32cbe6f4de7d47826 Get name of functions before exceuting all_passes diff -r 92347d3a3bf3 -r 8855f7d934ae src/Makefile --- a/src/Makefile Tue Sep 07 10:07:19 2010 +0800 +++ b/src/Makefile Wed Sep 08 17:46:29 2010 +0800 @@ -2,7 +2,7 @@ PLUGIN_SOURCE_FILES= cospy.c PLUGIN_OBJECT_FILES= $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES)) GCCPLUGINS_DIR:= $(shell $(GCC) -print-file-name=plugin) -CFLAGS+= -I$(GCCPLUGINS_DIR)/include -fPIC -O2 +CFLAGS:= -I$(GCCPLUGINS_DIR)/include -fPIC -O2 $(CFLAGS) all: cospy.so diff -r 92347d3a3bf3 -r 8855f7d934ae src/cospy.c --- a/src/cospy.c Tue Sep 07 10:07:19 2010 +0800 +++ b/src/cospy.c Wed Sep 08 17:46:29 2010 +0800 @@ -1,14 +1,34 @@ #include "gcc-plugin.h" #include "plugin-version.h" +#include "system.h" +#include "coretypes.h" +#include "tree-pass.h" +#include "tree.h" +#include "gimple.h" +#include "cgraph.h" #include int plugin_is_GPL_compatible; +static void +handle_all_passes(void *gcc_data, void *user_data) { + tree decl; + + decl = cfun->decl; + printf("decl %x\n", decl); + printf(" %s\n", current_function_name()); +} + int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { + struct cgraph_node_hook_list *hook; + if (!plugin_default_version_check (version, &gcc_version)) return 1; printf("Initialize plugin %s\n", plugin_info->base_name); + + register_callback(plugin_info->base_name, PLUGIN_ALL_PASSES_START, + handle_all_passes, NULL); return 0; } diff -r 92347d3a3bf3 -r 8855f7d934ae src/test.c --- a/src/test.c Tue Sep 07 10:07:19 2010 +0800 +++ b/src/test.c Wed Sep 08 17:46:29 2010 +0800 @@ -1,7 +1,11 @@ #include +int value(int a) { + return a + 1; +} + int main(int argc, const char *argv[]) { - printf("test\n"); + printf("test %d\n", value(12)); return 0; }