OpenWrt Forum Archive

Topic: How to build gdbserver for WhiteRussian?

The content of this topic has been archived on 5 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Is it possible to build gdbserver for WhiteRussian? There doesn't seem to be an ipkg for it, nor a binary in the OpenWrt-SDK.

In the SVN source, I see there's toolchain_build_mipsel/gdb-6.3/gdb/gdbserver/, but when building the system, I don't find a gdbserver binary built, nor a way to build it.

I also see that trunk has a gdbserver package, and it's the same version of gdb (6.3), but it's not in the WhiteRussian backports. So is there a fundamental reason why WhiteRussian can't run gdbserver?



OK, I think I found a way to make this work, thanks to a new wiki entry about native package building

1. Download

2. Mount it and extract the bits needed

bunzip2 root_fs_mipsel.ext2.bz2
mount -o loop root_fs_mipsel.ext2 /mnt
cd /mnt
tar -czf /tmp/gdbserver.tgz usr/bin/gdbserver lib/libthread_db* lib/libgcc_s*

3. Copy /tmp/gdbserver.tgz to the Openwrt box and untar it at the root directory

ssh root@x.x.x.x 'tar -C / -xvzf -' </tmp/gdbserver.tgz

4. Away you go, as per this thread

Target side:

gdbserver /usr/bin/myprog myargs

Host side:

# cd /path/to/myprog/src
# /path/to/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/bin/mipsel-linux-uclibc-gdb ./myprog
gdb> set solib-absolute-prefix /path/to/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel
gdb> target remote x.x.x.x:1234
gdb> cont

In fact, thanks to the hint about 'solib-absolute-prefix', I've managed to get gdb to work with core dumps too:

1. On target: 'ulimit -c unlimited'

2. Run the program, let it dump core, copy the core file to the host

3. On host:

# cd /path/to/myprog/src
# /path/to/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/bin/mipsel-linux-uclibc-gdb ./myprog
gdb> set solib-absolute-prefix /path/to/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel
gdb> target core /path/to/core.xxxx

This doesn't require any messing around with gdbserver.



How to enable  core dump on OpenWrt-Kamikaze-7.09?

I tried following steps but of no use, can you guide me on same?

$echo 2 > /proc/sys/fs/suid_dumpable
$echo 1 > /proc/sys/kernel/core_uses_pid
$echo "/etc/%e-%t-%p.core" >  /proc/sys/kernel/core_pattern
$ulimit -c unlimited


The discussion might have continued from here.