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; +}