home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / docs / kernel-2.0 / oops-tra.txt < prev    next >
Encoding:
Internet Message Format  |  1996-07-11  |  3.0 KB

  1. From: Linus Torvalds <torvalds@cs.helsinki.fi>
  2.  
  3. How to track down an Oops.. [originally a mail to linux-kernel]
  4.  
  5. The main trick is having 5 years of experience with those pesky oops 
  6. messages ;-)
  7.  
  8. Actually, there are things you can do that make this easier. I have two 
  9. separate approaches:
  10.  
  11.     gdb /usr/src/linux/vmlinux
  12.     gdb> disassemble <offending_function>
  13.  
  14. That's the easy way to find the problem, at least if the bug-report is 
  15. well made (like this one was - run through ksymoops to get the 
  16. information of which function and the offset in the function that it 
  17. happened in).
  18.  
  19. Oh, it helps if the report happens on a kernel that is compiled with the 
  20. same compiler and similar setups.
  21.  
  22. The other thing to do is disassemble the "Code:" part of the bug report: 
  23. ksymoops will do this too with the correct tools (and new version of 
  24. ksymoops), but if you don't have the tools you can just do a silly 
  25. program:
  26.  
  27.     char str[] = "\xXX\xXX\xXX...";
  28.     main(){}
  29.  
  30. and compile it with gcc -g and then do "disassemble str" (where the "XX" 
  31. stuff are the values reported by the Oops - you can just cut-and-paste 
  32. and do a replace of spaces to "\x" - that's what I do, as I'm too lazy 
  33. to write a program to automate this all).
  34.  
  35. Finally, if you want to see where the code comes from, you can do
  36.  
  37.     cd /usr/src/linux
  38.     make fs/buffer.s     # or whatever file the bug happened in
  39.  
  40. and then you get a better idea of what happens than with the gdb 
  41. disassembly.
  42.  
  43. Now, the trick is just then to combine all the data you have: the C 
  44. sources (and general knowledge of what it _should_ do, the assembly 
  45. listing and the code disassembly (and additionally the register dump you 
  46. also get from the "oops" message - that can be useful to see _what_ the 
  47. corrupted pointers were, and when you have the assembler listing you can 
  48. also match the other registers to whatever C expressions they were used 
  49. for).
  50.  
  51. Essentially, you just look at what doesn't match (in this case it was the 
  52. "Code" disassembly that didn't match with what the compiler generated). 
  53. Then you need to find out _why_ they don't match. Often it's simple - you 
  54. see that the code uses a NULL pointer and then you look at the code and 
  55. wonder how the NULL pointer got there, and if it's a valid thing to do 
  56. you just check against it..
  57.  
  58. Now, if somebody gets the idea that this is time-consuming and requires 
  59. some small amount of concentration, you're right. Which is why I will 
  60. mostly just ignore any panic reports that don't have the symbol table 
  61. info etc looked up: it simply gets too hard to look it up (I have some 
  62. programs to search for specific patterns in the kernel code segment, and 
  63. sometimes I have been able to look up those kinds of panics too, but 
  64. that really requires pretty good knowledge of the kernel just to be able 
  65. to pick out the right sequences etc..)
  66.  
  67. _Sometimes_ it happens that I just see the disassembled code sequence 
  68. from the panic, and I know immediately where it's coming from. That's when 
  69. I get worried that I've been doing this for too long ;-)
  70.  
  71.         Linus
  72.  
  73.