gdb/1992: ARM GNU/Linux GCC C remote

ymorin.ext@rd.francetelecom.com ymorin.ext@rd.francetelecom.com
Thu Aug 25 18:58:00 GMT 2005


>Number:         1992
>Category:       gdb
>Synopsis:       ARM GNU/Linux GCC C remote
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 19 14:08:00 UTC 2005
>Closed-Date:
>Last-Modified:
>Originator:     ymorin.ext@rd.francetelecom.com
>Release:        6.3.50.20050818
>Organization:
>Environment:
uname -a
Linux leminkainen 2.4.27-0.pre2.1mdkenterprise #1 SMP Fri Jun 4 03:42:09 CEST 2004 i686 Intel(R) Pentium(R) 4 CPU 2.50GHz unknown GNU/Linux

gcc -v
Reading specs from /usr/lib/gcc/i586-mandrake-linux-gnu/3.4.3/specs
Configured with: ../configure --prefix=/usr --libexecdir=/usr/lib --with-slibdir=/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --enable-long-long --enable-__cxa_atexit --enable-clocale=gnu --disable-libunwind-exceptions --enable-languages=c,c++,ada,f77,objc,java --host=i586-mandrake-linux-gnu --with-system-zlib
Thread model: posix
gcc version 3.4.3 (Mandrakelinux 10.2 3.4.3-7mdk)

gdb
This GDB was configured as "--host=i686-pc-linux-gnu --target=armv5b-xscale-linux-gnu".
>Description:
gdb segfaults and dumps core when stepping over a call to a symbol in a dynamicaly loaded library

It has been observed using:
6.3.0
6.3.0-20050818
6.3.50-20050818
>How-To-Repeat:
See in attachment.
>Fix:
Workaround: use static linking.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="gdb.txt"
Content-Disposition: inline; filename="gdb.txt"

Brief /
-----'

gdb-6.3.50-20050818 and gdb-6.3.0-20050818 segfault and dump core when remote
debugging on an ARM target.


Environement /
------------'

The native toolchain is based on:
   gcc-3.4.3
   glibc-2.3.4
   binutils-2.15.92.0.2
   linux headers ?
   threading model and version ?
This is the Mandrake 10.1 updated with some 10.2 packages.

The cross-toolchain is based on:
   gcc-3.4.4
   glibc-2.3.5
   binutils-2.15.91.0.2
   linux-libc-headers-2.6.12.0
   glibc-linuxthreads-2.3.5

Build triplets:  i686-pc-linux-gnu
Host triplets:   i686-pc-linux-gnu
Target triplets: armv5b-xscale-linux-gnu

