STABS: Parameters

Previous: Based Variables, Up: Variables [Contents][Index]

### 4.7 Parameters

Formal parameters to a function are represented by a stab (or sometimes two; see below) for each parameter. The stabs are in the order in which the debugger should print the parameters (i.e., the order in which the parameters are declared in the source file). The exact form of the stab depends on how the parameter is being passed.

Parameters passed on the stack use the symbol descriptor ‘`p`’ and the `N_PSYM` symbol type (or `C_PSYM` for XCOFF). The value of the symbol is an offset used to locate the parameter on the stack; its exact meaning is machine-dependent, but on most machines it is an offset from the frame pointer.

As a simple example, the code:

    main (argc, argv)
         int argc;
         char **argv;

produces the stabs:

    .stabs "main:F1",36,0,0,_main                 # 36 is N_FUN
    .stabs "argc:p1",160,0,0,68                   # 160 is N_PSYM
    .stabs "argv:p20=*21=*2",160,0,0,72

The type definition of `argv` is interesting because it contains several type definitions. Type 21 is pointer to type 2 (char) and `argv` (type 20) is pointer to type 21.

The following symbol descriptors are also said to go with `N_PSYM`. The value of the symbol is said to be an offset from the argument pointer (I’m not sure whether this is true or not).

    pP (<<??>>)
    pF Fortran function parameter
    X  (function result variable)

Previous: Based Variables, Up: Variables [Contents][Index]