Date: Wed, 5 Sep 2012 16:54:09 -0400 From: George Neville-Neil <gnn@neville-neil.com> To: Jonathan Anderson <jonathan@FreeBSD.org> Cc: freebsd-arch@freebsd.org Subject: Re: Call graphs with bsd.obj.mk Message-ID: <1135E0EA-319C-4AB9-B282-59CDEA9020C8@neville-neil.com> In-Reply-To: <CAMGEAwCNuF-P80XgsMBm1a=vSPBhB_GNw%2Bqw5ZUmPXRC2NrsGQ@mail.gmail.com> References: <CAMGEAwCNuF-P80XgsMBm1a=vSPBhB_GNw%2Bqw5ZUmPXRC2NrsGQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sep 5, 2012, at 11:28 , Jonathan Anderson <jonathan@FreeBSD.org> wrote: > Hi all, > > While doing some hacking recently, I really wanted a call graph. Clang > and LLVM make this pretty easy, assuming you have the right CFLAGS, so > a little build system integration seemed to be in order. I did this, > it's pretty small and modular, and I find it useful, so I'm sharing > this work with the list in the hope of putting it into -CURRENT. > > I've attached two BSD makefiles that let me produce call graphs from > any directory that includes bsd.obj.mk (which notably includes > binaries and libraries in src): > > - bsd.analysis.mk contains a 'callgraph' target that produces > ${.OBJDIR}/_callgraph_.dot > - bsd.llvm.mk contains a few LLVM helpers (e.g. to generate LLVM IR) > > If you have clang, llvm-link and opt installed, this allows you to > generate a complete call graph for C code; assembler files are ignored > because we don't currently have assembly -> IR transformations. The > resulting graph can be pretty large and ugly (e.g. LLVM shows an > "external node" pseudo-function that calls everything), but it can be > filtered with scripts like those found at > https://github.com/trombonehero/dot-tools to produce really useful > graphs. > > llvm-link and opt aren't included in the bootstrap tools, so I'm > currently doing this by installing the llvm-devel package. Perhaps we > might copy llvm-link and opt over to /usr/obj/usr/src/tmp, possibly > governed by a WITH_LLVM_TOOLS flag in src.conf or something? > This would be great to have in the tree as a real build target. Best, George
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1135E0EA-319C-4AB9-B282-59CDEA9020C8>