[ANNOUNCE] MDB Linux Kernel debugger kernels 2.6.19 through 4.3.0

From: Jeffrey Merkey
Date: Tue Dec 01 2015 - 17:57:39 EST


I am in process of completing testing all the branches. If you find a
bug or have a problem with a build, then feel free to push a change to
the git repo on github.com at https://github.com/jeffmerkey/linux.
See the logs in the git repo for info on changes.

Patches are available from github. To download patches and diffs, go to:

http://jeffmerkey.github.io

MDB (The Minimal Kernel Debugger) was written in 1998 and was one of
the earliest debuggers on Linux. It was originally developed for Linux
kernel file system development on the 2.2 series Linux kernels. MDB is
a tool I wrote for my own use and development since at the time, Linux
had no kernel debugger. MDB was open sourced in 2000. Over the years,
I shared this tool with friends and co-workers, and continued to
enhance it. Linux has since grown up and has several debugging tools
available including KGDB and KDB.

MDB supports a lot of features and capabilities and enhances the range
of tools for debugging kernel applications on Linux. If MDB is useful
to you, please feel free to contribute any changes or enhancements
back. Currently MDB supports x86 and x86_64, but can be easily ported
to other architectures.

MDB is fast, loads as a module, and supports complex conditional
breakpoints and disassembly on the fly, and is extremely useful for
debugging in the field. It's also a great example of how to write a
self-contained modular debugger that can load as a kernel module on
Linux. MDB has an open plug and play architecture and you can add
custom commands easily to the code, or support for other
architectures.

MDB uses the Native Linux Breakpoint API, which is platform
independent. The current architecture support module in the debugger
has all the code stubs for disassembly across all gcc compiler
supported platforms, and simply require the specific gdb disassembly
code sections for each architecture added to support that particular
processor. Anyone interested in doing so feel free to fork this repo
and have fun!
Download

Linux 4.X Diffs and Patches

Linux v4.3 : mdb-v4.3-x86_64.diff : mdb-v4.3-x86_64.patch
Linux v4.2 : mdb-v4.2-x86_64.diff : mdb-v4.2-x86_64.patch
Linux v4.1 : mdb-v4.1-x86_64.diff : mdb-v4.1-x86_64.patch
Linux v4.0 : mdb-v4.0-x86_64.diff : mdb-v4.0-x86_64.patch

Linux 3.X Diffs and Patches

Linux v3.19 : mdb-v3.19-x86_64.diff : mdb-v3.19-x86_64.patch
Linux v3.18 : mdb-v3.18-x86_64.diff : mdb-v3.18-x86_64.patch
Linux v3.17 : mdb-v3.17-x86_64.diff : mdb-v3.17-x86_64.patch
Linux v3.16 : mdb-v3.16-x86_64.diff : mdb-v3.16-x86_64.patch
Linux v3.15 : mdb-v3.15-x86_64.diff : mdb-v3.15-x86_64.patch
Linux v3.14 : mdb-v3.14-x86_64.diff : mdb-v3.14-x86_64.patch
Linux v3.13 : mdb-v3.13-x86_64.diff : mdb-v3.13-x86_64.patch
Linux v3.12 : mdb-v3.12-x86_64.diff : mdb-v3.12-x86_64.patch
Linux v3.11 : mdb-v3.11-x86_64.diff : mdb-v3.11-x86_64.patch
Linux v3.10 : mdb-v3.10-x86_64.diff : mdb-v3.10-x86_64.patch
Linux v3.9 : mdb-v3.9-x86_64.diff : mdb-v3.9-x86_64.patch
Linux v3.8 : mdb-v3.8-x86_64.diff : mdb-v3.8-x86_64.patch
Linux v3.7 : mdb-v3.7-x86_64.diff : mdb-v3.7-x86_64.patch
Linux v3.6 : mdb-v3.6-x86_64.diff : mdb-v3.6-x86_64.patch
Linux v3.5 : mdb-v3.5-x86_64.diff : mdb-v3.5-x86_64.patch
Linux v3.4 : mdb-v3.4-x86_64.diff : mdb-v3.4-x86_64.patch
Linux v3.3 : mdb-v3.3-x86_64.diff : mdb-v3.3-x86_64.patch
Linux v3.2 : mdb-v3.2-x86_64.diff : mdb-v3.2-x86_64.patch
Linux v3.1 : mdb-v3.1-x86_64.diff : mdb-v3.1-x86_64.patch
Linux v3.0 : mdb-v3.0-x86_64.diff : mdb-v3.0-x86_64.patch

MDB Linux Kernel Debugger Branches

Linux 4.X Branches

