From patchwork Mon May 16 15:35:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9103971 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 903A69F1C1 for ; Mon, 16 May 2016 15:43:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0387202B8 for ; Mon, 16 May 2016 15:43:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 063E420279 for ; Mon, 16 May 2016 15:43:38 +0000 (UTC) Received: from localhost ([::1]:44472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2KgD-0004l3-9A for patchwork-qemu-devel@patchwork.kernel.org; Mon, 16 May 2016 11:43:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2KZS-0001PI-I8 for qemu-devel@nongnu.org; Mon, 16 May 2016 11:36:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2KZJ-0006V4-Ek for qemu-devel@nongnu.org; Mon, 16 May 2016 11:36:38 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2KZI-0006Ur-Pu for qemu-devel@nongnu.org; Mon, 16 May 2016 11:36:29 -0400 Received: by mail-wm0-x241.google.com with SMTP id r12so18959946wme.0 for ; Mon, 16 May 2016 08:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=wOxn3PTgdnxmNimgbjYGYprTVSvxh8Iq4HK3ZbrQX+Y=; b=OOmbGXjK5w9QFuTATJWt5Nx8q7LvQFN5/1LACq5AN/MU8aWRaj9oFTnR5Krqo/o2aT iibvC5hNyDd1sFUecJsw8XcnoDxJVBIBLlSozxYEgZpc2DhANPmi5hEErOinH5PqybjE GLZC5gjGKQzDav5NWak7gQou2sw7C/fNs0NPGBOrQZFnyIiGupV43zeIjNtxatlzyO7R PLILftynKilMwp7PXCOuCgSqxDfAecaS1USq1Q0ovNwNnVJQtd5+oZOybemXSQm+oitm CGCVgX8BmU/oZz0/G4ATEoebBlglbMEYltK9FQywAikuYauOVl6afx/Xblctr+4yT1ok I4UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=wOxn3PTgdnxmNimgbjYGYprTVSvxh8Iq4HK3ZbrQX+Y=; b=G1ZXao1GJt5lp6oAyXZ+EQcNBmXxlXBxWMjcRU9WxN1jnFII8g6WULimPcsCxyNEfx 0buRIb+L/9HdZlCwop/wsNRO09SO84QEw9kendCyn0pT6GLYs2We2M75bg8Uarotbea4 Hw2QaAimyeKf0IOV/D2d40V8H3auCxx45d6CDYoKPQQ4+5nGNsTLp51gTBffnHtGFO1R 5pU7csFwbMRhPiOakmngvaKWiey/e6K6FQJzChj+O2DZ61fYCASRA9P+42X/d23uuvbM p0nYPMbubu6yvh9yt5aAt5hfng01M8SXegiRKeX/ZikizrXfZwiE1xBVjBSaTHpMnAuX Sldw== X-Gm-Message-State: AOPr4FWNdrnkr3d1cwT5fIC8JwfOR4K+49LuOw3MukDUnGX1nozMj8D68zACcUyEWK8bUw== X-Received: by 10.28.213.1 with SMTP id m1mr18705281wmg.103.1463412987701; Mon, 16 May 2016 08:36:27 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-252-58.clienti.tiscali.it. [78.12.252.58]) by smtp.gmail.com with ESMTPSA id lf9sm34386875wjc.44.2016.05.16.08.36.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 May 2016 08:36:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 May 2016 17:35:33 +0200 Message-Id: <1463412982-6681-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1463412982-6681-1-git-send-email-pbonzini@redhat.com> References: <1463412982-6681-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH 01/50] scripts: add script to build QEMU and analyze inclusions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Paolo Bonzini --- scripts/analyze-inclusions | 102 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 scripts/analyze-inclusions diff --git a/scripts/analyze-inclusions b/scripts/analyze-inclusions new file mode 100644 index 0000000..c64c023 --- /dev/null +++ b/scripts/analyze-inclusions @@ -0,0 +1,102 @@ +#! /bin/sh +# +# Copyright (C) 2016 Red Hat, Inc. +# +# Author: Paolo Bonzini +# +# Print statistics about header file inclusions. +# +# The script has two modes of execution: +# +# 1) if invoked with a path on the command line (possibly +# preceded by a "--" argument), it will run the analysis on +# an existing build directory +# +# 2) otherwise, it will configure and builds QEMU itself in a +# "+build" subdirectory which is left around when the script +# exits. In this case the command line is passed directly to +# "make" (typically used for a "-j" argument suitable for your +# system). +# +# Inspired by a post by Markus Armbruster. + +case "x$1" in +--) + shift + cd "$1" || exit $? + ;; +x-* | x) + mkdir -p +build + cd +build + test -f Makefile && make distclean + ../configure + make "$@" + ;; +*) + cd "$1" || exit $? +esac + +QEMU_CFLAGS=$(sed -n s/^QEMU_CFLAGS=//p config-host.mak) +QEMU_INCLUDES=$(sed -n s/^QEMU_INCLUDES=//p config-host.mak | \ + sed 's/$(SRC_PATH)/../g' ) +CFLAGS=$(sed -n s/^CFLAGS=//p config-host.mak) + +grep_include() { + find . -name "*.d" -exec grep -l "$@" {} + | wc -l +} + +echo Found $(find . -name "*.d" | wc -l) object files +echo $(grep_include -F 'include/qemu-common.h') files include qemu-common.h +echo $(grep_include -F 'hw/hw.h') files include hw/hw.h +echo $(grep_include 'target-[a-z0-9]*/cpu\.h') files include cpu.h +echo $(grep_include -F 'qapi-types.h') files include qapi-types.h +echo $(grep_include -F 'trace/generated-tracers.h') files include generated-tracers.h +echo $(grep_include -F 'qapi/error.h') files include qapi/error.h +echo $(grep_include -F 'qom/object.h') files include qom/object.h +echo $(grep_include -F 'block/aio.h') files include block/aio.h +echo $(grep_include -F 'exec/memory.h') files include exec/memory.h +echo $(grep_include -F 'fpu/softfloat.h') files include fpu/softfloat.h +echo $(grep_include -F 'qemu/bswap.h') files include qemu/bswap.h +echo + +awk1=' + /^# / { file = $3;next } + NR>1 { bytes[file]+=length()+1; lines[file]++ } + END { for(i in lines) print i,lines[i],bytes[i] }' + +awk2=' + {tot_l+=$2;tot_b+=$3;tot_f++} + /\/usr.*\/glib/ {glib_l+=$2;glib_b+=$3;glib_f++;next} + /\/usr/ {sys_l+=$2;sys_b+=$3;sys_f++;next} + {qemu_l+=$2;qemu_b+=$3;qemu_f++;next} + END { + printf "%s\t %s\t %s\t %s\n", "lines", "bytes", "files", "source" + printf "%s\t %s\t %s\t %s\n", qemu_l, qemu_b, qemu_f, "QEMU" + printf "%s\t %s\t %s\t %s\n", sys_l, sys_b, sys_f, "system" + printf "%s\t %s\t %s\t %s\n", glib_l, glib_b, glib_f, "glib" + printf "%s\t %s\t %s\t %s\n", tot_l, tot_b, tot_f, "total" + }' + +analyze() { + cc $QEMU_CFLAGS $QEMU_INCLUDES $CFLAGS -E -o - "$@" | \ + awk "$awk1" | awk "$awk2" + echo +} + +echo osdep.h: +analyze ../include/qemu/osdep.h + +echo qemu-common.h: +analyze -include ../include/qemu/osdep.h ../include/qemu-common.h + +echo hw/hw.h: +analyze -include ../include/qemu/osdep.h ../include/hw/hw.h + +echo trace/generated-tracers.h: +analyze -include ../include/qemu/osdep.h trace/generated-tracers.h + +echo target-i386/cpu.h: +analyze -DNEED_CPU_H -I../target-i386 -Ii386-softmmu -include ../include/qemu/osdep.h ../target-i386/cpu.h + +echo hw/hw.h + NEED_CPU_H: +analyze -DNEED_CPU_H -I../target-i386 -Ii386-softmmu -include ../include/qemu/osdep.h ../include/hw/hw.h