Repository : ssh://git@open-mesh.org/doc
On branches: backup-redmine/2019-10-12,master
commit 31d21b88a6a656ddc69e5bb2e45ee3f4455ef4ec Author: Sven Eckelmann sven@narfation.org Date: Fri Oct 11 23:30:52 2019 +0000
doc: open-mesh/Emulation_Debug: document usage of qemu gdb and linux gdb helper
31d21b88a6a656ddc69e5bb2e45ee3f4455ef4ec open-mesh/Emulation_Debug.textile | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/open-mesh/Emulation_Debug.textile b/open-mesh/Emulation_Debug.textile index 31fc6ae..8457e77 100644 --- a/open-mesh/Emulation_Debug.textile +++ b/open-mesh/Emulation_Debug.textile @@ -301,7 +301,6 @@ chmod +x hub.sh The @SHARED_PATH@ in run.sh has to be changed to a valid path which is used to share the precompiled batman-adv.ko and other tools
<pre> -cat > run.sh << "EOF" #! /bin/sh
SHARED_PATH=/home/sven/tmp/qemu-batman/ @@ -309,10 +308,11 @@ SHARED_PATH=/home/sven/tmp/qemu-batman/ for i in `seq 1 5`; do qemu-img create -b debian.img -f qcow2 root.cow$i normalized_id=`echo "$i"|awk '{ printf "%02d\n",$1 }'` - screen qemu-system-x86_64 -enable-kvm -kernel linux-next/arch/x86/boot/bzImage -append "root=/dev/vda rw console=ttyS0" \ + screen qemu-system-x86_64 -enable-kvm -kernel linux-next/arch/x86/boot/bzImage -append "root=/dev/vda rw console=ttyS0 nokaslr" \ -smp 2 -m 512 -drive file=root.cow$i,if=virtio \ -netdev type=tap,id=net0,ifname=tap$i,script=no -device virtio-net-pci,mac=02:ba:de:af:fe:`echo $i|awk '{ printf "%02X", $1 }'`,netdev=net0 \ -virtfs local,path="${SHARED_PATH}",security_model=none,mount_tag=host \ + -gdb tcp:127.0.0.1:$((23000+$i)) \ -device virtio-rng-pci -nographic sleep 1 done @@ -378,3 +378,30 @@ mkfifo remote-dump ssh root@192.168.2.51 'tcpdump -i enp3s0 -s 0 -U -n -w - "port not 22"' > remote-dump wireshark -k -i remote-dump </pre> + +h2. Using KGDB + +The instances are listening on 127.0.0.1 TCP port <code>23000 + instance_no</code>. We will use in the following example instance 1. The gdb debugger can be started from the linux source directory and all <code>lx-*</code> helpers will be automatically be loaded. + +The debugging with gdb can be started from the linux-next directory: + +<pre> +$ gdb -iex "set auto-load safe-path scripts/gdb/" -ex 'target remote 127.0.0.1:23001' -ex c ./vmlinux +</pre> + +The module can now be loaded in the qemu instance. After that, we have to reload the symbol information via <code>lx-symbol</code> and can set any kind of breakpoints on the batman-adv module: + +<pre> +^C +Thread 1 received signal SIGINT, Interrupt. +default_idle () at arch/x86/kernel/process.c:581 +581 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); +(gdb) lx-symbols /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/ +loading vmlinux +scanning for modules in /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/ +scanning for modules in /home/sven/tmp/qemu-batman/linux-next +loading @0xffffffffa0000000: /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv//batman-adv.ko +(gdb) b batadv_iv_send_outstanding_bat_ogm_packet +Breakpoint 1 at 0xffffffffa0005d60: file /home/sven/tmp/qemu-batman/batman-adv/net/batman-adv/bat_iv_ogm.c, line 1692. +(gdb) c +</pre> \ No newline at end of file