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....
 

Reply via email to