先留一下筆記。
前篇文章已經可以把ARM64的kernel與rootfs編譯好,並且在QEMU跑起來。所以嘗試使用gdb對QEMU做kernel level的單步執行。
1) 將 qemu 跑起來,並等待 gdb 來連接 (多了參數-s -S)
$ ./qemu.git/aarch64-softmmu/qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic -smp 1 -m 2048 -kernel ../kernel/arch/arm64/boot/Image --append "console=ttyAMA0" -s -S
2) 將gdb跑起來並連接到 QEMU
$ aarch64-linux-gnu-gdb
(gdb) file vmlinux ---> 載入kernel的binary
Reading symbols from /home/jesse/studies/arm64/linux.git/vmlinux...done.
(gdb) directory /home/jesse/studies/arm64/linux.git/ ---> 告知source code目錄
Source directories searched: /home/jesse/studies/arm64/linux.git:$cdir:$cwd
(gdb) target remote 10.10.10.10:1234 ---> 連上QEMU
Remote debugging using 10.10.10.10:1234
0x0000000040000000 in ?? ()
(gdb) break start_kernel ---> 設break point
Breakpoint 2 at 0xffffffc0005c94a0: file init/main.c, line 480.
(gdb) c ---> 讓kernel開始繼續執行
Continuing.
Breakpoint 2, start_kernel () at init/main.c:480 ---> 遇到中斷點,kernel停下來
480 {
(gdb) list ---> 看一下現在source code
475 pgtable_init();
476 vmalloc_init();
477 }
478
479 asmlinkage __visible void __init start_kernel(void)
480 {
481 char * command_line;
482 extern const struct kernel_param __start___param[], __stop___param[];
483
484 /*
(gdb) step ---> 單步執行
489 smp_setup_processor_id();
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言