Re: [PATCH V2] scripts: objdiff: detect object code changes between two commits

2014-03-29 Thread Michal Marek
Dne 24.3.2014 03:14, Jason Cooper napsal(a):
> 
> objdiff can be used in conjunction with a git rebase to confirm that
> each commit made no changes to the resulting object code.  It has the
> same return values as diff(1).

This looks nice. Just a few comments below:


> +# usage example:
> +#
> +# $ git checkout COMMIT_A
> +# $ 
> +# $ ./scripts/objdiff record path/to/*.o
> +#
> +# $ git checkout COMMIT_B
> +# $ 
> +# $ ./scripts/objdiff record path/to/*.o
> +#
> +# $ ./scripts/objdiff diff COMMIT_A COMMIT_B
> +# $
> +
> +# And to clean up (everything is in /tmp/objdiff-*)
> +# $ ./scripts/objdiff clean all

Can you change it to use some path in the source tree, like .tmp_objdiff
or so? Then you can have make distclean remove it and you can avoid the
fixed paths in /tmp.


> + # force rebuild
> + rm -f "$f"

Is this working around some kbuild bug, or is it more a "just in case?"
One usually assumes that "record" is a readonly operation and can be
repeated.

Thanks,
Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2] scripts: objdiff: detect object code changes between two commits

2014-03-29 Thread Michal Marek
Dne 24.3.2014 03:14, Jason Cooper napsal(a):
 
 objdiff can be used in conjunction with a git rebase to confirm that
 each commit made no changes to the resulting object code.  It has the
 same return values as diff(1).

This looks nice. Just a few comments below:


 +# usage example:
 +#
 +# $ git checkout COMMIT_A
 +# $ your fancy build command here
 +# $ ./scripts/objdiff record path/to/*.o
 +#
 +# $ git checkout COMMIT_B
 +# $ your fancy build command here
 +# $ ./scripts/objdiff record path/to/*.o
 +#
 +# $ ./scripts/objdiff diff COMMIT_A COMMIT_B
 +# $
 +
 +# And to clean up (everything is in /tmp/objdiff-*)
 +# $ ./scripts/objdiff clean all

Can you change it to use some path in the source tree, like .tmp_objdiff
or so? Then you can have make distclean remove it and you can avoid the
fixed paths in /tmp.


 + # force rebuild
 + rm -f $f

Is this working around some kbuild bug, or is it more a just in case?
One usually assumes that record is a readonly operation and can be
repeated.

Thanks,
Michal
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2] scripts: objdiff: detect object code changes between two commits

2014-03-23 Thread Jason Cooper
objdiff is useful when doing large code cleanups.  For example, when
removing checkpatch warnings and errors from new drivers in the staging
tree.

objdiff can be used in conjunction with a git rebase to confirm that
each commit made no changes to the resulting object code.  It has the
same return values as diff(1).

This was written specifically to support adding the skein and threefish
cryto drivers to the staging tree.  I needed a programmatic way to
confirm that commits changing >90% of the lines didn't inadvertently
change the code.

Signed-off-by: Jason Cooper 
---
Changes from RFC:

 - separated from staging/skein series

 - assume 'HEAD^ HEAD' for 'objdiff diff' w/o args.

Original submission here:

  
https://lkml.kernel.org/r/cc773270b6481ffe69516d994fbe98c13bcfdb5a.1394570067.git.ja...@lakedaemon.net

Example usage here:

  https://lkml.kernel.org/r/20140312165501.gc7...@titan.lakedaemon.net

thx,

Jason.

 scripts/objdiff | 131 
 1 file changed, 131 insertions(+)
 create mode 100755 scripts/objdiff

