From patchwork Mon Jun 9 02:16:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 4317441 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4A84A9F357 for ; Mon, 9 Jun 2014 02:17:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 617912015E for ; Mon, 9 Jun 2014 02:17:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 83E242015D for ; Mon, 9 Jun 2014 02:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754349AbaFICRw (ORCPT ); Sun, 8 Jun 2014 22:17:52 -0400 Received: from smtp.mei.co.jp ([133.183.100.20]:53939 "EHLO smtp.mei.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754268AbaFICRv (ORCPT ); Sun, 8 Jun 2014 22:17:51 -0400 Received: from mail-gw.jp.panasonic.com ([157.8.1.157]) by smtp.mei.co.jp (8.12.11.20060614/3.7W/kc-maile13) with ESMTP id s592Hnte006687; Mon, 9 Jun 2014 11:17:49 +0900 (JST) Received: from epochmail.jp.panasonic.com ([157.8.1.130]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili11) with ESMTP id s592HnR31395; Mon, 9 Jun 2014 11:17:49 +0900 Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi12) id s592Hnca008373; Mon, 9 Jun 2014 11:17:49 +0900 Received: from poodle by lomi12.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id s592Hnfk008315; Mon, 9 Jun 2014 11:17:49 +0900 Received: from beagle.diag.org (beagle.diag.org [10.184.179.16]) by poodle (Postfix) with ESMTP id 1A7E82743A5D; Mon, 9 Jun 2014 11:17:49 +0900 (JST) From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Jason Cooper , Masahiro Yamada Subject: [PATCH v2 4/7] scripts: objdiff: improve path flexibility for record command Date: Mon, 9 Jun 2014 11:16:37 +0900 Message-Id: <1402280200-21834-5-git-send-email-yamada.m@jp.panasonic.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1402280200-21834-1-git-send-email-yamada.m@jp.panasonic.com> References: <1402280200-21834-1-git-send-email-yamada.m@jp.panasonic.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Prior to this commit, scripts/objdiff expected to be run at the top directory and only the relative path of objects. This commit provides more flexibility in terms of object path: [1] scripts/objdiff can be run in any directory For example, $ scripts/objdiff record init/main.o and $ cd init; ../scripts/objdiff record main.o produce the same result. [2] Support absolute path for objects $ scripts/objdiff record /home/foo/bar/linux/init/main.o work as well. Signed-off-by: Masahiro Yamada Cc: Jason Cooper Acked-by: Jason Cooper --- Changes in v2: - Fix a typo in commit description: s/reltive/relative/ scripts/objdiff | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/scripts/objdiff b/scripts/objdiff index 6e72f96..499eb4b 100755 --- a/scripts/objdiff +++ b/scripts/objdiff @@ -25,7 +25,7 @@ # # Note: 'make mrproper' will also remove .tmp_objdiff -SRCTREE=$(git rev-parse --show-toplevel 2>/dev/null) +SRCTREE=$(cd $(git rev-parse --show-toplevel 2>/dev/null); pwd) if [ -z "$SRCTREE" ]; then echo >&2 "ERROR: Not a git repository." @@ -42,6 +42,18 @@ usage() { exit 1 } +get_output_dir() { + dir=${1%/*} + + if [ "$dir" = "$1" ]; then + dir=. + fi + + dir=$(cd $dir; pwd) + + echo $TMPD/$CMT${dir#$SRCTREE} +} + dorecord() { [ $# -eq 0 ] && usage @@ -50,18 +62,16 @@ dorecord() { CMT="`git rev-parse --short HEAD`" OBJDUMP="${CROSS_COMPILE}objdump" - OBJDIFFD="$TMPD/$CMT" for f in $FILES; do - dn="${f%/*}" + dir=$(get_output_dir $f) bn="${f##*/}" - [ ! -d "$OBJDIFFD/$dn" ] && mkdir -p "$OBJDIFFD/$dn" + [ ! -d "$dir" ] && mkdir -p $dir # remove addresses for a more clear diff # http://dummdida.tumblr.com/post/60924060451/binary-diff-between-libc-from-scientificlinux-and - $OBJDUMP -D "$f" | sed "s/^[[:space:]]\+[0-9a-f]\+//" \ - >"$OBJDIFFD/$dn/$bn" + $OBJDUMP -D $f | sed "s/^[[:space:]]\+[0-9a-f]\+//" > $dir/$bn done }