Nested Procedures (STABS)

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

### 2.6 Nested Procedures

For any of the symbol descriptors representing procedures, after the symbol descriptor and the type information is optionally a scope specifier. This consists of a comma, the name of the procedure, another comma, and the name of the enclosing procedure. The first name is local to the scope specified, and seems to be redundant with the name of the symbol (before the ‘`:`’). This feature is used by GCC, and presumably Pascal, Modula-2, etc., compilers, for nested functions.

If procedures are nested more than one level deep, only the immediately containing scope is specified. For example, this code:

    int
    foo (int x)
    {
      int bar (int y)
        {
          int baz (int z)
            {
              return x + y + z;
            }
          return baz (x + 2 * y);
        }
      return x + bar (3 * x);
    }

produces the stabs:

    .stabs "baz:f1,baz,bar",36,0,0,_baz.15         # 36 is N_FUN
    .stabs "bar:f1,bar,foo",36,0,0,_bar.12
    .stabs "foo:F1",36,0,0,_foo