Regis ALTMAYER wrote:

> Hi.
>
> Here is a problem I noticed using gdb on two SOLARIS Intel plateforms (uname -a: 
>SunOS pcxlg6 5.7 Generic_106542-08 i86pc i386 i86pc), with two different backgrounds:
>
> Background1:
> gcc -v :
> Reading specs from /usr/local/lib/gcc-lib/i386-pc-solaris2.6/2.8.1/specs
> gcc version 2.8.1
>
> gdb -v :
> GNU gdb 4.17
> Copyright 1998 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 "i386-pc-solaris2.7".
>
>
> Background 2:
> gcc -v:
> Reading specs from /usr/local/lib/gcc-lib/i386-pc-solaris2.7/2.95.2/specs
> gcc version 2.95.2 19991024 (release)
>
> gdb -v
> GNU gdb 4.17
> Copyright 1998 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 "i386-pc-solaris2.7".
>
>
> Source code:
> #include <stdio.h>
> #define SIZE_OF_P 256
> typedef struct {
>         char *p;
>         int length;
>         struct struct_kw_t *next;
>         struct struct_kw_t *output_next;
> } struct_kw_t;
>
> static struct_kw_t P[SIZE_OF_P];
> struct_kw_t LastNext;
> struct_kw_t LastOutputNext;
>
> main () {
> char *Z="YOUAREBEAUTIFUL";
> P[0].length=2;
> P[SIZE_OF_P -1 ].length=2;
> P[SIZE_OF_P -1 ].next=(struct struct_kw_t *)&LastNext;
> P[SIZE_OF_P -1 ].output_next=(struct struct_kw_t *)&LastOutputNext;
> P[SIZE_OF_P -1 ].p = Z ;
>
> printf("%s\n", P[SIZE_OF_P -1].p );fflush(stdout);
> }
>
> Problem:
> When I compile the above mentioned source code in the background1, I can access  the 
>content of the array 'P' through gdb; when I compile the same above mentioned source 
>code in the background2, I
> can not access the content of the array P through gdb (not allowed for address 0x0, 
>it says !!)
> There is no problem if I use an array P which is not static.
> I have also tried to modify the release for gcc (just in case), and to install its 
>version 2.8.1 on the machine with the background2. No difference; it still doesn't 
>work.
> My 2 machines have the same libc library (ldd : /usr/lib/libc.so.1 (954804 bytes Oct 
>14  1999) - /usr/lib/libdl.so.1 (4396 bytes Aug 12  1999).
> Any piece of advice is welcome....
>

Hi,
I have checked the above test program with following tools: gcc2.95.1, gdb4.18, OS  
Solaris 7.
Everything works fine. It's possible to access P (see below)

Best regards,

Bernd Stoehr

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


Here is the output trace:

gcc -ggdb test_for_bug.c
 murilo#/home/bernd_s/work/C: gcc -v
Reading specs from 
/tools/gnu2/stow/gcc-2.95.1/sun55/lib/gcc-lib/sparc-sun-solaris2.5/2.95.1/specs
gcc version 2.95.1 19990816 (release)
 murilo#/home/bernd_s/work/C: gdb a.out
GNU gdb 4.18
Copyright 1998 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 "sparc-sun-solaris2.5"...
(gdb) b test_for_bug.c:16
Breakpoint 1 at 0x109dc: file test_for_bug.c, line 16.
(gdb) run
Starting program: /home/bernd_s/work/C/a.out

Breakpoint 1, main () at test_for_bug.c:16
16      P[0].length=2;
(gdb) next
17      P[SIZE_OF_P -1 ].length=2;
(gdb) print P
$1 = {{p = 0x0, length = 2, next = 0x0, output_next = 0x0}, {p = 0x0, length = 0, next 
= 0x0,
    output_next = 0x0} <repeats 255 times>}
(gdb)


--
Bernd Stoehr                  | Motorola GmbH, Munich, Germany
Verification & Test Section   | Tel: +49-89-92103-392
SPS/SoCDT/SoC Design Platform | Email: [EMAIL PROTECTED]
[x] General Business Use  [ ] Internal Use Only  [ ] Confidential Proprietary



  • Bug ? Regis ALTMAYER
    • Bernd Stoehr

Reply via email to