a bit closer

This commit is contained in:
Ciro Santilli
2018-02-13 16:09:16 +00:00
parent d97d461605
commit 64130ecfb9
22 changed files with 316 additions and 569 deletions

View File

@@ -1,15 +1,10 @@
[[kgdb]]
= KGDB
=== KGDB
KGDB is kernel dark magic that allows you to GDB the kernel on real
hardware without any extra hardware support.
KGDB is kernel dark magic that allows you to GDB the kernel on real hardware without any extra hardware support.
It is useless with QEMU since we already have full system visibility
with `-gdb`, but this is a good way to learn it.
It is useless with QEMU since we already have full system visibility with `-gdb`, but this is a good way to learn it.
Cheaper than JTAG (free) and easier to setup (all you need is serial),
but with less visibility as it depends on the kernel working, so e.g.:
dies on panic, does not see boot sequence.
Cheaper than JTAG (free) and easier to setup (all you need is serial), but with less visibility as it depends on the kernel working, so e.g.: dies on panic, does not see boot sequence.
Usage:
@@ -43,17 +38,14 @@ c
And now you can count from GDB!
If you do: `b sys_write` immediately after `./rungdb -k`, it fails with
`KGDB: BP remove failed: <address>`. I think this is because it would
break too early on the boot sequence, and KGDB is not yet ready.
If you do: `b sys_write` immediately after `./rungdb -k`, it fails with `KGDB: BP remove failed: <address>`. I think this is because it would break too early on the boot sequence, and KGDB is not yet ready.
See also:
* https://github.com/torvalds/linux/blob/v4.9/Documentation/DocBook/kgdb.tmpl
* https://stackoverflow.com/questions/22004616/qemu-kernel-debugging-with-kgdb/44197715#44197715
[[kgdb-kernel-modules]]
== KGDB kernel modules
==== KGDB kernel modules
In QEMU:
@@ -73,11 +65,9 @@ c
and you now control the count.
TODO: if I `-ex lx-symbols` to the `gdb` command, just like done for
QEMU `-gdb`, the kernel oops. How to automate this step?
TODO: if I `-ex lx-symbols` to the `gdb` command, just like done for QEMU `-gdb`, the kernel oops. How to automate this step?
[[kdb]]
== KDB
==== KDB
If you modify `runqemu` to use:
@@ -85,8 +75,7 @@ If you modify `runqemu` to use:
-append kgdboc=kbd
....
instead of `kgdboc=ttyS0,115200`, you enter a different debugging mode
called KDB.
instead of `kgdboc=ttyS0,115200`, you enter a different debugging mode called KDB.
Usage: in QEMU:
@@ -110,9 +99,6 @@ And you are back in KDB. Now you can:
And you will break whenever `sys_write` is hit.
The other KDB commands allow you to instruction steps, view memory,
registers and some higher level kernel runtime data.
The other KDB commands allow you to instruction steps, view memory, registers and some higher level kernel runtime data.
But TODO I don't think you can see where you are in the kernel source
code and line step as from GDB, since the kernel source is not available
on guest (ah, if only debugging information supported full source).
But TODO I don't think you can see where you are in the kernel source code and line step as from GDB, since the kernel source is not available on guest (ah, if only debugging information supported full source).