Line Numbers (STABS)

Next: Procedures, Previous: Include Files, Up: Program Structure [Contents][Index]

### 2.4 Line Numbers

An `N_SLINE` symbol represents the start of a source line. The desc field contains the line number and the value contains the code address for the start of that source line. On most machines the address is absolute; for stabs in sections (see Stab Sections), it is relative to the function in which the `N_SLINE` symbol occurs.

GNU documents `N_DSLINE` and `N_BSLINE` symbols for line numbers in the data or bss segments, respectively. They are identical to `N_SLINE` but are relocated differently by the linker. They were intended to be used to describe the source location of a variable declaration, but I believe that GCC2 actually puts the line number in the desc field of the stab for the variable itself. GDB has been ignoring these symbols (unless they contain a string field) since at least GDB 3.5.

For single source lines that generate discontiguous code, such as flow of control statements, there may be more than one line number entry for the same source line. In this case there is a line number entry at the start of each code range, each with the same line number.

XCOFF does not use stabs for line numbers. Instead, it uses COFF line numbers (which are outside the scope of this document). Standard COFF line numbers cannot deal with include files, but in XCOFF this is fixed with the `C_BINCL` method of marking include files (see Include Files).