diff --git a/scripts/objdiff b/scripts/objdiff
new file mode 100755
index ..c5d22b1814ba
--- /dev/null
+++ b/scripts/objdiff
@@ -0,0 +1,131 @@
+#!/bin/bash
+
+# objdiff - a small script for validating that a commit or series of commits
+# didn't change object code.
+#
+# Copyright 2014, Jason Cooper 
+#
+# Licensed under the terms of the GNU GPL version 2
+
+# usage example:
+#
+# $ git checkout COMMIT_A
+# $ 
+# $ ./scripts/objdiff record path/to/*.o
+#
+# $ git checkout COMMIT_B
+# $ 
+# $ ./scripts/objdiff record path/to/*.o
+#
+# $ ./scripts/objdiff diff COMMIT_A COMMIT_B
+# $
+
+# And to clean up (everything is in /tmp/objdiff-*)
+# $ ./scripts/objdiff clean all
+
+usage() {
+   echo "Usage: $0  "
+   echo "  record"
+   echo "  diff   "
+   echo "  clean all | "
+   exit 1
+}
+
+dorecord() {
+   [ $# -eq 0 ] && usage
+
+   FILES="$*"
+
+   CMT="`git rev-parse --short HEAD`"
+
+   OBJDUMP="${CROSS_COMPILE}objdump"
+   OBJDIFFD="/tmp/objdiff-$CMT"
+
+   [ ! -d "$OBJDIFFD" ] && mkdir -p "$OBJDIFFD"
+
+   for f in $FILES; do
+   dn="${f%/*}"
+   bn="${f##*/}"
+
+   [ ! -d "$OBJDIFFD/$dn" ] && mkdir -p "$OBJDIFFD/$dn"
+
+   # 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"
+
+   # force rebuild
+   rm -f "$f"
+   done
+}
+
+dodiff() {
+   [ $# -ne 2 ] && [ $# -ne 0 ] && usage
+
+   if [ $# -eq 0 ]; then
+   SRC="`git rev-parse --short HEAD^`"
+   DST="`git rev-parse --short HEAD`"
+   else
+   SRC="`git rev-parse --short $1`"
+   DST="`git rev-parse --short $2`"
+   fi
+
+   DIFF="`which colordiff`"
+
+   if [ ${#DIFF} -eq 0 ] || [ ! -x "$DIFF" ]; then
+   DIFF="`which diff`"
+   fi
+
+   SRCD="/tmp/objdiff-$SRC"
+   DSTD="/tmp/objdiff-$DST"
+
+   if [ ! -d "$SRCD" ]; then
+   echo "ERROR: $SRCD doesn't exist"
+   exit 1
+   fi
+
+   if [ ! -d "$DSTD" ]; then
+   echo "ERROR: $DSTD doesn't exist"
+   exit 1
+   fi
+
+   $DIFF -Nurd $SRCD $DSTD
+}
+
+doclean() {
+   [ $# -eq 0 ] && usage
+   [ $# -gt 1 ] && usage
+
+   if [ "x$1" = "xall" ]; then
+   rm -rf /tmp/objdiff-*
+   else
+   CMT="`git rev-parse --short $1`"
+
+   if [ -d "/tmp/objdiff-$CMT" ]; then
+   rm -rf /tmp/objdiff-$CMT
+   else
+   echo "$CMT not found"
+   fi
+   fi
+}
+
+[ $# -eq 0 ] &&usage
+
+case "$1" in
+   record)
+   shift
+   dorecord $*
+   ;;
+   diff)
+   shift
+   dodiff $*
+   ;;
+   clean)
+   shift
+   doclean $*
+   ;;
+   *)
+   echo "Unrecognized command '$1'"
+   exit 1
+   ;;
+esac
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2] scripts: objdiff: detect object code changes between two commits

2014-03-23 Thread Jason Cooper
objdiff is useful when doing large code cleanups.  For example, when
removing checkpatch warnings and errors from new drivers in the staging
tree.

objdiff can be used in conjunction with a git rebase to confirm that
each commit made no changes to the resulting object code.  It has the
same return values as diff(1).

This was written specifically to support adding the skein and threefish
cryto drivers to the staging tree.  I needed a programmatic way to
confirm that commits changing 90% of the lines didn't inadvertently
change the code.

Signed-off-by: Jason Cooper ja...@lakedaemon.net
---
Changes from RFC:

 - separated from staging/skein series

 - assume 'HEAD^ HEAD' for 'objdiff diff' w/o args.

Original submission here:

  
https://lkml.kernel.org/r/cc773270b6481ffe69516d994fbe98c13bcfdb5a.1394570067.git.ja...@lakedaemon.net

Example usage here:

  https://lkml.kernel.org/r/20140312165501.gc7...@titan.lakedaemon.net

thx,

Jason.

 scripts/objdiff | 131 
 1 file changed, 131 insertions(+)
 create mode 100755 scripts/objdiff

diff --git a/scripts/objdiff b/scripts/objdiff
new file mode 100755
index ..c5d22b1814ba
--- /dev/null
+++ b/scripts/objdiff
@@ -0,0 +1,131 @@
+#!/bin/bash
+
+# objdiff - a small script for validating that a commit or series of commits
+# didn't change object code.
+#
+# Copyright 2014, Jason Cooper ja...@lakedaemon.net
+#
+# Licensed under the terms of the GNU GPL version 2
+
+# usage example:
+#
+# $ git checkout COMMIT_A
+# $ your fancy build command here
+# $ ./scripts/objdiff record path/to/*.o
+#
+# $ git checkout COMMIT_B
+# $ your fancy build command here
+# $ ./scripts/objdiff record path/to/*.o
+#
+# $ ./scripts/objdiff diff COMMIT_A COMMIT_B
+# $
+
+# And to clean up (everything is in /tmp/objdiff-*)
+# $ ./scripts/objdiff clean all
+
+usage() {
+   echo Usage: $0 command args
+   echo   recordlist of object files
+   echo   diff  commitA commitB
+   echo   clean all | commit
+   exit 1
+}
+
+dorecord() {
+   [ $# -eq 0 ]  usage
+
+   FILES=$*
+
+   CMT=`git rev-parse --short HEAD`
+
+   OBJDUMP=${CROSS_COMPILE}objdump
+   OBJDIFFD=/tmp/objdiff-$CMT
+
+   [ ! -d $OBJDIFFD ]  mkdir -p $OBJDIFFD
+
+   for f in $FILES; do
+   dn=${f%/*}
+   bn=${f##*/}
+
+   [ ! -d $OBJDIFFD/$dn ]  mkdir -p $OBJDIFFD/$dn
+
+   # 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
+
+   # force rebuild
+   rm -f $f
+   done
+}
+
+dodiff() {
+   [ $# -ne 2 ]  [ $# -ne 0 ]  usage
+
+   if [ $# -eq 0 ]; then
+   SRC=`git rev-parse --short HEAD^`
+   DST=`git rev-parse --short HEAD`
+   else
+   SRC=`git rev-parse --short $1`
+   DST=`git rev-parse --short $2`
+   fi
+
+   DIFF=`which colordiff`
+
+   if [ ${#DIFF} -eq 0 ] || [ ! -x $DIFF ]; then
+   DIFF=`which diff`
+   fi
+
+   SRCD=/tmp/objdiff-$SRC
+   DSTD=/tmp/objdiff-$DST
+
+   if [ ! -d $SRCD ]; then
+   echo ERROR: $SRCD doesn't exist
+   exit 1
+   fi
+
+   if [ ! -d $DSTD ]; then
+   echo ERROR: $DSTD doesn't exist
+   exit 1
+   fi
+
+   $DIFF -Nurd $SRCD $DSTD
+}
+
+doclean() {
+   [ $# -eq 0 ]  usage
+   [ $# -gt 1 ]  usage
+
+   if [ x$1 = xall ]; then
+   rm -rf /tmp/objdiff-*
+   else
+   CMT=`git rev-parse --short $1`
+
+   if [ -d /tmp/objdiff-$CMT ]; then
+   rm -rf /tmp/objdiff-$CMT
+   else
+   echo $CMT not found
+   fi
+   fi
+}
+
+[ $# -eq 0 ] usage
+
+case $1 in
+   record)
+   shift
+   dorecord $*
+   ;;
+   diff)
+   shift
+   dodiff $*
+   ;;
+   clean)
+   shift
+   doclean $*
+   ;;
+   *)
+   echo Unrecognized command '$1'
+   exit 1
+   ;;
+esac
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/