From patchwork Fri Sep 4 01:25:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amerigo Wang X-Patchwork-Id: 45467 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n841RJtd001502 for ; Fri, 4 Sep 2009 01:27:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756202AbZIDB0l (ORCPT ); Thu, 3 Sep 2009 21:26:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756122AbZIDB0l (ORCPT ); Thu, 3 Sep 2009 21:26:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47866 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756093AbZIDB0k (ORCPT ); Thu, 3 Sep 2009 21:26:40 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n841Q1uh027365; Thu, 3 Sep 2009 21:26:01 -0400 Received: from localhost.localdomain (dhcp-65-141.nay.redhat.com [10.66.65.141]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n841Px8b013256; Thu, 3 Sep 2009 21:26:00 -0400 Date: Thu, 3 Sep 2009 21:25:59 -0400 From: Amerigo Wang To: linux-kernel@vger.kernel.org Cc: Peter Oberparleiter , akpm@linux-foundation.org, linux-kbuild@vger.kernel.org, Amerigo Wang , Sam Ravnborg Message-Id: <20090904012827.3749.82833.sendpatchset@localhost.localdomain> In-Reply-To: <20090904012755.3749.69645.sendpatchset@localhost.localdomain> References: <20090904012755.3749.69645.sendpatchset@localhost.localdomain> Subject: [Patch 4/5] scripts: add gen_gcov.sh X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Add scripts/gen_gcov.sh which will be used by the later patch. It is used to generate .gcov file from .c file. Signed-off-by: WANG Cong --- -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/scripts/gen_gcov.sh =================================================================== --- /dev/null +++ linux-2.6/scripts/gen_gcov.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# WANG Cong +# GPLv2 applies. + +GCOV_BASE=/sys/kernel/debug/gcov$(readlink /lib/modules/`uname -r`/build) +target="" +trap "rm -f *.gcov" INT + +function usage() +{ + echo "$0 [GCOV_BASE_DIR] target_file.c" + echo "The default directory is: /sys/kernel/debug/gcov/path/to/compile." +} + +if [ $# -eq 2 ]; +then + GCOV_BASE="$1" + target="$2" +elif [ $# -eq 1 ]; +then + target="$1" + if [ ! -d "$GCOV_BASE" ]; + then + echo "You have to provide the base directory for gcov." >&2 + exit 1 + fi +else + usage + exit 1 +fi + +if [ ! -f "$target" ]; +then + echo "File $target doesn't exist.\n" 1>&2 + exit 1 +fi + +target_base_name=$(basename "$target") +target_dir_name=$(dirname "$target") + +${GCOV} -o "$GCOV_BASE/$target_dir_name" "$target_base_name" +if [ -f "${target_base_name}.gcov" ]; +then + mv *.gcov "$target_dir_name" + exit 0 +else + exit 1 +fi +