...
- Create a KVM image
- Update the the KVM xml file:
Code Block sudo virsh edit <uuid> <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> ###and at the end add: <qemu:commandline> <qemu:arg value='-gdb'/> <qemu:arg value='tcp::1200'/> ## 1200 is the TCP port that gdb will connect on </qemu:commandline> </domain>
- On Ubuntu host the "sudo virsh edit" approach didn't seem to update the VM's definition. The following approach work:
Code Block virsh dumpxml test03 > test03.xml vi test03.xml # Update it as above virsh define test03.xml
- Grab the vmlinux and unzip it
Code Block /boot/vmlinux-2.6.32.431.23.3.el6_lustre.bz2
- place the vmlinux on y our guest OS
- Download and place the attached .gdbinit in your home directory
- Place the modules with debugging symbols on your host machine
- Starup the guest OS
- On the guest, Load the modules you wish to debug
lnet.ko
for example. - On the host, startup gdb with the vmlinux
Code Block gdb vmlinux-2.6.32.431.23.3.el6_lustre
- In GDB on the guest:
Code Block (gdb) target remote localhost:1200 ## This is defined int he .gdbinit and it will list all the addresses of the loaded modules (gdb) mod-list-syms add-symbol-file lnet.ko 0xffffffffa03c8000 add-symbol-file sha512_generic.ko 0xffffffffa00a8000 add-symbol-file sha256_generic.ko 0xffffffffa0065000 add-symbol-file crc32c_intel.ko 0xffffffffa0023000 add-symbol-file libcfs.ko 0xffffffffa0356000 add-symbol-file fuse.ko 0xffffffffa0231000 add-symbol-file autofs4.ko 0xffffffffa034e000 add-symbol-file sunrpc.ko 0xffffffffa02f5000 add-symbol-file bnx2fc.ko 0xffffffffa02d7000 .... ## Add the symbols to GDB using the module with debugging symbols you copied to your host machine (gdb) add-symbol-file /path/to/lnet.ko 0xffffffffa03c8000 ## Add breakpoints as you wish ## continue execution (gdb) continue
By this point the symbols for the module you wish to debug is loaded in GDB and GDB is attached to your guest OS.
- Add strategic breakpoints to enhance your debugging
- Invoke the scenario you wish to debug
- GDB will break at the desired break points, allowing you to debug as you normally would a user space program from gdb.