From e038f068b1d9f17ae538c7bc4d5d0421814b667f Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Sat, 28 Oct 2006 19:07:45 -0300 Subject: [PATCH] New dwarf: pfunct, see it in action: [acme@newtoy net-2.6]$ pfunct ~acme/work/atag/atag | grep LRMI void * LRMI_alloc_real(int size); void LRMI_free_real(void * m); int LRMI_init(void); void set_regs(struct LRMI_regs * r); void get_regs(struct LRMI_regs * r); int LRMI_call(struct LRMI_regs * r); int LRMI_int(int i, struct LRMI_regs * r); [acme@newtoy net-2.6]$ [acme@newtoy net-2.6]$ pfunct kernel/sched.o task_running int task_running(struct rq * rq, struct task_struct * p); [acme@newtoy net-2.6]$ Signed-off-by: Arnaldo Carvalho de Melo --- Makefile | 6 +++++- pfunct.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 pfunct.c diff --git a/Makefile b/Makefile index afda9a8..5a2df59 100644 --- a/Makefile +++ b/Makefile @@ -17,14 +17,18 @@ INSTALL = cp binprefix = PAHOLE_OBJECTS = pahole.o classes.o +PFUNCT_OBJECTS = pfunct.o classes.o -all: pahole +all: pahole pfunct default: $(TARGETS) pahole: $(PAHOLE_OBJECTS) $(CC) $(CFLAGS) -o $@ $(PAHOLE_OBJECTS) $(LDFLAGS) +pfunct: $(PFUNCT_OBJECTS) + $(CC) $(CFLAGS) -o $@ $(PFUNCT_OBJECTS) $(LDFLAGS) + install: all $(INSTALL) pahole $(bindir)/pahole diff --git a/pfunct.c b/pfunct.c new file mode 100644 index 0000000..767db7b --- /dev/null +++ b/pfunct.c @@ -0,0 +1,41 @@ +/* + Copyright (C) 2006 Mandriva Conectiva S.A. + Copyright (C) 2006 Arnaldo Carvalho de Melo + + This program is free software; you can redistribute it and/or modify it + under the terms of version 2 of the GNU General Public License as + published by the Free Software Foundation. +*/ + +#include +#include +#include + +#include "classes.h" + +int main(int argc, char *argv[]) +{ + if (argc == 0) { + puts("usage: " + "pfunct {}"); + return EXIT_FAILURE; + } + + if (classes__load(argv[1]) != 0) { + fprintf(stderr, "pfunct: couldn't load DWARF info from %s\n", + argv[1]); + return EXIT_FAILURE; + } + + if (argc == 2) + classes__print(DW_TAG_subprogram); + else { + struct class *class = classes__find_by_name(argv[2]); + if (class != NULL) + class__print(class); + else + printf("function %s not found!\n", argv[2]); + } + + return EXIT_SUCCESS; +}