Table of Contents
Updated
Hope this guide helps you when you see qemu arm linux debugging.
QEMU is a great tool to use whenever you need to debug your kernel. YesThere are a large number of recipes for this on the internet as well, and I have listed a few useful ones at the most important end of the article for reference. We prefer to share the kernel debugging steps, but we are focusing on aarch64 schemas as some of the steps for this type may differ slightly from the system as a whole. Build First the directory to work with, then also run the following commands to create expensive images: Then download the working QEMU image. We are using the ie8 image we created earlier. We might mention that our procedure is to build a kernel from scratch and transfer such an image to QEMU. So, the first step can be described in such a way that the QEMU image is actually created. Let’s say you already have an image that you wantyou can use. Otherwise, check out our articles: We prefer the first method using LISA-QEMU as we also have a modified script to automatically install your kernel into each of our VM images. No But rest assured, if you and your family decide to go the other way, my partner and I will show you all the steps as well! You have several options. One is to manually download the installation image and image, or use LISA-QEMU scripts to install it. The download command below the command will use the image in the legal process. You want to use the later instructions to download the image, but scp contains a kernel (possibly a .deb file) and installs it manually with deb -i Typically, to support QEMU with a kernel, you need a kernel image (created publicly), an initrd image (created after installing the kernel type to your image), and an operating system image (created above). Remember that the steps start with the raw image. At this point, if you have qcow2, first use qemu-img to convert it to raw.For example: Below you can mount the image so that the files are completely copied. In this case, you need to copy the initrd. Next is the sneaker core that you created with initrd. Note that the kernel you created can be found atArch / arm64 / boot / Image. This command line displays the kernel image with initrd as well as the operating system image. You may need to change the “root = / dev / vda1” argument. This tells the kernel where to access your boot partition. This can vary depending on what is in your virtual machine image. -s specifierAllows QEMU to use most of the TCP port: 1234 Before debugging, update your ~ / .gdbinit as follows: Start the debugger in another window.Note that if you are on an aarch64 x86 host, you will need to use gdb-multiarch for debugging (sudo apt-get gdb-multiarch). In the legal procedure below, we are on a different host aarch64, so we only use gdb. It’s great that below we get a special “Done” message, which says that the icons were packaged successfully, otherwise the steps described below will not work. Attach a debugger to a specific kernel. Do you remember the -s Es argument above? tells QEMU to use port: 2345. We will now connect to this task. B And that’s it. A debugger is usually included. We are now testing the configuration. Create a breakpoint! Do you remember above that I personally used the -S option for QEMU? This made QEMU wait for the image to start until we attach a common debugger. So, once we get to the point, let’s continue, QEMU will actually start loading the kernel. Links:
dd if = / dev / zero of = flash1.img bs = 1M count = 64dd if = / dev / zero of = flash0.img bs = 1M count = 64dd if = / usr / share / qemu-efi-aarch64 / QEMU_EFI.fd of = flash0.img conv = notrunc
qemu / build / aarch64-softmmu / qemu-system-aarch64 -nographic n -virt laptop, gic-version = max -m 2G -cpu max n -netdev-user, id = vnet, hostfwd =: 127.0.0.1: 0-: 22 -virtio-net-pci device, netdev = vnet n -drive file =. / mini_ubuntu.img if = not, id = disk0, cache = writeback n -device virtio-blk, disk = disk0, boot index = 0 n - hard disk file =. / Flash0.img, format = raw, if = pflash n -drive file =. / flash1.img, format = raw, if = pflash -smp 4 Cast
qemu-img make over -O raw my_image.qcow2 my_image_output.raw
$ mkdir mnt$ sudo losetup -f -P ubuntu.img$ sudo Lostup -lNAME SIZE LIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC/ dev / loop0 0 0 0 6 ubuntu.img 0512$ sudo mount / dev / loop0p2 ./mnt$ mark vii ./mnt/bootconfig-4.15.0-88-generic Grub initrd.img-5.5.11 System.map-5.5.11 vmlinuz-5.5.11config-5.5.11 initrd.img initrd.img.old Vmlinuz Vmlinuz. oldefi initrd.img-4.15.0-88-generic System.map-4.15.0-88-generic vmlinuz-4.15.0-88-generic$ cp ./mnt/initrd.img-5.5.11.$ sudo umount ./mnt$ sudo losetup -d / dev / loop0
qemu / build / aarch64-softmmu / qemu-system-aarch64 -nographic n -machine virt, gic-version = max -m 2G -cpu max n -netdev-user, id = vnet, hostfwd =: 127.0.0.1: 0-: 22 n -virtio-net-pci device, netdev = vnet n File = -disk. / Mini_ubuntu.img, if = none, id = drive0, cache = writeback n -device virtio-blk, disk = disk0, boot index = 0 n -Disk file =. / Flash0.img, format = raw, if = pflash n -build file =. / flash1.img, format = raw, if = pflash -smp 4 n Basic. / Linux / Arch / arm64 / boot / image n -append "root = / dev / vda2 nokaslr console = ttyAMA0" n -initrd ./initrd.img-5.5.11 -s -S
-S stop at Medical and wait for the debugger to connect.
add-auto-load-safe-path linux-5.5.11 / scripts / gdb / vmlinux-gdb.py
$ gdb linux-5.5.11 / vmlinuxGNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-gitRead images from linux-5.5.11 / vmlinux ... done.
(gdb) Target remote localhost: 1234Remote debug from localhost: 12340x0000000000000000 there ?? ()
Add this breakpoint to the kernel as a test.
(gdb) hbreak start_kernelBreakpoint supported by hardware 1 all 0xffff800011330cdc: init / main.c file, line 577.(gdb) cProceed.Thread hits breakpoint 1, start_kernel () only with init / main.c: 577577 {(gdb) i572573 rest_init ();574575576 Avoid __visible asmlinkage __init start_kernel (void)577 {578 characters * command line;579 characters * after_dashes;580581 set_task_stack_end_magic (& init_task);(Gdb)
dd if = / dev / zero of = flash1.img bs = 1M count = 64dd if = / dev / zero of = flash0.img bs = 1M count = 64dd if = / usr / share / qemu-efi-aarch64 / QEMU_EFI.fd of = flash0.img conv = notrunc
qemu / build / aarch64-softmmu / qemu-system-aarch64 -nographic n -machine virt, gic-version = max -m 2G -cpu max n -netdev-user, id = vnet, hostfwd =: 127.0.0.1: 0-: 22 n - virtio-net-pci technology, netdev = vnet n -drive file =. / mini_ubuntu.img if = not, id = disk0, cache = writeback n -device virtio-blk, disk = disk0, boot index = 0 n -Disk file =. / Flash0.img, format = raw, if = pflash n -drive file =. / flash1.img, format = raw, if = pflash -smp think about it
qemu-img convert -O raw my_image.qcow2 my_image_output.raw
$ mkdir mnt$ sudo losetup -f -P ubuntu.img$ sudo Lostup -lNAME SIZE LIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC/ dev / loop0 0 0 4 0 ubuntu.img 0512$ sudo build / dev / loop0p2 ./mnt$ ls ./mnt/bootconfig-4.15.0-88-generic Grub initrd.img-5.5.11 System.map-5.5.11 vmlinuz-5.5.11config-5.5.11 initrd.img initrd.img.old Vmlinuz Vmlinuz. oldefi initrd.img-4.15.0-88-generic System.map-4.15.0-88-generic vmlinuz-4.15.0-88-generic$ cp ./mnt/initrd.img-5.5.11.$ sudo umount ./mnt$ sudo Lostup -d -nographic n / dev / loop0
qemu / build / aarch64-softmmu / qemu-system-aarch64 -machine virt, gic-version = max -m 2G -cpu max n -netdev-user, id = vnet, hostfwd =: 127.0.0.1: 0-: 22 n -virtio-net-pci device, netdev = vnet n File = -disk. / Mini_ubuntu.img, if = none, id = drive0, cache = writeback n - virtio-blk machine, disk = drive0, bootindex = 0 n -Disk file =. / Flash0.img, format = raw, if = pflash n -drive file =. / flash1.img, format = raw, if = pflash -smp 4 n Basic. / Linux / Arch / arm64 / boot Not / Image n -append "root = / dev / vda2 nokaslr console = ttyAMA0" n -initrd ./initrd.img-5.5.11 -s -S
add-auto-load-safe-path linux-5.5.11 / scripts / gdb / vmlinux-gdb.py
$ gdb linux-5.5.11 / vmlinuxGNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-gitReading symbols from linux-5.5.11 / vmlinux ... done.
(gdb) Target remote localhost: 1234Remote debug localhost: 1234Use 0x0000000000000000 consistently ?? ()
(gdb) hbreak start_kernelHardware breakpoint 0 to 0xffff800011330cdc: init / main.c file, line 577.(gdb) cProceed.Thread # 1 has reached breakpoint 1, start_kernel () here in init / main.c: 577577 {(gdb) i572573 rest_init ();574575576 asmlinkage __avoidably avoid __init start_kernel (void)577 {578 characters * command line;579 characters * after_dashes;580581 set_task_stack_end_magic (& init_task);(Gdb)
Qemu Arm Linux 디버그
Qemu Arm Linux Debug
Qemu Arm Linux Debug
Qemu Arm Linux Debug
Débogage Linux Qemu Arm
Depuração Do Qemu Arm Linux
Depuración De Qemu Arm Linux
Debugowanie Qemu Arm Linux
Qemu Arm Linux-Debugging
Qemu Arm Linux Debug
![Jeremy O\'May](https://geeksofknowhere.com/wp-content/uploads/jeremyo'may.jpg)