Discussion:
problems with gdb in 4.9-2014.09_linux 32-bit
Sergio R. Caprile
2015-09-18 16:20:53 UTC
Permalink
Hello,
I'm starting work on an ARM Cortex-A5 platform.
I've setup a cross-build environment on Centos 6, my toolchain is
gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux since my build system
is 32-bits (I don't have 64-bit hardware/OS available).
I've written a simple hello_world and managed to compile on my build
environment and execute in the target system. However, I can't debug the
application.

#include <stdio.h>

int main(int argc, char **argv)
{
printf("Hello world! (hola mundo) [v2]\n");
return 0;
}
[***@EL-Toradex Hello_world]$
~/gcc-linaro/bin/arm-linux-gnueabihf-gcc -g -o Hello_world main.c

I've already confirmed that the program to debug runs OK, I've connected
via SSH and run it, it just prints a hello message as expected.

When I try to debug, I get a SIGSEGV and then the following reports:
If I use the provided gdbinit in gcc-linaro/share/gdb/gdbinit, I get the
following error:

----------------------------------------------------------------------
/home/toradex/gcc-linaro/share/gdb/gdbinit:6: Error in sourced command file:
Python scripting is not supported in this copy of GDB.
----------------------------------------------------------------------

If I don't, then gdb complains it can't locate source files:

----------------------------------------------------------------------
Can't find a source file at
"/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/.build/src/eglibc-linaro-2.19-2014.08/elf/dl-fini.c"
Locate the file or edit the source lookup path to include its location.
----------------------------------------------------------------------

The SIGSEGV occurs before main(), I can't do anything on startup:

----------------------------------------------------------------------
TARGET:
------
***@colibri-vf:~# gdbserver :2345 /home/root/Hello_world
BUILD:
-----
[***@EL-Toradex ~]$ gcc-linaro/bin/arm-linux-gnueabihf-gdb
workspace/Hello_world/Debug/Hello_world
GNU gdb (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC
4.9-2014.09) 7.6.1-2013.10
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-build_pc-linux-gnu
--target=arm-linux-gnueabihf".
For bug reporting instructions, please see:
<https://bugs.launchpad.net/gcc-linaro>...
Reading symbols from
/media/sf_EL-Toradex/Hello_world/Debug/Hello_world...done.
(gdb) target remote 192.168.1.6:2345
Remote debugging using 192.168.1.6:2345
Reading symbols from
/home/toradex/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3...done.
Loaded symbols for
/home/toradex/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3
process_dl_debug (dl_debug=0x0,
***@entry=<error reading variable: Cannot access memory at
address 0x34>) at rtld.c:2415
2415 rtld.c: No such file or directory.
(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x76fe36f8 in _dl_sort_fini (maps=0x7efff98c, nmaps=0, used=0x0,
ns=<optimized out>) at dl-fini.c:70
70 dl-fini.c: No such file or directory.
(gdb)
----------------------------------------------------------------------


I do need some help here.
Following is what I know how to get out of /proc/mypid/
Thanks.


----------------------------------------------------------------------

AT "ERROR READING VARIABLE"

***@colibri-vf:~# cat /proc/438/maps
00010000-00011000 r-xp 00000000 00:0d 15533 /home/root/Hello_world
00020000-00021000 rw-p 00000000 00:0d 15533 /home/root/Hello_world
76fd8000-76ff7000 r-xp 00000000 00:0d 15010 /lib/ld-2.19-2014.04.so
76ffd000-76ffe000 r-xp 00000000 00:00 0 [sigpage]
76ffe000-77000000 rw-p 0001e000 00:0d 15010 /lib/ld-2.19-2014.04.so
7efdf000-7f000000 rw-p 00000000 00:00 0 [stack]
ffff0000-ffff1000 r-xp 00000000 00:00 0 [vectors]
***@colibri-vf:~# cat /proc/438/stack
[<8002b2c4>] ptrace_stop+0x11c/0x214
[<8002c3b8>] get_signal+0x2c8/0x534
[<80011088>] do_signal+0x1a0/0x3ec
[<80011468>] do_work_pending+0x90/0xd0
[<8000e5e0>] work_pending+0xc/0x20
[<ffffffff>] 0xffffffff
***@colibri-vf:~# cat /proc/438/stat
438 (Hello_world) t 435 438 412 34816 438 1073741824 33 0 0 0 0 0 0 0 20
0 1 0 171447 286720 20 4294967295 65536 66668 2130705728 2130705728
1996328256 0 0 268435456 0 2147660484 0 0 17 0 0 0 0 0 0 132204 132488
135168 2130705997 2130706020 2130706020 2130706405 0
***@colibri-vf:~# cat /proc/438/status
Name: Hello_world
State: t (tracing stop)
Tgid: 438
Ngid: 0
Pid: 438
PPid: 435
TracerPid: 435
Uid: 0 0 0 0
Gid: 0 0 0 0
FDSize: 32
Groups: 0
VmPeak: 304 kB
VmSize: 280 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 80 kB
VmRSS: 80 kB
VmData: 4 kB
VmStk: 136 kB
VmExe: 4 kB
VmLib: 124 kB
VmPTE: 6 kB
VmSwap: 0 kB
Threads: 1
SigQ: 0/819
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000010000000
SigCgt: 0000000000000000
CapInh: 0000000000000000
CapPrm: 0000003fffffffff
CapEff: 0000003fffffffff
CapBnd: 0000003fffffffff
Cpus_allowed: 1
Cpus_allowed_list: 0
voluntary_ctxt_switches: 1
nonvoluntary_ctxt_switches: 0
***@colibri-vf:~# cat /proc/438/syscall
0 0x0 0x0 0x0 0x0 0x0 0x0 0x7efffd40 0x76fd8d40
***@colibri-vf:~#


AFTER "CONTINUE", WHEN "SIGSEGV"
--------------------------------

***@colibri-vf:~# cat /proc/438/maps
00010000-00011000 r-xp 00000000 00:0d 15533 /home/root/Hello_world
00020000-00021000 rw-p 00000000 00:0d 15533 /home/root/Hello_world
76ea1000-76fca000 r-xp 00000000 00:0d 15031 /lib/libc-2.19-2014.04.so
76fca000-76fd2000 ---p 00129000 00:0d 15031 /lib/libc-2.19-2014.04.so
76fd2000-76fd5000 rw-p 00129000 00:0d 15031 /lib/libc-2.19-2014.04.so
76fd5000-76fd8000 rw-p 00000000 00:00 0
76fd8000-76ff7000 r-xp 00000000 00:0d 15010 /lib/ld-2.19-2014.04.so
76ff7000-76ff8000 rw-p 00000000 00:00 0
76ff8000-76ffc000 r--p 00000000 00:0d 14058 /etc/ld.so.cache
76ffc000-76ffd000 rw-p 00000000 00:00 0
76ffd000-76ffe000 r-xp 00000000 00:00 0 [sigpage]
76ffe000-77000000 rw-p 0001e000 00:0d 15010 /lib/ld-2.19-2014.04.so
7efdf000-7f000000 rw-p 00000000 00:00 0
ffff0000-ffff1000 r-xp 00000000 00:00 0 [vectors]
***@colibri-vf:~# cat /proc/438/stack
[<8002b2c4>] ptrace_stop+0x11c/0x214
[<8002c3b8>] get_signal+0x2c8/0x534
[<80011088>] do_signal+0x1a0/0x3ec
[<80011468>] do_work_pending+0x90/0xd0
[<8000e5e0>] work_pending+0xc/0x20
[<ffffffff>] 0xffffffff
***@colibri-vf:~# cat /proc/438/stat
438 (Hello_world) t 435 438 412 34816 438 1073741824 49 0 0 0 0 0 0 0 20
0 1 0 171447 1585152 74 4294967295 65536 66668 2130705728 0 1996371704 0
0 268435456 0 2147660484 0 0 17 0 0 0 0 0 0 132204 132488 135168
2130705997 2130706020 2130706020 2130706405 0
***@colibri-vf:~# cat /proc/438/status
Name: Hello_world
State: t (tracing stop)
Tgid: 438
Ngid: 0
Pid: 438
PPid: 435
TracerPid: 435
Uid: 0 0 0 0
Gid: 0 0 0 0
FDSize: 32
Groups: 0
VmPeak: 1548 kB
VmSize: 1548 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 296 kB
VmRSS: 296 kB
VmData: 24 kB
VmStk: 136 kB
VmExe: 4 kB
VmLib: 1312 kB
VmPTE: 6 kB
VmSwap: 0 kB
Threads: 1
SigQ: 0/819
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000010000000
SigCgt: 0000000000000000
CapInh: 0000000000000000
CapPrm: 0000003fffffffff
CapEff: 0000003fffffffff
CapBnd: 0000003fffffffff
Cpus_allowed: 1
Cpus_allowed_list: 0
voluntary_ctxt_switches: 2
nonvoluntary_ctxt_switches: 1
***@colibri-vf:~# cat /proc/438/syscall
0 0xffffffff 0x1934 0x76ffed90 0x76ea1000 0x0 0x0 0x0 0x76fe36f8
***@colibri-vf:~#

--
Yao Qi
2015-09-24 15:54:54 UTC
Permalink
Hi Sergio,
Post by Sergio R. Caprile
----------------------------------------------------------------------
------
Where do you get this gdbserver? Is it shipped in 4.9-2014.09_linux
toolchain?
Post by Sergio R. Caprile
-----
workspace/Hello_world/Debug/Hello_world
GNU gdb (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC
4.9-2014.09) 7.6.1-2013.10
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-build_pc-linux-gnu
--target=arm-linux-gnueabihf".
<https://bugs.launchpad.net/gcc-linaro>...
Reading symbols from
/media/sf_EL-Toradex/Hello_world/Debug/Hello_world...done.
(gdb) target remote 192.168.1.6:2345
Remote debugging using 192.168.1.6:2345
Reading symbols from
/home/toradex/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3...done.
Loaded symbols for
/home/toradex/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3
process_dl_debug (dl_debug=0x0,
address 0x34>) at rtld.c:2415
2415 rtld.c: No such file or directory.
(gdb) continue
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x76fe36f8 in _dl_sort_fini (maps=0x7efff98c, nmaps=0, used=0x0,
ns=<optimized out>) at dl-fini.c:70
70 dl-fini.c: No such file or directory.
(gdb)
I have no clue why program receives SIGSEGV.
--
Yao
Sergio R. Caprile
2015-09-24 17:09:59 UTC
Permalink
Hi, thanks for answering
gdbserver belongs to the Toradex image file, built from Angstrom
gdb is shipped in Linaro 4.9-2014.09_linux toolchain

There are two problems here:
1- gdbinit has Python script and gdb is not compiled with Python script
support
2- The SIGSEGV after symbol problem

I addressed (1) by not using that gdbinit :^)
I managed to work (2) around by disabling automatic symbol loading.

I've recently updated the Toradex module to the latest image, tomorrow I
will try with that one and eventually with Linaro's own gdbserver

Xiè xie
Post by Yao Qi
Hi Sergio,
Post by Sergio R. Caprile
----------------------------------------------------------------------
------
Where do you get this gdbserver? Is it shipped in 4.9-2014.09_linux
toolchain?
Post by Sergio R. Caprile
-----
workspace/Hello_world/Debug/Hello_world
GNU gdb (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC
4.9-2014.09) 7.6.1-2013.10
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-build_pc-linux-gnu
--target=arm-linux-gnueabihf".
<https://bugs.launchpad.net/gcc-linaro>...
Reading symbols from
/media/sf_EL-Toradex/Hello_world/Debug/Hello_world...done.
(gdb) target remote 192.168.1.6:2345
Remote debugging using 192.168.1.6:2345
Reading symbols from
/home/toradex/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3...done.
Loaded symbols for
/home/toradex/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3
process_dl_debug (dl_debug=0x0,
address 0x34>) at rtld.c:2415
2415 rtld.c: No such file or directory.
(gdb) continue
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x76fe36f8 in _dl_sort_fini (maps=0x7efff98c, nmaps=0, used=0x0,
ns=<optimized out>) at dl-fini.c:70
70 dl-fini.c: No such file or directory.
(gdb)
I have no clue why program receives SIGSEGV.
--
Sergio R. Caprile, Human Being, Bs.As., Argentina
http://www.scaprile.ldir.com.ar/
Sergio R. Caprile
2015-09-25 13:15:54 UTC
Permalink
Works OK with latest Toradex image.
gdbserver problem...
Thanks for the clue, debug messages didn't point to that.
Post by Yao Qi
Hi Sergio,
Post by Sergio R. Caprile
----------------------------------------------------------------------
------
Where do you get this gdbserver? Is it shipped in 4.9-2014.09_linux
toolchain?
Post by Sergio R. Caprile
-----
workspace/Hello_world/Debug/Hello_world
GNU gdb (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC
4.9-2014.09) 7.6.1-2013.10
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-build_pc-linux-gnu
--target=arm-linux-gnueabihf".
<https://bugs.launchpad.net/gcc-linaro>...
Reading symbols from
/media/sf_EL-Toradex/Hello_world/Debug/Hello_world...done.
(gdb) target remote 192.168.1.6:2345
Remote debugging using 192.168.1.6:2345
Reading symbols from
/home/toradex/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3...done.
Loaded symbols for
/home/toradex/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3
process_dl_debug (dl_debug=0x0,
address 0x34>) at rtld.c:2415
2415 rtld.c: No such file or directory.
(gdb) continue
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x76fe36f8 in _dl_sort_fini (maps=0x7efff98c, nmaps=0, used=0x0,
ns=<optimized out>) at dl-fini.c:70
70 dl-fini.c: No such file or directory.
(gdb)
I have no clue why program receives SIGSEGV.
--
Sergio R. Caprile, Human Being, Bs.As., Argentina
http://www.scaprile.ldir.com.ar/
Loading...