From: frazer AT rtp DOT ericsson DOT se Newsgroups: comp.os.msdos.djgpp Subject: GDB and static variables Date: Wed, 22 Jan 1997 16:38:17 GMT Organization: Ericsson Data Services Americas Lines: 95 Message-ID: <5c553u$jr6@cnn.exu.ericsson.se> NNTP-Posting-Host: pc340.rtp.ericsson.se To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp I am having problems with GDB and static variables. GDB seems to have problems with debugging information for uninitialized static variables. Here is a test program which exhibits the strangeness: ---------------------------- /* main.c */ int uninitialized_global_variable; int initialized_global_variable = 1; static int uninitialized_static_variable; static int initialized_static_variable = 1; int main( void ) { uninitialized_global_variable = initialized_global_variable; uninitialized_static_variable = initialized_static_variable; return( 0 ); } ---------------------------- Now I compile with DJGPP v2.01 and GCC 2.7.2.1: C:\TEST>gcc -c -m486 -Wall -g -o main.o main.c C:\TEST>gcc -g -o test.exe main.o C:\TEST> Now into GDB v4.16: C:\TEST>gdb test.exe GDB is free software and you are welcome to 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. GDB 4.16 (go32), Copyright 1996 Free Software Foundation, Inc... (gdb) info variables All defined variables: File _globals_: int initialized_global_variable; int uninitialized_global_variable; File main.c: static int initialized_static_variable; Non-debugging symbols: 00006a00 __djgpp_memory_handle_pointer 00006a00 djgpp_first_dtor 00006a00 djgpp_last_dtor 00006a00 djgpp_first_ctor 00006a00 djgpp_last_ctor 00006a04 sbrk16_first_byte 00006a70 sbrk16_api_ofs 00006a70 sbrk16_last_byte 00006a74 sbrk16_api_seg 00006a76 zero < etc., etc., etc. > 00007208 _what_we_return_to_app_as_old_size 0000720c _what_size_dpmi_thinks_we_are 00007210 uninitialized_static_variable 00007214 _emu_entry 00007218 exception_stack < etc., etc., etc. > (gdb) Why is the uninitialized static variable a "Non-debugging symbol"? I tried compiling with "-ggdb" ( unsupported ) and "-g3" ( no change in behavior ). I also tried debugging the COFF output, but it was the same. Now if it was just simple "int"s or "double"s or whatever I could just muddle through by using GDB's "print /FMT", but in my real program I have static struct's and without the debugging information I can't get to the data members. To further add to the weirdness, when I first enter a module with the static struct's, GDB understands the struct and I can get to the data members. But after I leave the module and come back in later in the program, GDB has forgotten the format of the struct. When I try to get to one of the data members GDB says "Attempt to extract a component of a value that is not a structure." Help! Scott Frazer