Built with crosstool (http://www.kegel.com/crosstool) configured with (extract):
   --prefix=/opt/arm-glibc
   --with-sysroot=$prefix/$target/sys-root
   soft-float   

Plus, for gcc, to force Xscale processor as a default:
   --with-cpu=xscale
   --enable-cxx-flags=-mcpu=xscale

How gdb was installed /
---------------------'

tar xfj gdb-6.3.50.20050818.tar.bz2
mv gdb-6.3.50.20050818 gdb
mkdir build-gdb
cd build-gdb
../gdb/configure \
   --build=`../gdb/config.guess` --host=`../gdb/config.guess` --target=armv5b-xscale-linux-gnu \
   --prefix=/opt/arm-glibc \
   --with-mpfr --with-gmp \
   --with-build-sysroot=/opt/arm-glibc/armv5b-xscale-linux-gnu/sys-root
   --enable-serial-configure
make
make install
cd ..
mkdir build-gdbserver
cd build-gdbserver
CC=armv5b-xscale-linux-gnu-gcc ../gdb/gdb/gdbserver/configure \
   --build=`../gdb/config.guess` \
   --host=armv5b-xscale-linux-gnu \
   --target=armv5b-xscale-linux-gnu \
   --prefix=/home/ymorin/boot/root \
   --infodir=/home/ymorin/info \
   --mandir=/home/ymorin/man \
   --program-prefix=""
make
make install

   
The program being debugged /
--------------------------'

main.c:
01:#include <stdio.h>
02:#include <stdlib.h>
03:#include <string.h>
04:
05:int main( int argc,
06:          char** argv )
07:{
08:    char hostname[1024];
09:    FILE* p;
10:    int i = 0;
11:    memset( hostname, 0, 1024 );
12:    p = popen( "/bin/hostname", "r" );
13:    fread( hostname, 1024, 1, p );
14:    pclose( p );
15:    for( i = 0; ( hostname[i] != 0 ) && ( hostname[i] != '\n' ); i++ ) ;
16:    hostname[i] = 0;
17:    printf( "Hello world! I'm running on \"%s\"\n", hostname );
18:    return 0;
19:}

Compiled with:
armv5b-xscale-linux-gnu-gcc -O0 -g3 -o Test

"armv5b-xscale-linux-gnu-readelf Test" says libc.so.6 is NEEDED


Debugging session /
-----------------'

On target:
$ /bin/Test
Hello world! I'm running on "target"
$ gdbserver host:10000 /bin/Test
Process /bin/Test created; pid = 113
Listening on port 10000

On host:
$ armv5b-xscale-linux-gnu-gdb
GNU gdb 6.3.50.20050818
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=armv5b-xscale-linux-gnu".
(gdb) target remote target:10000
Remote debugging using target:10000
0x40000a40 in ?? ()
[Note: here, targets says: "Remote debugging from host 192.168.0.1"]
(gdb) symbol Test
Reading symbols from /some/place/Test...done.
(gdb) break main
Breakpoint 1 at 0x8580: file ../src/main.c, line 10.
(gdb) cont
Continuing.

Breakpoint 1, main (argc=1, argv=0xbffffed4) at ../src/main.c:10
10          int i = 0;
(gdb) s
Cannot access memory at address 0x0
11          memset( hostname, 0, 1024 );
(gdb) s
Segmentation fault (core dumped)
[Note: here; targets says:
"readchar: Got EOF
"Remote side has terminated connection.  GDBserver will reopen the connection.
"Listening on port 10000
]


Looking at what happened /
------------------------'

$ gdb
GNU gdb 6.3-3.1.102mdk (Mandrakelinux)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i586-mandrake-linux-gnu".
(gdb) core core.31730
Core was generated by `armv5b-xscale-linux-gnu-gdb'.
Program terminated with signal 11, Segmentation fault.
#0  0x0805bb28 in ?? ()
(gdb) symbol /opt/arm-glibc/bin/armv5b-xscale-linux-gnu-gdb
Reading symbols from /opt/arm-glibc/bin/armv5b-xscale-linux-gnu-gdb...done.
Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) bt
#0  0x0805bb28 in get_frame_pc (frame=0x0) at ../../gdb/gdb/frame.c:1321
#1  0x080c5a7a in insert_step_resume_breakpoint_at_frame (return_frame=0x0) at ../../gdb/gdb/infrun.c:2749
#2  0x080c8f92 in handle_inferior_event (ecs=0xbfffdf40) at ../../gdb/gdb/infrun.c:2388
#3  0x080c9638 in wait_for_inferior () at ../../gdb/gdb/infrun.c:1000
#4  0x080c97c5 in proceed (addr=1, siggnal=1075553728, step=1) at ../../gdb/gdb/infrun.c:825
#5  0x080c3099 in step_1 (skip_subroutines=0, single_inst=0, count_string=0x0) at ../../gdb/gdb/infcmd.c:717
#6  0x0805477e in execute_command (p=0x8251ae1 "", from_tty=1) at ../../gdb/gdb/top.c:450
#7  0x080d380e in command_handler (command=0x8251ae0 "s") at ../../gdb/gdb/event-top.c:508
#8  0x080d3e23 in command_line_handler (rl=0x82c6948 "@ë%\b") at ../../gdb/gdb/event-top.c:793
#9  0x08163bd2 in rl_callback_read_char () at ../../gdb/readline/callback.c:123
#10 0x080d31da in rl_callback_read_char_wrapper (client_data=0x0) at ../../gdb/gdb/event-top.c:174
#11 0x080d2a47 in handle_file_event (event_file_desc=0) at ../../gdb/gdb/event-loop.c:728
#12 0x080d2516 in process_event () at ../../gdb/gdb/event-loop.c:341
#13 0x080d2d55 in gdb_do_one_event (data=0x0) at ../../gdb/gdb/event-loop.c:378
#14 0x080d00ac in catch_errors (func=0x80d2c20 <gdb_do_one_event>, func_args=0x0, errstring=0x81bce7f <Error reading address 0x81bce7f: No such file or directory>, mask=6) at ../../gdb/gdb/exceptions.c:515
#15 0x08084543 in tui_command_loop (data=0x0) at ../../gdb/gdb/tui/tui-interp.c:151
#16 0x080d036c in current_interp_command_loop () at ../../gdb/gdb/interps.c:278
#17 0x0804b85a in captured_command_loop (data=0x0) at ../../gdb/gdb/main.c:92
#18 0x080d00ac in catch_errors (func=0x804b850 <captured_command_loop>, func_args=0x0, errstring=0x81bce7f <Error reading address 0x81bce7f: No such file or directory>, mask=6)
    at ../../gdb/gdb/exceptions.c:515
#19 0x0804bf48 in captured_main (data=0x8251808) at ../../gdb/gdb/main.c:797
#20 0x080d00ac in catch_errors (func=0x804b890 <captured_main>, func_args=0xbfffe430, errstring=0x81bce7f <Error reading address 0x81bce7f: No such file or directory>, mask=6)
    at ../../gdb/gdb/exceptions.c:515
#21 0x0804c602 in gdb_main (args=0x0) at ../../gdb/gdb/main.c:806
#22 0x0804b83d in main (argc=0, argv=0x0) at ../../gdb/gdb/gdb.c:35
(gdb) quit



More information about the Gdb-prs mailing list