BUG-HUNTING
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. [Sat Mar  2 10:32:33 PST 1996 KERNEL_BUG-HOWTO lm@sgi.com (Larry McVoy)]
  2. This is how to track down a bug if you know nothing about kernel hacking.  
  3. It's a brute force approach but it works pretty well.
  4. You need:
  5.         . A reproducible bug - it has to happen predictably (sorry)
  6.         . All the kernel tar files from a revision that worked to the
  7.           revision that doesn't
  8. You will then do:
  9.         . Rebuild a revision that you believe works, install, and verify that.
  10.         . Do a binary search over the kernels to figure out which one
  11.           introduced the bug.  I.e., suppose 1.3.28 didn't have the bug, but 
  12.           you know that 1.3.69 does.  Pick a kernel in the middle and build
  13.           that, like 1.3.50.  Build & test; if it works, pick the mid point
  14.           between .50 and .69, else the mid point between .28 and .50.
  15.         . You'll narrow it down to the kernel that introduced the bug.  You
  16.           can probably do better than this but it gets tricky.  
  17.         . Narrow it down to a subdirectory
  18.           - Copy kernel that works into "test".  Let's say that 3.62 works,
  19.             but 3.63 doesn't.  So you diff -r those two kernels and come
  20.             up with a list of directories that changed.  For each of those
  21.             directories:
  22.                 Copy the non-working directory next to the working directory
  23.                 as "dir.63".  
  24.                 One directory at time, try moving the working directory to
  25.                 "dir.62" and mv dir.63 dir"time, try 
  26.                         mv dir dir.62
  27.                         mv dir.63 dir
  28.                         find dir -name '*.[oa]' -print | xargs rm -f
  29.                 And then rebuild and retest.  Assuming that all related
  30.                 changes were contained in the sub directory, this should 
  31.                 isolate the change to a directory.  
  32.                 Problems: changes in header files may have occurred; I've
  33.                 found in my case that they were self explanatory - you may 
  34.                 or may not want to give up when that happens.
  35.         . Narrow it down to a file
  36.           - You can apply the same technique to each file in the directory,
  37.             hoping that the changes in that file are self contained.  
  38.             
  39.         . Narrow it down to a routine
  40.           - You can take the old file and the new file and manually create
  41.             a merged file that has
  42.                 #ifdef VER62
  43.                 routine()
  44.                 {
  45.                         ...
  46.                 }
  47.                 #else
  48.                 routine()
  49.                 {
  50.                         ...
  51.                 }
  52.                 #endif
  53.             And then walk through that file, one routine at a time and
  54.             prefix it with
  55.                 #define VER62
  56.                 /* both routines here */
  57.                 #undef VER62
  58.             Then recompile, retest, move the ifdefs until you find the one
  59.             that makes the difference.
  60. Finally, you take all the info that you have, kernel revisions, bug
  61. description, the extent to which you have narrowed it down, and pass 
  62. that off to whomever you believe is the maintainer of that section.
  63. A post to linux.dev.kernel isn't such a bad idea if you've done some
  64. work to narrow it down.
  65. If you get it down to a routine, you'll probably get a fix in 24 hours.
  66. My apologies to Linus and the other kernel hackers for describing this
  67. brute force approach, it's hardly what a kernel hacker would do.  However,
  68. it does work and it lets non-hackers help fix bugs.  And it is cool
  69. because Linux snapshots will let you do this - something that you can't
  70. do with vendor supplied releases.