Linux kernel v4.3 (https://github.com/jeffmerkey/linux/tree/mdb-v4.3)
Linux kernel v4.2 (https://github.com/jeffmerkey/linux/tree/mdb-v4.2)
Linux kernel v4.1 (https://github.com/jeffmerkey/linux/tree/mdb-v4.1)
Linux kernel v4.0 (https://github.com/jeffmerkey/linux/tree/mdb-v4.0)

Linux 3.X Branches

Linux kernel v3.19 (https://github.com/jeffmerkey/linux/tree/mdb-v3.19)
Linux kernel v3.18 (https://github.com/jeffmerkey/linux/tree/mdb-v3.18)
Linux kernel v3.17 (https://github.com/jeffmerkey/linux/tree/mdb-v3.17)
Linux kernel v3.16 (https://github.com/jeffmerkey/linux/tree/mdb-v3.16)
Linux kernel v3.15 (https://github.com/jeffmerkey/linux/tree/mdb-v3.15)
Linux kernel v3.14 (https://github.com/jeffmerkey/linux/tree/mdb-v3.14)
Linux kernel v3.13 (https://github.com/jeffmerkey/linux/tree/mdb-v3.13)
Linux kernel v3.12 (https://github.com/jeffmerkey/linux/tree/mdb-v3.12)
Linux kernel v3.11 (https://github.com/jeffmerkey/linux/tree/mdb-v3.11)
Linux kernel v3.10 (https://github.com/jeffmerkey/linux/tree/mdb-v3.10)
Linux kernel v3.9 (https://github.com/jeffmerkey/linux/tree/mdb-v3.9)
Linux kernel v3.8 (https://github.com/jeffmerkey/linux/tree/mdb-v3.8)
Linux kernel v3.7 (https://github.com/jeffmerkey/linux/tree/mdb-v3.7)
Linux kernel v3.6 (https://github.com/jeffmerkey/linux/tree/mdb-v3.6)
Linux kernel v3.5 (https://github.com/jeffmerkey/linux/tree/mdb-v3.5)
Linux kernel v3.4 (https://github.com/jeffmerkey/linux/tree/mdb-v3.4)
Linux kernel v3.3 (https://github.com/jeffmerkey/linux/tree/mdb-v3.3)
Linux kernel v3.2 (https://github.com/jeffmerkey/linux/tree/mdb-v3.2)
Linux kernel v3.1 (https://github.com/jeffmerkey/linux/tree/mdb-v3.1)
Linux kernel v3.0 (https://github.com/jeffmerkey/linux/tree/mdb-v3.0)

Installation

Download the diff which matches your particular linux version, then
apply the patch from your linux build directory. To download the diff
and convert it into a patch file, click on the link for your kernel
version for your system, then the patch text will display in your
browser window, use your mouse to right click, then save as and save
the patch into any filename you wish. It does not matter what filename
you save the file under, you can choose any filename you wish, so long
as it matches the filename you specify when you run the patch utility.
To patch the kernel, from the linux build directory, type:

(linux build directory) patch -p1 < filename.diff

then type

make oldconfig

make bzImage modules modules_install install

You can also type "make menuconfig" to manually adjust kernel settings
for your debugger under the section "Kernel Hacking". After the kernel
rebuilds, reboot your system to the new kernel and you can load MDB as
a module.
Loading MDB

To load MDB as a module, type:

modprobe mdb

To enter the debugger type:

echo a > /proc/sysrq-trigger

The debugger has excellent online help, just type 'h' or 'help' from
the debugger console for a list of commands. For help with a specific
command, just type 'help (command)' where (command) is the command you
need help with.
Disabling KDB/KGDB

You need to check whether or not another kernel debugger is active on
the system, and if so, disable it. Both the KGDB and KDB debuggers are
available as default build options on Linux. Only one debugger can be
running at a time on the system to function properly. Don't try to run
MDB if KDB or KGDB are active, disable them first. If MDB is compiled
as a module, during module loading MDB will attempt to disable
KGDB/KDB if it detects either is active. You may see something like
this in your /var/log/messages file after the module loads which
indicates it detected and disabled KGDB or KDB:

Nov 30 10:28:49 localhost kernel: KGDB: Registered I/O driver kgdboc
Nov 30 10:28:52 localhost kernel: MDB: kgdb currently set to
[kdb], attempting to disable.
Nov 30 10:28:52 localhost kernel: KGDB: Unregistered I/O driver
kgdboc, debugger disabled
Nov 30 10:28:52 localhost kernel: MDB: kgdb/kdb set to disabled.
MDB is enabled.

By default, MDB will always compile as a module unless you select it
to compile directly into the kernel. If MDB is compiled in the kernel
directly, you may need to check whether KGDB/KDB have been enabled
before activating the MDB debugger.

To check whether kdb or kgdb are running on your system, type:

cat /sys/module/kgdboc/parameters/kgdboc

if the text string "kdb", "kbd", or "tty"(some numbers) show up
disable this interface by typing:

echo "" > /sys/module/kgdboc/parameters/kgdboc

which will disable kgdb and kdb and allow MDB to function correctly.
Using Git to pull remote MDB Branches

You can also use git to pull any of the debugger branches into your
local git tree of the default linux and linux-stable git trees from
kernel.org and build MDB directly from your tree as each branch
corresponds to a particular kernel build and revision. To pull a
remote branch from your local repository type:

git remote add mdb https://github.com/jeffmerkey/linux.git

git fetch mdb mdb-(branch version) i.e. git fetch mdb mdb-v4.3

make certain you create a local branch to merge to

git checkout (kernel version) i.e. git checkout v4.3

git branch (mdb branch) i.e. git branch mdb-v4.3

git checkout (mdb branch) i.e. git checkout mdb-v4.3

then if you wish to commit those changes, type:

git merge mdb/(branch version) i.e. git merge mdb/mdb-v4.3

you can also just pull directly and skip the fetch/merge steps just
make certain you have created and switched to a local branch to commit
your changes into.

git pull mdb mdb-(branch version) i.e. git pull mdb mdb-v4.3

After you have merged your changes into your local branch, switch to
your local linux build directory then you can build your kernel by
typing:

make oldconfig

make bzImage modules modules_install install

then follow the instructions above for loading MDB from the linux command line.
Legacy MDB Versions (X86_64 and IA32)

Linux 2.6.X Patches and Diffs (X86_64)

Linux v2.6.37 : mdb-v2.6.37-x86_64.diff : mdb-v2.6.37-x86_64.patch
Linux v2.6.36 : mdb-v2.6.36-x86_64.diff : mdb-v2.6.36-x86_64.patch
Linux v2.6.35 : mdb-v2.6.35-x86_64.diff : mdb-v2.6.35-x86_64.patch
Linux v2.6.34 : mdb-v2.6.34-x86_64.diff : mdb-v2.6.34-x86_64.patch
Linux v2.6.33 : mdb-v2.6.33-x86_64.diff : mdb-v2.6.33-x86_64.patch
Linux v2.6.32 : mdb-v2.6.32-x86_64.diff : mdb-v2.6.32-x86_64.patch
Linux v2.6.31 : mdb-v2.6.31-x86_64.diff : mdb-v2.6.31-x86_64.patch
Linux v2.6.30 : mdb-v2.6.30-x86_64.diff : mdb-v2.6.30-x86_64.patch
Linux v2.6.29 : mdb-v2.6.29-x86_64.diff : mdb-v2.6.29-x86_64.patch
Linux v2.6.28 : mdb-v2.6.28-x86_64.diff : mdb-v2.6.28-x86_64.patch

Linux 2.6.X Branches (X86_64)

Linux kernel v2.6.37 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.37)
Linux kernel v2.6.36 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.36)
Linux kernel v2.6.35 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.35)
Linux kernel v2.6.34 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.34)
Linux kernel v2.6.33 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.33)
Linux kernel v2.6.32 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.32)
Linux kernel v2.6.31 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.31)
Linux kernel v2.6.30 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.30)
Linux kernel v2.6.29 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.29)
Linux kernel v2.6.28 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.28)

Legacy MDB Patches and Diffs (IA32 Only)

These versions are for older kernels and support IA32 only. They do
not support x86_64 based systems.

mdb-v2.6.27-ia32.diff : mdb-v2.6.27-ia32.patch
mdb-v2.6.26-ia32.diff : mdb-v2.6.26-ia32.patch
mdb-v2.6.25-ia32.diff : mdb-v2.6.25-ia32.patch
mdb-v2.6.24-ia32.diff : mdb-v2.6.24-ia32.patch
mdb-v2.6.23-ia32.diff : mdb-v2.6.23-ia32.patch
mdb-v2.6.22-ia32.diff : mdb-v2.6.22-ia32.patch
mdb-v2.6.21-ia32.diff : mdb-v2.6.21-ia32.patch
mdb-v2.6.20-ia32.diff : mdb-v2.6.20-ia32.patch
mdb-v2.6.19-ia32.diff : mdb-v2.6.19-ia32.patch
mdb-v2.6.18-ia32.diff : mdb-v2.6.18-ia32.patch

Legacy MDB Branches (IA32 Only)

Linux kernel v2.6.27 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.27)
Linux kernel v2.6.26 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.26)
Linux kernel v2.6.25 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.25)
Linux kernel v2.6.24 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.24)
Linux kernel v2.6.23 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.23)
Linux kernel v2.6.22 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.22)
Linux kernel v2.6.21 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.21)
Linux kernel v2.6.20 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.20)
Linux kernel v2.6.19 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.19)
Linux kernel v2.6.18 (https://github.com/jeffmerkey/linux/tree/mdb-v2.6.18)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/