www.delorie.com/gnu/docs/gdb/stabs_19.html   search  
 
Buy the book!


STABS

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 Global Variables

A variable whose scope is not specific to just one source file is represented by the `G' symbol descriptor. These stabs use the N_GSYM stab type (C_GSYM for XCOFF). The type information for the stab (see section 1.3 The String Field) gives the type of the variable.

For example, the following source code:

 
char g_foo = 'c';

yields the following assembly code:

 
.stabs "g_foo:G2",32,0,0,0     # 32 is N_GSYM
     .global _g_foo
     .data
_g_foo:
     .byte 99

The address of the variable represented by the N_GSYM is not contained in the N_GSYM stab. The debugger gets this information from the external symbol for the global variable. In the example above, the .global _g_foo and _g_foo: lines tell the assembler to produce an external symbol.

Some compilers, like GCC, output N_GSYM stabs only once, where the variable is defined. Other compilers, like SunOS4 /bin/cc, output a N_GSYM stab for each compilation unit which references the variable.


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003