diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/checkpatch.pl | 28 | ||||
| -rw-r--r-- | scripts/markup_oops.pl | 59 |
2 files changed, 70 insertions, 17 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7bed4ed2c519..45eb0ae98eba 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -10,7 +10,7 @@ use strict; | |||
| 10 | my $P = $0; | 10 | my $P = $0; |
| 11 | $P =~ s@.*/@@g; | 11 | $P =~ s@.*/@@g; |
| 12 | 12 | ||
| 13 | my $V = '0.26'; | 13 | my $V = '0.27'; |
| 14 | 14 | ||
| 15 | use Getopt::Long qw(:config no_auto_abbrev); | 15 | use Getopt::Long qw(:config no_auto_abbrev); |
| 16 | 16 | ||
| @@ -411,13 +411,15 @@ sub ctx_statement_block { | |||
| 411 | 411 | ||
| 412 | my $type = ''; | 412 | my $type = ''; |
| 413 | my $level = 0; | 413 | my $level = 0; |
| 414 | my @stack = ([$type, $level]); | 414 | my @stack = (); |
| 415 | my $p; | 415 | my $p; |
| 416 | my $c; | 416 | my $c; |
| 417 | my $len = 0; | 417 | my $len = 0; |
| 418 | 418 | ||
| 419 | my $remainder; | 419 | my $remainder; |
| 420 | while (1) { | 420 | while (1) { |
| 421 | @stack = (['', 0]) if ($#stack == -1); | ||
| 422 | |||
| 421 | #warn "CSB: blk<$blk> remain<$remain>\n"; | 423 | #warn "CSB: blk<$blk> remain<$remain>\n"; |
| 422 | # If we are about to drop off the end, pull in more | 424 | # If we are about to drop off the end, pull in more |
| 423 | # context. | 425 | # context. |
| @@ -1663,7 +1665,7 @@ sub process { | |||
| 1663 | # Should not end with a space. | 1665 | # Should not end with a space. |
| 1664 | $to =~ s/\s+$//; | 1666 | $to =~ s/\s+$//; |
| 1665 | # '*'s should not have spaces between. | 1667 | # '*'s should not have spaces between. |
| 1666 | while ($to =~ s/(.)\s\*/$1\*/) { | 1668 | while ($to =~ s/\*\s+\*/\*\*/) { |
| 1667 | } | 1669 | } |
| 1668 | 1670 | ||
| 1669 | #print "from<$from> to<$to>\n"; | 1671 | #print "from<$from> to<$to>\n"; |
| @@ -1678,7 +1680,7 @@ sub process { | |||
| 1678 | # Should not end with a space. | 1680 | # Should not end with a space. |
| 1679 | $to =~ s/\s+$//; | 1681 | $to =~ s/\s+$//; |
| 1680 | # '*'s should not have spaces between. | 1682 | # '*'s should not have spaces between. |
| 1681 | while ($to =~ s/(.)\s\*/$1\*/) { | 1683 | while ($to =~ s/\*\s+\*/\*\*/) { |
| 1682 | } | 1684 | } |
| 1683 | # Modifiers should have spaces. | 1685 | # Modifiers should have spaces. |
| 1684 | $to =~ s/(\b$Modifier$)/$1 /; | 1686 | $to =~ s/(\b$Modifier$)/$1 /; |
| @@ -2014,7 +2016,11 @@ sub process { | |||
| 2014 | 2016 | ||
| 2015 | # Flatten any parentheses | 2017 | # Flatten any parentheses |
| 2016 | $value =~ s/\)\(/\) \(/g; | 2018 | $value =~ s/\)\(/\) \(/g; |
| 2017 | while ($value !~ /(?:$Ident|-?$Constant)\s*$Compare\s*(?:$Ident|-?$Constant)/ && $value =~ s/\([^\(\)]*\)/1/) { | 2019 | while ($value =~ s/\[[^\{\}]*\]/1/ || |
| 2020 | $value !~ /(?:$Ident|-?$Constant)\s* | ||
| 2021 | $Compare\s* | ||
| 2022 | (?:$Ident|-?$Constant)/x && | ||
| 2023 | $value =~ s/\([^\(\)]*\)/1/) { | ||
| 2018 | } | 2024 | } |
| 2019 | 2025 | ||
| 2020 | if ($value =~ /^(?:$Ident|-?$Constant)$/) { | 2026 | if ($value =~ /^(?:$Ident|-?$Constant)$/) { |
| @@ -2102,6 +2108,11 @@ sub process { | |||
| 2102 | ERROR("trailing statements should be on next line\n" . $herecurr); | 2108 | ERROR("trailing statements should be on next line\n" . $herecurr); |
| 2103 | } | 2109 | } |
| 2104 | } | 2110 | } |
| 2111 | # if should not continue a brace | ||
| 2112 | if ($line =~ /}\s*if\b/) { | ||
| 2113 | ERROR("trailing statements should be on next line\n" . | ||
| 2114 | $herecurr); | ||
| 2115 | } | ||
| 2105 | # case and default should not have general statements after them | 2116 | # case and default should not have general statements after them |
| 2106 | if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g && | 2117 | if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g && |
| 2107 | $line !~ /\G(?: | 2118 | $line !~ /\G(?: |
| @@ -2516,9 +2527,10 @@ sub process { | |||
| 2516 | WARN("please use device_initcall() instead of __initcall()\n" . $herecurr); | 2527 | WARN("please use device_initcall() instead of __initcall()\n" . $herecurr); |
| 2517 | } | 2528 | } |
| 2518 | # check for struct file_operations, ensure they are const. | 2529 | # check for struct file_operations, ensure they are const. |
| 2519 | if ($line =~ /\bstruct\s+file_operations\b/ && | 2530 | if ($line !~ /\bconst\b/ && |
| 2520 | $line !~ /\bconst\b/) { | 2531 | $line =~ /\bstruct\s+(file_operations|seq_operations)\b/) { |
| 2521 | WARN("struct file_operations should normally be const\n" . $herecurr); | 2532 | WARN("struct $1 should normally be const\n" . |
| 2533 | $herecurr); | ||
| 2522 | } | 2534 | } |
| 2523 | 2535 | ||
| 2524 | # use of NR_CPUS is usually wrong | 2536 | # use of NR_CPUS is usually wrong |
diff --git a/scripts/markup_oops.pl b/scripts/markup_oops.pl index 700a7a654a3f..d40449cafa84 100644 --- a/scripts/markup_oops.pl +++ b/scripts/markup_oops.pl | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | #!/usr/bin/perl -w | 1 | #!/usr/bin/perl -w |
| 2 | 2 | ||
| 3 | use File::Basename; | ||
| 4 | |||
| 3 | # Copyright 2008, Intel Corporation | 5 | # Copyright 2008, Intel Corporation |
| 4 | # | 6 | # |
| 5 | # This file is part of the Linux kernel | 7 | # This file is part of the Linux kernel |
| @@ -13,23 +15,41 @@ | |||
| 13 | 15 | ||
| 14 | 16 | ||
| 15 | my $vmlinux_name = $ARGV[0]; | 17 | my $vmlinux_name = $ARGV[0]; |
| 16 | 18 | if (!defined($vmlinux_name)) { | |
| 19 | my $kerver = `uname -r`; | ||
| 20 | chomp($kerver); | ||
| 21 | $vmlinux_name = "/lib/modules/$kerver/build/vmlinux"; | ||
| 22 | print "No vmlinux specified, assuming $vmlinux_name\n"; | ||
| 23 | } | ||
| 24 | my $filename = $vmlinux_name; | ||
| 17 | # | 25 | # |
| 18 | # Step 1: Parse the oops to find the EIP value | 26 | # Step 1: Parse the oops to find the EIP value |
| 19 | # | 27 | # |
| 20 | 28 | ||
| 21 | my $target = "0"; | 29 | my $target = "0"; |
| 30 | my $function; | ||
| 31 | my $module = ""; | ||
| 32 | my $func_offset; | ||
| 33 | my $vmaoffset = 0; | ||
| 34 | |||
| 22 | while (<STDIN>) { | 35 | while (<STDIN>) { |
| 23 | if ($_ =~ /EIP: 0060:\[\<([a-z0-9]+)\>\]/) { | 36 | my $line = $_; |
| 37 | if ($line =~ /EIP: 0060:\[\<([a-z0-9]+)\>\]/) { | ||
| 24 | $target = $1; | 38 | $target = $1; |
| 25 | } | 39 | } |
| 26 | } | 40 | if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]/) { |
| 41 | $function = $1; | ||
| 42 | $func_offset = $2; | ||
| 43 | } | ||
| 27 | 44 | ||
| 28 | if ($target =~ /^f8/) { | 45 | # check if it's a module |
| 29 | print "This script does not work on modules ... \n"; | 46 | if ($line =~ /EIP is at ([a-zA-Z0-9\_]+)\+(0x[0-9a-f]+)\/0x[a-f0-9]+\W\[([a-zA-Z0-9\_\-]+)\]/) { |
| 30 | exit; | 47 | $module = $3; |
| 48 | } | ||
| 31 | } | 49 | } |
| 32 | 50 | ||
| 51 | my $decodestart = hex($target) - hex($func_offset); | ||
| 52 | my $decodestop = $decodestart + 8192; | ||
| 33 | if ($target eq "0") { | 53 | if ($target eq "0") { |
| 34 | print "No oops found!\n"; | 54 | print "No oops found!\n"; |
| 35 | print "Usage: \n"; | 55 | print "Usage: \n"; |
| @@ -37,6 +57,29 @@ if ($target eq "0") { | |||
| 37 | exit; | 57 | exit; |
| 38 | } | 58 | } |
| 39 | 59 | ||
| 60 | # if it's a module, we need to find the .ko file and calculate a load offset | ||
| 61 | if ($module ne "") { | ||
| 62 | my $dir = dirname($filename); | ||
| 63 | $dir = $dir . "/"; | ||
| 64 | my $mod = $module . ".ko"; | ||
| 65 | my $modulefile = `find $dir -name $mod | head -1`; | ||
| 66 | chomp($modulefile); | ||
| 67 | $filename = $modulefile; | ||
| 68 | if ($filename eq "") { | ||
| 69 | print "Module .ko file for $module not found. Aborting\n"; | ||
| 70 | exit; | ||
| 71 | } | ||
| 72 | # ok so we found the module, now we need to calculate the vma offset | ||
| 73 | open(FILE, "objdump -dS $filename |") || die "Cannot start objdump"; | ||
| 74 | while (<FILE>) { | ||
| 75 | if ($_ =~ /^([0-9a-f]+) \<$function\>\:/) { | ||
| 76 | my $fu = $1; | ||
| 77 | $vmaoffset = hex($target) - hex($fu) - hex($func_offset); | ||
| 78 | } | ||
| 79 | } | ||
| 80 | close(FILE); | ||
| 81 | } | ||
| 82 | |||
| 40 | my $counter = 0; | 83 | my $counter = 0; |
| 41 | my $state = 0; | 84 | my $state = 0; |
| 42 | my $center = 0; | 85 | my $center = 0; |
| @@ -59,9 +102,7 @@ sub InRange { | |||
| 59 | # first, parse the input into the lines array, but to keep size down, | 102 | # first, parse the input into the lines array, but to keep size down, |
| 60 | # we only do this for 4Kb around the sweet spot | 103 | # we only do this for 4Kb around the sweet spot |
| 61 | 104 | ||
| 62 | my $filename; | 105 | open(FILE, "objdump -dS --adjust-vma=$vmaoffset --start-address=$decodestart --stop-address=$decodestop $filename |") || die "Cannot start objdump"; |
| 63 | |||
| 64 | open(FILE, "objdump -dS $vmlinux_name |") || die "Cannot start objdump"; | ||
| 65 | 106 | ||
| 66 | while (<FILE>) { | 107 | while (<FILE>) { |
| 67 | my $line = $_; | 108 | my $line = $_; |
