mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
I understand kdb, now missing fix and document arm failures
This commit is contained in:
32
README.adoc
32
README.adoc
@@ -752,10 +752,10 @@ Our C bare-metal compiler is built with link:https://github.com/crosstool-ng/cro
|
|||||||
QEMU:
|
QEMU:
|
||||||
|
|
||||||
....
|
....
|
||||||
./download-dependencies --baremetal --qemu
|
./download-dependencies --baremetal --qemu && \
|
||||||
./build-qemu --arch arm
|
./build-qemu --arch arm && \
|
||||||
./build-crosstool-ng --arch arm
|
./build-crosstool-ng --arch arm && \
|
||||||
./build-baremetal --arch arm
|
./build-baremetal --arch arm && \
|
||||||
./run --arch arm --baremetal prompt
|
./run --arch arm --baremetal prompt
|
||||||
....
|
....
|
||||||
|
|
||||||
@@ -1907,9 +1907,15 @@ continue
|
|||||||
continue
|
continue
|
||||||
....
|
....
|
||||||
|
|
||||||
|
As of Linux v 4.19, the function is called `sys_write` in `arm`, and `__arm64_sys_write` in `aarch64`. One good way to find it if the name changes as it recently did is to try:
|
||||||
|
|
||||||
|
....
|
||||||
|
rbreak .*sys_write
|
||||||
|
....
|
||||||
|
|
||||||
And now you can count from GDB!
|
And now you can count from GDB!
|
||||||
|
|
||||||
If you do: `b __x64_sys_write` immediately after `./run-gdb --kgdb`, 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: `break __x64_sys_write` immediately after `./run-gdb --kgdb`, 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:
|
See also:
|
||||||
|
|
||||||
@@ -1949,7 +1955,7 @@ Tested on d089c4660615abaf5ae16255fc0195cf989ce437.
|
|||||||
In QEMU:
|
In QEMU:
|
||||||
|
|
||||||
....
|
....
|
||||||
/kgdb-mod.sh
|
insmod /timer.ko
|
||||||
....
|
....
|
||||||
|
|
||||||
Source: link:rootfs_overlay/kgdb-mod.sh[].
|
Source: link:rootfs_overlay/kgdb-mod.sh[].
|
||||||
@@ -1958,7 +1964,7 @@ In GDB:
|
|||||||
|
|
||||||
....
|
....
|
||||||
lx-symbols ../kernel_modules-1.0/
|
lx-symbols ../kernel_modules-1.0/
|
||||||
break fop_write
|
break lkmc_timer_callback
|
||||||
continue
|
continue
|
||||||
continue
|
continue
|
||||||
continue
|
continue
|
||||||
@@ -1972,13 +1978,9 @@ TODO: if I `-ex lx-symbols` to the `gdb` command, just like done for QEMU `-gdb`
|
|||||||
|
|
||||||
If you modify `run` to use:
|
If you modify `run` to use:
|
||||||
|
|
||||||
....
|
Advantage over KGDB: you can do everything in one serial. This can actually be important if you only have one serial for both shell and .
|
||||||
-append kgdboc=kbd
|
|
||||||
....
|
|
||||||
|
|
||||||
instead of `kgdboc=ttyS0,115200`, you enter a different debugging mode called KDB.
|
Disadvantage: not as much functionality as GDB, especially when you use Python scripts.
|
||||||
|
|
||||||
TODO is there any advantage of using KDB over GDB? Except for the fact that you need potentially less setup?
|
|
||||||
|
|
||||||
TODO: only works in <<graphics,graphic mode>>. On the serial, prompt hangs, and the characters I type don't show up at all.
|
TODO: only works in <<graphics,graphic mode>>. On the serial, prompt hangs, and the characters I type don't show up at all.
|
||||||
|
|
||||||
@@ -11259,8 +11261,8 @@ Should break GDB at `start_kernel`.
|
|||||||
|
|
||||||
Then proceed to do the following tests:
|
Then proceed to do the following tests:
|
||||||
|
|
||||||
* `/count.sh` and `b __x64_sys_write`
|
* `/count.sh` and `break __x64_sys_write`
|
||||||
* `insmod /timer.ko` and `b lkmc_timer_callback`
|
* `insmod /timer.ko` and `break lkmc_timer_callback`
|
||||||
|
|
||||||
=== Bisection
|
=== Bisection
|
||||||
|
|
||||||
|
|||||||
14
run
14
run
@@ -27,6 +27,7 @@ defaults = {
|
|||||||
'kernel_cli_after_dash': None,
|
'kernel_cli_after_dash': None,
|
||||||
'eval_busybox': None,
|
'eval_busybox': None,
|
||||||
'kgdb': False,
|
'kgdb': False,
|
||||||
|
'kdb': False,
|
||||||
'kvm': False,
|
'kvm': False,
|
||||||
'memory': '256M',
|
'memory': '256M',
|
||||||
'record': False,
|
'record': False,
|
||||||
@@ -93,8 +94,12 @@ def main(args, extra_args=None):
|
|||||||
kernel_cli += ' console={}'.format(console)
|
kernel_cli += ' console={}'.format(console)
|
||||||
extra_console = '{}{}'.format(console_type, console_count)
|
extra_console = '{}{}'.format(console_type, console_count)
|
||||||
console_count += 1
|
console_count += 1
|
||||||
if args.kgdb:
|
if args.kdb or args.kgdb:
|
||||||
kernel_cli += ' kgdbwait kgdboc={},115200'.format(console)
|
kernel_cli += ' kgdbwait'
|
||||||
|
if args.kdb:
|
||||||
|
kernel_cli += ' kgdboc={},115200'.format(console)
|
||||||
|
if args.kgdb:
|
||||||
|
kernel_cli += ' kgdboc={},115200'.format(extra_console)
|
||||||
if kernel_cli_after_dash:
|
if kernel_cli_after_dash:
|
||||||
kernel_cli += " -{}".format(kernel_cli_after_dash)
|
kernel_cli += " -{}".format(kernel_cli_after_dash)
|
||||||
extra_env = {}
|
extra_env = {}
|
||||||
@@ -451,7 +456,10 @@ gem.op5 --debug-flags=Exec fs.py --cpu-type=HPI --caches
|
|||||||
help='Use KVM. Only works if guest arch == host arch'
|
help='Use KVM. Only works if guest arch == host arch'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-k', '--kgdb', default=defaults['kgdb'], action='store_true'
|
'--kgdb', default=defaults['kgdb'], action='store_true'
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--kdb', default=defaults['kdb'], action='store_true'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-l', '--gem5-restore', type=int,
|
'-l', '--gem5-restore', type=int,
|
||||||
|
|||||||
Reference in New Issue
Block a user