home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!warwick!uknet!edcastle!dcs.ed.ac.uk!sct
- From: sct@dcs.ed.ac.uk (Stephen Tweedie)
- Newsgroups: comp.os.linux
- Subject: Re: Missing stuff: pstat, tset, NIS?
- Message-ID: <SCT.93Jan23162304@ascrib.dcs.ed.ac.uk>
- Date: 23 Jan 93 16:23:04 GMT
- References: <C16J5A.9Lw@news2.cis.umn.edu> <1993Jan21.124216.13521@aston.ac.uk>
- Sender: cnews@dcs.ed.ac.uk (UseNet News Admin)
- Organization: University of Edinburgh Dept. of Computer Science, Scotland
- Lines: 55
- In-Reply-To: evansmp@uhura.aston.ac.uk's message of 21 Jan 93 12:42:16 GMT
-
- In article <1993Jan21.124216.13521@aston.ac.uk>, evansmp@uhura.aston.ac.uk (Mark Evans) writes:
- > : >In article <lma.727207214@dayton.Stanford.EDU>, lma@dayton.Stanford.EDU (Larry Augustin) writes:
- > : >
- > : >Pstat? Nope. Anyway, the kernel structures have been changing too
- > : >rapidly to make such a beast easy to maintain...
-
- > The current idea appears to be to impliment examination of any
- > kernel data structures by using the /proc filesystem. The format of
- > this is likely to be more stable (once all the bits have been put
- > in) than diging arround in /dev/kmen i.e. no recompiling
- > tools/rebuilding databases whenever the kernel is changed!
-
- /dev/kmem or some form of explicit system support (via syscalls or
- /proc) is needed to allow programs access to internal data structures,
- but for human browsing of kernel space, there is another way...
-
- The dead easy way of looking through the kernel: if you are running a
- kernel with all of the object files still kicking around in the
- correct places, then you can use GDB to look at the kernel while it is
- running! (Although obviously you can't change actually change
- anything. That would be just TOO dirty.)
-
- The program file to run GDB on will usually be
- /usr/src/linux/tools/system. But the clever bit is that GDB will
- allow you to debug a program on a core dump file, and linux is cunning
- enough to be able to present the running kernel image to GDB as a
- core-dump image!
-
- The trick is to create a /dev/core character device with major/minor
- 1,6 (ie. mknod /dev/core c 1 6). Then
- gdb /usr/src/linux/tools/system /dev/core
- and you're away!
-
- I understand that the procedure is especially useful if you have
- compiled tools/system with the -g flag, but I have only tried it out
- on a non-debugging kernel. However, it works wonderfully.
-
- By the way, it is a good idea to be pretty careful about the
- permissions you set on /dev/core if you are at all worried about
- security...
-
- Oh, and another point. If you get a kernel panic, it is a great idea
- to run GDB on tools/system and "disassemble 0x<offending-pc>" (where
- offending-pc is the program counter reported in the kernel panic
- message. GDB will automatically work out the enclosing function
- (well, at least narrowing down to the surrounding global symbols if
- the kernel is compiled without -g), so you have a good chance of
- locating fairly precisely the offending code. This can make tracking
- down kernel bugs a LOT easier.
-
- Cheers,
- Stephen Tweedie.
- ---
- Stephen Tweedie <sct@uk.ac.ed.dcs> (Internet: <sct@dcs.ed.ac.uk>)
- Department of Computer Science, Edinburgh University, Scotland.
-