Debugging issue with gdbserver and a daemon on the target

Laszlo Papp <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAOMwXhPxtfv7f=akjpuTh+HNCGDeEm0vxen1Kp3pPco++gvuLg@mail.gmail.com>
Hi,

I am having a bit of difficult time to get a breakpoint hit on my
daemon. My setup is as follows:

== Target ==

gdbserver --attach 192.168.0.32:2345 pid-of-my-daemon

== Host ==

./tmp/sysroots/x86_64-linux/usr/bin/armv5te-foo-linux-gnueabi/cgdb -d
./tmp/sysroots/x86_64-linux/usr/bin/armv5te-foo-linux-gnueabi/arm-foo-linux-gnueabi-gdb
-s ./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/usr/bin/.debug/foo
-e ./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/usr/bin/foo
-q -ex set sysroot
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs -ex
tar rem192.168.0.1:2345

Reading symbols from
/home/lpapp/Projects/Yocto/poky-dylan-9.0.1/build/tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/usr/bin/.debug/foo...done.
Remote debugging using 192.168.0.1:2345
Reading symbols from
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/librt.so.1...Reading
symbols from /home/lpapp/Projects/Yocto/poky-dylan-9.0.1/build/tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/root
fs/lib/.debug/librt-2.17.so...done.
done.
Loaded symbols for
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/librt.so.1
Reading symbols from
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/libpthread.so.0...Reading
symbols from /home/lpapp/Projects/Yocto/poky-dylan-9.0.1/build/tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0
/rootfs/lib/.debug/libpthread-2.17.so...done.
done.
Loaded symbols for
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/libpthread.so.0
Reading symbols from
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/libgcc_s.so.1...Reading
symbols from /home/lpapp/Projects/Yocto/poky-dylan-9.0.1/build/tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/r
ootfs/lib/.debug/libgcc_s.so.1...done.
done.
Loaded symbols for
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/libgcc_s.so.1
Reading symbols from
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/libc.so.6...Reading
symbols from /home/lpapp/Projects/Yocto/poky-dylan-9.0.1/build/tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootf
s/lib/.debug/libc-2.17.so...done.
done.
Loaded symbols for
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/libc.so.6
Reading symbols from
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/ld-linux.so.3...Reading
symbols from /home/lpapp/Projects/Yocto/poky-dylan-9.0.1/build/tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/r
ootfs/lib/.debug/ld-2.17.so...done.
done.
Loaded symbols for
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/ld-linux.so.3
Reading symbols from
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/libnss_compat.so.2...Reading
symbols from /home/lpapp/Projects/Yocto/poky-dylan-9.0.1/build/tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0
-r0/rootfs/lib/.debug/libnss_compat-2.17.so...done.
done.
Loaded symbols for
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/libnss_compat.so.2
Reading symbols from
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/libnsl.so.1...Reading
symbols from /home/lpapp/Projects/Yocto/poky-dylan-9.0.1/build/tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/roo
tfs/lib/.debug/libnsl-2.17.so...done.
done.
Loaded symbols for
./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/lib/libnsl.so.1
0x44ad26ec in select () at ../sysdeps/unix/syscall-template.S:81
81      ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) set debug remote 1
(gdb) b foo
Sending packet: $maa1c,4#23...Packet received: 030052e1
Sending packet: $maa1c,4#23...Packet received: 030052e1
Sending packet: $maa1c,4#23...Packet received: 030052e1
Breakpoint 1 at 0xaa1c: file foo.c, line 99.
Sending packet: $qTStatus#49...Packet received:
(gdb) c
Continuing.
Sending packet: $qTStatus#49...Packet received:
Sending packet: $Z0,aa1c,4#6c...Packet received:
Packet Z0 (software-breakpoint) is NOT supported
Sending packet: $maa1c,4#23...Packet received: 030052e1
Sending packet: $Xaa1c,0:#44...Packet received: OK
binary downloading supported by target
Sending packet: $Xaa1c,4:\001#10...Packet received: OK
Sending packet: $m449e80c8,4#d6...Packet received: 1eff2fe1
Sending packet: $X449e80c8,4:\001#c3...Packet received: OK
Sending packet:
$QPassSignals:e;10;14;17;1a;1b;1c;21;24;25;2c;4c;#5f...Packet
received: OK
Sending packet: $vCont?#49...Packet received: vCont;c;C;s;S;t
Packet vCont (verbose-resume) is supported
Program received signal SIGINT, Interrupt.
0x44ad26ec in select () at ../sysdeps/unix/syscall-template.S:81
81      in ../sysdeps/unix/syscall-template.S
(gdb) bt
#0  0x44ad26ec in select () at ../sysdeps/unix/syscall-template.S:81
#1  0x0002ac08 in bar (timeout=10, name=0x42f30 <yy_ec+56> "foo") at
src/socket.c:906
#2  0x0003284c in main (argc=0, argv=0x0) at src/bar.c:679
(gdb)


... And then I do some communication with the daemon where the foo
function is executed based on the logs, but the breakpoint is not hit.
I wished to try hardware breakpoints, but they are not presented on my
hardware.

Furthermore, if I use the same workflow on a binary that is
"one-shot", i.e. not running continuously as a daemon, the debugging
workflow for stopping at main works with exactly the aforementioned
software breakpoint issue.

I am completely clueless at this point. Do you know how I can debug a
daemon with gdbserver?

Cheers, L.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.