All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amerigo Wang <amwang@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>,
	akpm@linux-foundation.org, linux-kbuild@vger.kernel.org,
	Amerigo Wang <amwang@redhat.com>, Sam Ravnborg <sam@ravnborg.org>
Subject: [Patch 4/5] scripts: add gen_gcov.sh
Date: Thu, 3 Sep 2009 21:25:59 -0400	[thread overview]
Message-ID: <20090904012827.3749.82833.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20090904012755.3749.69645.sendpatchset@localhost.localdomain>


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 <amwang@redhat.com>

---
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 <xiyou.wangcong@gmail.com>
+# 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
+

  parent reply	other threads:[~2009-09-04  1:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-04  1:25 [RFC Patch 0/5] gcov: integrate gcov into kbuild Amerigo Wang
2009-09-04  1:25 ` [Patch 1/5] gitignore: add .gcov files Amerigo Wang
2009-09-04  1:25 ` [Patch 2/5] Makefile: clean " Amerigo Wang
2009-09-04  1:25 ` [Patch 3/5] doc: move the scripts in gcov.txt to tools/gcov/ Amerigo Wang
2009-09-04  1:25 ` Amerigo Wang [this message]
2009-09-04  1:26 ` [Patch 5/5] Makefile: implement "make foo.c.gcov" Amerigo Wang
2009-09-07  8:24 ` [RFC Patch 0/5] gcov: integrate gcov into kbuild Peter Oberparleiter
2009-09-07  9:58   ` Amerigo Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090904012827.3749.82833.sendpatchset@localhost.localdomain \
    --to=amwang@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oberpar@linux.vnet.ibm.com \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.