From ae63b2d7bdd9bd66b88843be0daf8e37d8f0b574 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Thu, 6 Feb 2014 07:51:42 -0500 Subject: scripts/tags.sh: Ignore *.mod.c CONFIG_MODVERSIONS=y results in a .mod.c for every compiled file in the kernel. Issuing a 'make cscope' on a compiled kernel tree results in the cscope files containing *.mod.c files. [prarit@prarit linux]# make cscope [prarit@prarit linux]# cat cscope.files | grep mod.c | wc -l 4807 These files are not useful for cscope and should be ignored. For example, # line filename / context / line 1 105 arch/x86/kvm/kvm-intel.mod.c <> { 0x618911fc, __VMLINUX_SYMBOL_STR(numa_node) }, 2 508 drivers/block/mtip32xx/mtip32xx.h <> int numa_node; 3 55 drivers/block/mtip32xx/mtip32xx.mod.c <> { 0x618911fc, __VMLINUX_SYMBOL_STR(numa_node) }, 4 37 drivers/cpufreq/acpi-cpufreq.mod.c <> { 0x618911fc, __VMLINUX_SYMBOL_STR(numa_node) }, Add an export to RCS_FIND_IGNORE so it can be used in scripts/tags.sh and add explicitly ignore *.mod.c files. Signed-off-by: Prarit Bhargava Cc: Andrew Morton Cc: Kirill Tkhai Cc: Michael Opdenacker Cc: Rusty Russell Signed-off-by: Michal Marek --- scripts/tags.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/tags.sh b/scripts/tags.sh index 58c455929091..f2c5b006a3d7 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -11,11 +11,10 @@ if [ "$KBUILD_VERBOSE" = "1" ]; then set -x fi -# This is a duplicate of RCS_FIND_IGNORE without escaped '()' -ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \ - -name CVS -o -name .pc -o -name .hg -o \ - -name .git ) \ - -prune -o" +# RCS_FIND_IGNORE has escaped ()s -- remove them. +ignore="$(echo "$RCS_FIND_IGNORE" | sed 's|\\||g' )" +# tags and cscope files should also ignore MODVERSION *.mod.c files +ignore="$ignore ( -name *.mod.c ) -prune -o" # Do not use full path if we do not use O=.. builds # Use make O=. {tags|cscope} -- cgit v1.2.3 From 0a830dad5e3ceffc1f12f3e674322182d809e3a9 Mon Sep 17 00:00:00 2001 From: Peter Senna Tschudin Date: Tue, 18 Mar 2014 22:11:32 +0100 Subject: Coccicheck: Remove memcpy to struct assignment test The Coccinelle script scripts/coccinelle/misc/memcpy-assign.cocci look for opportunities to replace a call to memcpy by a struct assignment. This patch removes memcpy-assign.cocci as it is not clear that this convention has an impact on the generated code. Signed-off-by: Peter Senna Tschudin Signed-off-by: Michal Marek --- scripts/coccinelle/misc/memcpy-assign.cocci | 103 ---------------------------- 1 file changed, 103 deletions(-) delete mode 100644 scripts/coccinelle/misc/memcpy-assign.cocci (limited to 'scripts') diff --git a/scripts/coccinelle/misc/memcpy-assign.cocci b/scripts/coccinelle/misc/memcpy-assign.cocci deleted file mode 100644 index afd058be497f..000000000000 --- a/scripts/coccinelle/misc/memcpy-assign.cocci +++ /dev/null @@ -1,103 +0,0 @@ -// -// Replace memcpy with struct assignment. -// -// Confidence: High -// Copyright: (C) 2012 Peter Senna Tschudin, INRIA/LIP6. GPLv2. -// URL: http://coccinelle.lip6.fr/ -// Comments: -// Options: --no-includes --include-headers - -virtual patch -virtual report -virtual context -virtual org - -@r1 depends on !patch@ -identifier struct_name; -struct struct_name to; -struct struct_name from; -struct struct_name *top; -struct struct_name *fromp; -position p; -@@ -memcpy@p(\(&(to)\|top\), \(&(from)\|fromp\), \(sizeof(to)\|sizeof(from)\|sizeof(struct struct_name)\|sizeof(*top)\|sizeof(*fromp)\)) - -@script:python depends on report@ -p << r1.p; -@@ -coccilib.report.print_report(p[0],"Replace memcpy with struct assignment") - -@depends on context@ -position r1.p; -@@ -*memcpy@p(...); - -@script:python depends on org@ -p << r1.p; -@@ -cocci.print_main("Replace memcpy with struct assignment",p) - -@depends on patch@ -identifier struct_name; -struct struct_name to; -struct struct_name from; -@@ -( --memcpy(&(to), &(from), sizeof(to)); -+to = from; -| --memcpy(&(to), &(from), sizeof(from)); -+to = from; -| --memcpy(&(to), &(from), sizeof(struct struct_name)); -+to = from; -) - -@depends on patch@ -identifier struct_name; -struct struct_name to; -struct struct_name *from; -@@ -( --memcpy(&(to), from, sizeof(to)); -+to = *from; -| --memcpy(&(to), from, sizeof(*from)); -+to = *from; -| --memcpy(&(to), from, sizeof(struct struct_name)); -+to = *from; -) - -@depends on patch@ -identifier struct_name; -struct struct_name *to; -struct struct_name from; -@@ -( --memcpy(to, &(from), sizeof(*to)); -+ *to = from; -| --memcpy(to, &(from), sizeof(from)); -+ *to = from; -| --memcpy(to, &(from), sizeof(struct struct_name)); -+ *to = from; -) - -@depends on patch@ -identifier struct_name; -struct struct_name *to; -struct struct_name *from; -@@ -( --memcpy(to, from, sizeof(*to)); -+ *to = *from; -| --memcpy(to, from, sizeof(*from)); -+ *to = *from; -| --memcpy(to, from, sizeof(struct struct_name)); -+ *to = *from; -) - -- cgit v1.2.3 From 79192ca8ebd9a25c583aa46024a250fef1e7766f Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 7 Apr 2014 18:30:29 +0000 Subject: scripts: objdiff: detect object code changes between two commits 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. Temporary files (objdump output) are stored in /path/to/linux/.tmp_objdiff 'make mrproper' will remove this directory. Signed-off-by: Jason Cooper Signed-off-by: Michal Marek --- Makefile | 2 +- scripts/objdiff | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 1 deletion(-) create mode 100755 scripts/objdiff (limited to 'scripts') diff --git a/Makefile b/Makefile index 2acd9dde1339..c68c23fe31b9 100644 --- a/Makefile +++ b/Makefile @@ -1066,7 +1066,7 @@ CLEAN_DIRS += $(MODVERDIR) # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config usr/include include/generated \ - arch/*/include/generated + arch/*/include/generated .tmp_objdiff MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \ Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ signing_key.priv signing_key.x509 x509.genkey \ diff --git a/scripts/objdiff b/scripts/objdiff new file mode 100755 index 000000000000..b3e4f10bfc3e --- /dev/null +++ b/scripts/objdiff @@ -0,0 +1,141 @@ +#!/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 +# +# Note: 'make mrproper' will also remove .tmp_objdiff + +GIT_DIR="`git rev-parse --git-dir`" + +if [ -d "$GIT_DIR" ]; then + TMPD="${GIT_DIR%git}tmp_objdiff" + + [ -d "$TMPD" ] || mkdir "$TMPD" +else + echo "ERROR: git directory not found." + exit 1 +fi + +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="$TMPD/$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" + 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="$TMPD/$SRC" + DSTD="$TMPD/$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 $TMPD/* + else + CMT="`git rev-parse --short $1`" + + if [ -d "$TMPD/$CMT" ]; then + rm -rf $TMPD/$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 -- cgit v1.2.3 From 67554faa7614b93722ed559fc3f914b86bf606ae Mon Sep 17 00:00:00 2001 From: Fabian Frederick Date: Wed, 2 Apr 2014 21:39:52 +0200 Subject: scripts/bootgraph.pl: Add graphic header Adding -header + help function like other .pl in /scripts. Signed-off-by: Fabian Frederick Signed-off-by: Michal Marek --- scripts/bootgraph.pl | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/bootgraph.pl b/scripts/bootgraph.pl index b78fca994a15..9ca667bcaee9 100644 --- a/scripts/bootgraph.pl +++ b/scripts/bootgraph.pl @@ -38,6 +38,31 @@ # use strict; +use Getopt::Long; +my $header = 0; + +sub help { + my $text = << "EOM"; +Usage: +1) dmesg | perl scripts/bootgraph.pl [OPTION] > output.svg +2) perl scripts/bootgraph.pl -h + +Options: + -header Insert kernel version and date +EOM + my $std=shift; + if ($std == 1) { + print STDERR $text; + } else { + print $text; + } + exit; +} + +GetOptions( + 'h|help' =>\&help, + 'header' =>\$header +); my %start; my %end; @@ -49,6 +74,11 @@ my $count = 0; my %pids; my %pidctr; +my $headerstep = 20; +my $xheader = 15; +my $yheader = 25; +my $cyheader = 0; + while (<>) { my $line = $_; if ($line =~ /([0-9\.]+)\] calling ([a-zA-Z0-9\_\.]+)\+/) { @@ -112,15 +142,23 @@ if ($count == 0) { print STDERR < output.svg END + help(1); exit 1; } print " \n"; print "\n"; + +if ($header) { + my $version = `uname -a`; + my $date = `date`; + print "Kernel version: $version\n"; + $cyheader = $yheader+$headerstep; + print "Date: $date\n"; +} + my @styles; $styles[0] = "fill:rgb(0,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; -- cgit v1.2.3 From f23a9fa7e81f7df65e0bcf586e028a2db736b9e6 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 27 Jan 2014 12:21:22 +0530 Subject: scripts/coccinelle: Use PTR_ERR_OR_ZERO PTR_RET is deprecated. Do not recommend its usage anymore. Use PTR_ERR_OR_ZERO instead. Signed-off-by: Sachin Kamat Signed-off-by: Michal Marek --- scripts/coccinelle/api/ptr_ret.cocci | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci index e18f8402e37c..dd58dab5d411 100644 --- a/scripts/coccinelle/api/ptr_ret.cocci +++ b/scripts/coccinelle/api/ptr_ret.cocci @@ -7,7 +7,7 @@ // URL: http://coccinelle.lip6.fr/ // Options: --no-includes --include-headers // -// Keywords: ERR_PTR, PTR_ERR, PTR_RET, PTR_ERR_OR_ZERO +// Keywords: ERR_PTR, PTR_ERR, PTR_ERR_OR_ZERO // Version min: 2.6.39 // @@ -62,35 +62,35 @@ position p3; p << r1.p1; @@ -coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") +coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used") @script:python depends on org@ p << r2.p2; @@ -coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") +coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used") @script:python depends on org@ p << r3.p3; @@ -coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used") +coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used") @script:python depends on report@ p << r1.p1; @@ -coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") +coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used") @script:python depends on report@ p << r2.p2; @@ -coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") +coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used") @script:python depends on report@ p << r3.p3; @@ -coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used") +coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used") -- cgit v1.2.3