Help with QEMU based Linux Kernel debugging

11 views
Skip to first unread message

Aijaz Baig

unread,
Oct 30, 2023, 7:16:59 AM10/30/23
to inside...@googlegroups.com
Hello

I'm trying to debug the Linux kernel (v3.13) via QEMU. I am using [this][1], [this][2] and [this][3] as reference.   I clone buildroot, checkout tag `2014/08`. Then I let buildroot build the kernel for me (v3.13.5). Here are my buildroot [config][4] and the kernel [config][5] options. 

FYI I choose to integrate the rootfs into the kernel *as an initramfs* as described [here][6]. Once done, I see a `rootfs.cpio` archive and a `bzImage` under `output/images`.  Once everything is complete, I invoke qemu like so:
`sudo qemu-system-x86_64 --enable-kvm -serial tcp::1234,server,nowait -m 512M -kernel ./bzImage -append "kgdbwait kgdboc=ttyS0,115200 nokaslr ip=dhcp" -net nic,model=virtio -device virtio-blk,drive=drive0 -drive file=./disk.img,format=raw,if=none,id=drive0`

This opens a new window which displays the start-up log and ultimately runs the getty process allowing me to log in. So here are my queries

 1. If I pass `-nographic` to QEMU, I do not see the login prompt. Why?
 2. if I use `-s` which is equivalent to `-gdb tcp:1234`, the gdb client doesn't seem to connect to it properly (it breaks in at a different place in the kernel as compared to when I use `-serial tcp::1234,server,nowait` instead); although qemu is apparently paused, waiting for a connection from remote gdb
 3. Most of the backtrace stack symbols are '??' even though I've enabled debug info and frame pointers in the kernel. I even compiled using COPTS=-O0 which increased the size of the binary but to no avail as far as qemu gdb is concerned.

Keen to hear what you folks have to say!

  [1]: https://stackoverflow.com/a/44197715/1794617
  [2]: https://stackoverflow.com/a/33203642/1794617
  [3]: https://stackoverflow.com/questions/60988342/qemu-doesnt-recognize-block-device-file
  [4]: https://raw.githubusercontent.com/redbilledpanda/SetupScripts/Unix/BUILDROOT_CONFIG
  [5]: https://raw.githubusercontent.com/redbilledpanda/SetupScripts/Unix/KERNEL_CONFIG
  [6]: https://raw.githubusercontent.com/maximeh/buildroot/master/fs/initramfs/Config.in

--

Best Regards,
Aijaz Baig

Anil Kumar Pugalia

unread,
Nov 4, 2023, 1:05:08 AM11/4/23
to inside...@googlegroups.com

Do you see a size change w/ & w/o debug enable as well?

Regards
Anil
Passion: https://sysplay.in (Playing with Systems)
Aijaz Baig wrote on 30/10/23 4:46 pm:
--
You received this message because you are subscribed to the Google Groups "SysPlay's Inside Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inside_linux...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/inside_linux/CAHB2L%2Bc3qpLXAf3R7YiK4k%3DHxb0M7tzabAU04F_JS-%2B3PcAXmQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages