Kernel debugging support #101
Replies: 8 comments 2 replies
-
Honestly I've never used vng with kgbd, the closest thing that I've used is to generate a memory dump and use drgn to inspect it, something like this: Line 301 in ee99d23 That is not the same as attaching gdb directly via kgdb, maybe someone else has more experience than me on this and wants to comment... |
Beta Was this translation helpful? Give feedback.
-
@arighi I can take a stab at trying to make this work. If I enable networking in the VM, I should be able to connect to it from my laptop right? |
Beta Was this translation helpful? Give feedback.
-
@jfernandez sure! To access the VM from your host you can use If you have troubles with |
Beta Was this translation helpful? Give feedback.
-
@arighi I tried enabling bridge mode and ran into several issues not covered by your troubleshooting section. Instead I used the I think the best solution is to simply enable serial port communication between the host and VM. Then socat and libvirt are not requirements because networking is not needed for debugging. I can hack virtme-ng to do this, but I found already some serial port params being used and it was unclear if you are already setting this up. |
Beta Was this translation helpful? Give feedback.
-
fwiw, Im using gdb to control a virtme-ng session, heres my wrappers function vrun__ () { alias vrun_e="vrun_ -e $*" alias vrun_d="vrun_ -a nokaslr -o=-S -o=-s " function vrun_a () { |
Beta Was this translation helpful? Give feedback.
-
Most of the time I work with the running kernel that comes with the OS. So instead of development, most of the time I just try to figure out how the kernel works, and for that I have to prepare the sources and debuginfo for virtme-ng. This is not a big deal for development, where you probably have the sources compiled with debuginfo. It would be handy to have something that would automatically figure out the debuginfo. Sure, without the appropriate kernel sources, this does not have much use... What do you think, it would be possible to have options like download debuginfo, download kernel source (and prepare it for GDB). Right now, if I execute
In a dream scenario
What do you think @arighi, these are intrusive changes? I just thinking about improve the experience of the casual experimenter (like myself) who want to explore the operation of the kernel actually running on the machine. |
Beta Was this translation helpful? Give feedback.
-
@SPYFF it's still a draft for now, but what do you think about #123? |
Beta Was this translation helpful? Give feedback.
-
Currently, the
For some reason, I can't connect to the VM (through gdb) using the serial port when That's the reason behind (Note: Example session: ~/linux $ vng --gdb
kernel version = 6.5.7-virtme
Reading symbols from vmlinux...
Remote debugging using localhost:1234
kgdb_breakpoint () at kernel/debug/debug_core.c:1219
1219 wmb(); /* Sync point after breakpoint */
(gdb) monitor ps
11 idle processes (state -) and
91 sleeping system daemon (state [ims]) processes suppressed,
use 'ps A' to see all.
Task Addr Pid Parent [*] cpu State Thread Command
0xffff888003658000 1 0 1 6 R 0xffff888003658b80 *swapper/0
0xffff888003658000 1 0 1 6 R 0xffff888003658b80 *swapper/0
(gdb) |
Beta Was this translation helpful? Give feedback.
-
This may already be supported, so I thought I'd ask before I try to figure this out myself. I want to have a Kernel debugging setup with virtme-ng following these instructions: https://www.kernel.org/doc/html/latest/dev-tools/kgdb.html
gdb would run on the host machine, and kgdb in the VM. How would I go about configuring this?
Beta Was this translation helpful? Give feedback.
All reactions