Import 2.2.3pre2
[davej-history.git] / Documentation / oops-tracing.txt
blob108c3b645b626ee708ffa911071efd6855c3c44f
1 Quick Summary
2 -------------
4 cd /usr/src/linux/scripts/ksymoops
5 make ksymoops
6 ./ksymoops < the_oops.txt
8 and send the output the maintainer of the kernel area that seems to be
9 involved with the problem. Don't worry too much about getting the wrong
10 person. If you are unsure send it to the person responsible for the code
11 relevant to what you were doing. If it occurs repeatably try and describe
12 how to recreate it. Thats worth even more than the oops
14 If you are totally stumped as to whom to send the report, send it to 
15 linux-kernel@vger.rutgers.edu. Thanks for your help in making Linux as
16 stable as humanly possible.
19 Full Information
20 ----------------
22 From: Linus Torvalds <torvalds@cs.helsinki.fi>
24 How to track down an Oops.. [originally a mail to linux-kernel]
26 The main trick is having 5 years of experience with those pesky oops 
27 messages ;-)
29 Actually, there are things you can do that make this easier. I have two 
30 separate approaches:
32         gdb /usr/src/linux/vmlinux
33         gdb> disassemble <offending_function>
35 That's the easy way to find the problem, at least if the bug-report is 
36 well made (like this one was - run through ksymoops to get the 
37 information of which function and the offset in the function that it 
38 happened in).
40 Oh, it helps if the report happens on a kernel that is compiled with the 
41 same compiler and similar setups.
43 The other thing to do is disassemble the "Code:" part of the bug report: 
44 ksymoops will do this too with the correct tools (and new version of 
45 ksymoops), but if you don't have the tools you can just do a silly 
46 program:
48         char str[] = "\xXX\xXX\xXX...";
49         main(){}
51 and compile it with gcc -g and then do "disassemble str" (where the "XX" 
52 stuff are the values reported by the Oops - you can just cut-and-paste 
53 and do a replace of spaces to "\x" - that's what I do, as I'm too lazy 
54 to write a program to automate this all).
56 Finally, if you want to see where the code comes from, you can do
58         cd /usr/src/linux
59         make fs/buffer.s        # or whatever file the bug happened in
61 and then you get a better idea of what happens than with the gdb 
62 disassembly.
64 Now, the trick is just then to combine all the data you have: the C 
65 sources (and general knowledge of what it _should_ do), the assembly 
66 listing and the code disassembly (and additionally the register dump you 
67 also get from the "oops" message - that can be useful to see _what_ the 
68 corrupted pointers were, and when you have the assembler listing you can 
69 also match the other registers to whatever C expressions they were used 
70 for).
72 Essentially, you just look at what doesn't match (in this case it was the 
73 "Code" disassembly that didn't match with what the compiler generated). 
74 Then you need to find out _why_ they don't match. Often it's simple - you 
75 see that the code uses a NULL pointer and then you look at the code and 
76 wonder how the NULL pointer got there, and if it's a valid thing to do 
77 you just check against it..
79 Now, if somebody gets the idea that this is time-consuming and requires 
80 some small amount of concentration, you're right. Which is why I will 
81 mostly just ignore any panic reports that don't have the symbol table 
82 info etc looked up: it simply gets too hard to look it up (I have some 
83 programs to search for specific patterns in the kernel code segment, and 
84 sometimes I have been able to look up those kinds of panics too, but 
85 that really requires pretty good knowledge of the kernel just to be able 
86 to pick out the right sequences etc..)
88 _Sometimes_ it happens that I just see the disassembled code sequence 
89 from the panic, and I know immediately where it's coming from. That's when 
90 I get worried that I've been doing this for too long ;-)
92                 Linus
95 ---------------------------------------------------------------------------
96 Notes on Oops tracing with klogd:
98 In order to help Linus and the other kernel developers there has been
99 substantial support incorporated into klogd for processing protection
100 faults.  In order to have full support for address resolution at least
101 version 1.3-pl3 of the sysklogd package should be used.
103 When a protection fault occurs the klogd daemon automatically
104 translates important addresses in the kernel log messages to their
105 symbolic equivalents.  This translated kernel message is then
106 forwarded through whatever reporting mechanism klogd is using.  The
107 protection fault message can be simply cut out of the message files
108 and forwarded to the kernel developers.
110 Two types of address resolution are performed by klogd.  The first is
111 static translation and the second is dynamic translation.  Static
112 translation uses the System.map file in much the same manner that
113 ksymoops does.  In order to do static translation the klogd daemon
114 must be able to find a system map file at daemon initialization time.
115 See the klogd man page for information on how klogd searches for map
116 files.
118 Dynamic address translation is important when kernel loadable modules
119 are being used.  Since memory for kernel modules is allocated from the
120 kernel's dynamic memory pools there are no fixed locations for either
121 the start of the module or for functions and symbols in the module.
123 The kernel supports system calls which allow a program to determine
124 which modules are loaded and their location in memory.  Using these
125 system calls the klogd daemon builds a symbol table which can be used
126 to debug a protection fault which occurs in a loadable kernel module.
128 At the very minimum klogd will provide the name of the module which
129 generated the protection fault.  There may be additional symbolic
130 information available if the developer of the loadable module chose to
131 export symbol information from the module.
133 Since the kernel module environment can be dynamic there must be a
134 mechanism for notifying the klogd daemon when a change in module
135 environment occurs.  There are command line options available which
136 allow klogd to signal the currently executing daemon that symbol
137 information should be refreshed.  See the klogd manual page for more
138 information.
140 A patch is included with the sysklogd distribution which modifies the
141 modules-2.0.0 package to automatically signal klogd whenever a module
142 is loaded or unloaded.  Applying this patch provides essentially
143 seamless support for debugging protection faults which occur with
144 kernel loadable modules.
146 The following is an example of a protection fault in a loadable module
147 processed by klogd:
148 ---------------------------------------------------------------------------
149 Aug 29 09:51:01 blizard kernel: Unable to handle kernel paging request at virtual address f15e97cc
150 Aug 29 09:51:01 blizard kernel: current->tss.cr3 = 0062d000, %cr3 = 0062d000
151 Aug 29 09:51:01 blizard kernel: *pde = 00000000
152 Aug 29 09:51:01 blizard kernel: Oops: 0002
153 Aug 29 09:51:01 blizard kernel: CPU:    0
154 Aug 29 09:51:01 blizard kernel: EIP:    0010:[oops:_oops+16/3868]
155 Aug 29 09:51:01 blizard kernel: EFLAGS: 00010212
156 Aug 29 09:51:01 blizard kernel: eax: 315e97cc   ebx: 003a6f80   ecx: 001be77b   edx: 00237c0c
157 Aug 29 09:51:01 blizard kernel: esi: 00000000   edi: bffffdb3   ebp: 00589f90   esp: 00589f8c
158 Aug 29 09:51:01 blizard kernel: ds: 0018   es: 0018   fs: 002b   gs: 002b   ss: 0018
159 Aug 29 09:51:01 blizard kernel: Process oops_test (pid: 3374, process nr: 21, stackpage=00589000)
160 Aug 29 09:51:01 blizard kernel: Stack: 315e97cc 00589f98 0100b0b4 bffffed4 0012e38e 00240c64 003a6f80 00000001 
161 Aug 29 09:51:01 blizard kernel:        00000000 00237810 bfffff00 0010a7fa 00000003 00000001 00000000 bfffff00 
162 Aug 29 09:51:01 blizard kernel:        bffffdb3 bffffed4 ffffffda 0000002b 0007002b 0000002b 0000002b 00000036 
163 Aug 29 09:51:01 blizard kernel: Call Trace: [oops:_oops_ioctl+48/80] [_sys_ioctl+254/272] [_system_call+82/128] 
164 Aug 29 09:51:01 blizard kernel: Code: c7 00 05 00 00 00 eb 08 90 90 90 90 90 90 90 90 89 ec 5d c3 
165 ---------------------------------------------------------------------------
167 Dr. G.W. Wettstein           Oncology Research Div. Computing Facility
168 Roger Maris Cancer Center    INTERNET: greg@wind.rmcc.com
169 820 4th St. N.
170 Fargo, ND  58122
171 Phone: 701-234-7556