From owner-freebsd-arch@FreeBSD.ORG Thu Sep 6 04:00:36 2012 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E4213106566B; Thu, 6 Sep 2012 04:00:36 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) by mx1.freebsd.org (Postfix) with ESMTP id 9F5368FC12; Thu, 6 Sep 2012 04:00:36 +0000 (UTC) Received: from JRE-MBP-2.local (ppp121-45-230-94.lns20.per1.internode.on.net [121.45.230.94]) (authenticated bits=0) by vps1.elischer.org (8.14.5/8.14.5) with ESMTP id q8640Rwx076704 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 5 Sep 2012 21:00:29 -0700 (PDT) (envelope-from julian@freebsd.org) Message-ID: <50481FD5.2090802@freebsd.org> Date: Thu, 06 Sep 2012 12:00:21 +0800 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:15.0) Gecko/20120824 Thunderbird/15.0 MIME-Version: 1.0 To: Jonathan Anderson References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-arch@freebsd.org Subject: Re: Call graphs with bsd.obj.mk X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2012 04:00:37 -0000 On 9/5/12 11:28 PM, Jonathan Anderson 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? can you put a sample output file up somewhere? (.png or something?) > > Jon > > > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"