Slashdot Mirror


Inside the Linux kernel debugger

An anonymous reader writes "Here's a good article that shows you how to install and set up the kernel debugger (KDB) to trace Linux kernel execution and examine memory and data structures. The best part is, you don't need a separate machine for debugging."

28 comments

  1. A KDE Debugger? by baywulf · · Score: 0, Offtopic

    Unfair. They need to make one for Gnome and call it GDB.

  2. Beos was better. by Anonymous Coward · · Score: 2, Interesting

    BeOS had a nifty debugger that you dropped into instead of BSOD. you could do all sorts of fun things, and it even allowed modules to be loaded to add new debug commands.

    1. Re:Beos was better. by slimey_limey · · Score: 0

      Sounds somewhat like Macsbug on the Mac.

  3. The article .. by damaru · · Score: 2, Insightful

    is more of a Intoduction to KDB then an inside thing.

  4. Visual debuggers by ObviousGuy · · Score: 4, Interesting

    I have no doubt that KDB is a powerful debugger, but having a GUI would make it even better, IMO.

    This probably comes from my own experience with OS debuggers and Application debuggers (windbg, VC++/Borland C++). Being able to get immediate feedback about program state without having to enter arcane commands is a definite boon.

    Are there any GUI wrappers available for KDB?

    --
    I have been pwned because my /. password was too easy to guess.
    1. Re:Visual debuggers by weicco · · Score: 2, Interesting

      SoftIce ported on Linux/Unix would be grrrreat. I refused to write any driver code until I got myself a SoftIce in dev-computer at my last job :) Unfortunately SoftIce costs more than family wagon I think.

      --
      You don't know what you don't know.
    2. Re:Visual debuggers by Anonymous Coward · · Score: 0

      Well, you can actually GDB a running linux-kernel if you have two computers and a null-modem cable. Then, any of the GDB GUI wrappetrs will work...

      Obviously, in a single-computer scenario, you can't do this, but back in my day (Amiga SAD) no-one did serious OS kernel development with only one computer.

    3. Re:Visual debuggers by kruntiform · · Score: 2, Insightful

      Huh? All he's saying is that GUI-fied debuggers are nicer than console ones. I've used windbg (one of the ones he mentions) to write and debug kernel-mode drivers on NT. I don't see why you think he hasn't a clue. Just because you use Linux doesn't mean you know everything there is to know about computers!

    4. Re:Visual debuggers by Anonymous Coward · · Score: 0

      Uh, that is to say, I used a text editor to write the code, but windbg to debug it.

    5. Re:Visual debuggers by turgid · · Score: 0

      I was trying to make the point that Windoze people generally have a very stranfe, preverse view of computing. Why the hell should an operating system kernel have a GUI in it just so you can debug it?

    6. Re:Visual debuggers by kruntiform · · Score: 2, Insightful

      No, no, debuggers can have GUIs. Kernels can't have GUIs. "Windoze" people generally have strange view of computing? Are you really that much of a zealot, or have I just been trolled?

    7. Re:Visual debuggers by turgid · · Score: 1

      No, I'm a zealot. I stopped using Windoze in 1996 and haven't looked back.

    8. Re:Visual debuggers by turgid · · Score: 1

      Kernel debugger are just that : compiled into the kernel (or have hooks compiled in). They exist in kernel space only and do not interface with any high-level stuff like GUIs. They let you do things like examine the CPU registers (and alter them), look at the page tables, look at the kernel stack, and the kernel data structures in general. For example you can follow the pointers in a process structure, find vnodes and inodes, all kinds of things. You don't want to be going out to a GUI and all the way back down into the kernel to do that (you'll alter the state of the kernel for a start).

    9. Re:Visual debuggers by Anonymous Coward · · Score: 0

      You really are clueless about debugging operating systems.

    10. Re:Visual debuggers by kruntiform · · Score: 1

      Ok, fair enough. I should have read the article. The kdb debugger is built in to the kernel. My experience with kernel debugging was using a seperate machine over a serial cable. But no one was suggesting adding a GUI to a built-in kernel debugger!

    11. Re:Visual debuggers by kruntiform · · Score: 1

      At home I use w2k as a workstation and FreeBSD as a server and Internet gateway. There are good things in both worlds!

    12. Re:Visual debuggers by turgid · · Score: 1

      I have yet to be convinced.

    13. Re:Visual debuggers by turgid · · Score: 1

      That's one of the differences between UNIX-like systems and WindowsNT systems: you can debug the kernel on the machine you're running on UNIX, but on NT (and hence 2k and XP) you need another machine. I've seen debugging on Linux plus a System VR4-based kernel.

    14. Re:Visual debuggers by kruntiform · · Score: 1

      That's a funny way of classifying things. Your hatred of Windows is sounding really irrational. Not all Unixes have single-machine kernel debugging. Which ones besides Linux do? And SoftICE on Windows allows single machine debugging (or so their blurb says* -- I haven't used it myself). And you didn't account for BeOS (which has a built-in kernel debugger) in your classification scheme ;)

      -------------
      * "Debug kernel-mode drivers with ease
      SoftICE is a powerful kernel mode debugger that supports device driver debugging on either a single or dual machine configuration. "

    15. Re:Visual debuggers by turgid · · Score: 0, Redundant

      I'm not basing my hatred of Windows on kernel debugging. There's so much wrong with Windows, I just cannot think where to start. Everything about Windows is "dumbing down" the experience from the user and in doing so removing power from them. A UNIX system is an incredibly rich and flexible (and extensible) tool. It's very empowering. WIndows is all smoke and mirrors, trade secrets, treating the user as a moron etc. As someone who uses computers every day to do work, I just can't imagine how I'd get 1/10th the work done on a Windows box, without substantial expensive 3rd-party add-ons (mainly software). The last time I used Windows at work was NT4 in 2000. I found it so primitive, buggy, unstable and restrictive compared to Linux and Solaris. I know Windows has improved some what, however it's still an expensive toy compared to Linux and Solaris. On a UNIX machine, everything's there, it's documented and it just works. Most of the software is Open Source or Free. Everything conforms to standards. If you don't like one system, you can move over to another e.g. fed up with Linux? Try Free BSD. Want an enterprise server with a support contract? Move up to Solaris. Need a real-time embedded POSIX kernel? Get QNX. Want to run on a small ARM machine? Get Net BSD. ... and KEEP YOUR EXISTING SOFTWARE.... and we haven't mentioned 64-bits yet, have we? There have been 64-bit UNIXes for over 10 years now. They're mature. Where is Windows? What about porting your applications? Which processor? Do you have a choice other than itanic? Good luck.

    16. Re:Visual debuggers by turgid · · Score: 1

      Yeah, I know. I only went on a course once and ran the kernel debugger for a few hours during the course of the week and it was over a year ago. I wrote a small device driver module and watched it execute, passing things up and down a stream. That doesn't really count. I suppose if I'd want to know about a real OS I'd have studied NT like everyone else? For you irony-impared Americans, that was tongue in cheek.

    17. Re:Visual debuggers by Gumpu · · Score: 1

      Don't know about KDB, but gdb, the perl debugger and the java debugger all are wrapped by DDD. DDD is a very fine graphical debugger.
      See http://www.gnu.org/software/ddd/

  5. Much easier to use User-Mode Linux by Ristretto · · Score: 2, Interesting

    We're doing OS research here (UMass) with Linux, and unless you have very specialized needs, you're far better off using User-Mode Linux. By running Linux as a user-process, you don't have to worry about bringing down your machine and you can use gdb to do your debugging.

    1. Re:Much easier to use User-Mode Linux by Chalst · · Score: 0

      Porting games from Windows to Linux I think is such a niche. I gather these folks spend a great deal of time looking at debugger output, and are unusually likely to run into kernel mode errors.