Created
April 27, 2020 20:48
-
-
Save mpictor/ea092ebbb2dddeb35c2d4ca0f8571587 to your computer and use it in GitHub Desktop.
gdb / qemu kernel debug notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# notes from when I had trouble with kexec some time back. possibly useful to others. | |
# disable kaslr or boot with nokaslr, or no symbols will match and no breakpoints will be hit | |
# | |
# hbreak used to be necessary? not any more | |
qemu-system-x86_64 --version | |
#QEMU emulator version 4.0.0 | |
gdb --version | |
#GNU gdb (Gentoo 8.3 vanilla) 8.3 | |
#update these | |
kernel=$GOPATH/src/github.com/u-root/u-root/work/i/arch/x86/boot/bzImage | |
uinteg=/tmp/uroot-integration646325419 | |
#in one console window | |
qemu-system-x86_64 -machine accel=tcg -nographic \ | |
-kernel $kernel \ | |
-append 'nokaslr console=ttyS0 earlyprintk=ttyS0' \ | |
-initrd $uinteg/initramfs.cpio \ | |
-drive file=fat:rw:$uinteg,if=none,id=tmpdir \ | |
-device ich9-ahci,id=ahci -device ide-drive,drive=tmpdir,bus=ahci.0 \ | |
-device virtio-rng-pci \ | |
-s -S | |
#in another console window | |
gdb vmlinux -ex 'target remote localhost:1234' \ | |
-ex 'b __x64_sys_kexec_load' \ | |
-ex 'b __x64_sys_kexec_file_load' \ | |
-ex 'b __x64_sys_execve' \ | |
-ex 'b __x64_sys_execveat' \ | |
-ex 'b do_syscall_64' \ | |
-ex 'b do_execve_file' \ | |
-ex 'b open_exec' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment