Re: Kernel panic debugging (was Re: 1.3.95 is not stable)

Matthias Urlichs (smurf@smurf.noris.de)
Mon, 29 Apr 1996 12:49:05 +0100


In linux.dev.kernel, article <Pine.LNX.3.91.960427113649.20025C-100000@=
linux.cs.Helsinki.FI>,
Linus Torvalds <torvalds@cs.helsinki.fi> writes:
>=20
> Actually, there are things you can do that make this easier. I have t=
wo=20
> separate approached:
>=20
> gdb /usr/src/linux/vmlinux
> gdb> disassemble <offending_function>

I'm often using
gdb> list *0xoffending_address

to find out where the code in question is dying at. (Usually, this will
list the next instruction, but that's close enough.) That way obviously
requires a kernel compiled with -g and the exact same addresses, though=
you
can of course add in the difference in function start addresses.

Gdb is also not too smart about noticing addresses that really point to
data space and string storage (they're in the .text segment).

Getting a reliable call trace isn't that easy, either, as sometimes
discarded return addresses from interrupt code is lying around on the
stack. A top-down approach with the "list *" trick is often useful here=
.

Finally, here's a patch to strip the symbols from installed modules if =
you
do want to build your kernel with -g. You don't need the symbols in
/lib/modules and they can be _huge_... Note, btw, that the -g makes
building a new kernel "somewhat" slower.

diff -ub /pub/src/linux/kernel/linux-1.3/Makefile /usr/src/kernel/linux=
-1.3/Makefile
--- /pub/src/linux/kernel/linux-1.3/Makefile Mon Apr 29 09:10:29 1996
+++ /usr/src/kernel/linux-1.3/Makefile Mon Apr 29 09:10:09 1996
@@ -87,7 +87,7 @@
# standard CFLAGS
#
=20
-CFLAGS =3D -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-str=
ength-reduce
+CFLAGS =3D -g -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-=
strength-reduce
=20
ifdef CONFIG_CPP
CFLAGS :=3D $(CFLAGS) -x c++
@@ -280,6 +280,7 @@
inst_mod() { These=3D"`cat $$1`"; MODULES=3D"$$MODULES $$These"; \
mkdir -p $$MODLIB/$$2; cp -p $$These $$MODLIB/$$2; \
echo Installing modules under $$MODLIB/$$2; \
+ strip --strip-debug $$MODLIB/$$2/*; \
}; \
\
if [ -f BLOCK_MODULES ]; then inst_mod BLOCK_MODULES block; fi; \

> The other thing to do is disassemble the "Code:" part of the bugrepro=
t:=20
> ksymoops will do this too with the correct tools (and new version of=20
> ksymoops), but if you don't have the tools you can just do a silly=20
> program:
>=20
> char str[] =3D "\xXX\xXX\xXX...";
> main(){}
>=20
The problem with that is, unfortunately, that you lose any references
external to that 16 bytes of code snippet.

--=20
Quality is inversely proportional to the time left for the completion
of a project.
-- Wright.
--=20
Matthias Urlichs \ Noris Network GmbH i.Gr/ Xlink-POP N=FCrnberg=
=20
Schleiermacherstra=DFe 12 \ Linux+Internet / EMail: urlichs@nor=
is.de
90491 N=FCrnberg (Germany) \ Consulting+Programming+Networking+etc'i=
ng
PGP: 1B 89 E2 1C 43 EA 80 44 15 D2 29 CF C6 C7 E0 DE=20
Click <A HREF=3D"http://smurf.noris.de/~smurf/finger">here</A>. =
42