Work around MinGW mangling of "host:/path"
[msysgit/historical-msysgit.git] / mingw / info / stabs / Local-Variable-Parameters.html
blobde42b2cf5e2b4b85f49d7c440c38214fa1eb0ce0
1 <html lang="en">
2 <head>
3 <title>STABS</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="STABS">
6 <meta name="generator" content="makeinfo 4.3">
7 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
8 </head>
9 <body>
10 <div class="node">
11 <p>
12 Node:<a name="Local%20Variable%20Parameters">Local Variable Parameters</a>,
13 Next:<a rel="next" accesskey="n" href="Reference-Parameters.html#Reference%20Parameters">Reference Parameters</a>,
14 Previous:<a rel="previous" accesskey="p" href="Register-Parameters.html#Register%20Parameters">Register Parameters</a>,
15 Up:<a rel="up" accesskey="u" href="Parameters.html#Parameters">Parameters</a>
16 <hr><br>
17 </div>
19 <h4 class="subsection">Storing Parameters as Local Variables</h4>
21 <p>There is a case similar to an argument in a register, which is an
22 argument that is actually stored as a local variable. Sometimes this
23 happens when the argument was passed in a register and then the compiler
24 stores it as a local variable. If possible, the compiler should claim
25 that it's in a register, but this isn't always done.
27 <p>If a parameter is passed as one type and converted to a smaller type by
28 the prologue (for example, the parameter is declared as a <code>float</code>,
29 but the calling conventions specify that it is passed as a
30 <code>double</code>), then GCC2 (sometimes) uses a pair of symbols. The first
31 symbol uses symbol descriptor <code>p</code> and the type which is passed.
32 The second symbol has the type and location which the parameter actually
33 has after the prologue. For example, suppose the following C code
34 appears with no prototypes involved:
36 <pre class="example"> void
37 subr (f)
38 float f;
40 </pre>
42 <p>if <code>f</code> is passed as a double at stack offset 8, and the prologue
43 converts it to a float in register number 0, then the stabs look like:
45 <pre class="example"> .stabs "f:p13",160,0,3,8 # 160 is <code>N_PSYM</code>, here 13 is <code>double</code>
46 .stabs "f:r12",64,0,3,0 # 64 is <code>N_RSYM</code>, here 12 is <code>float</code>
47 </pre>
49 <p>In both stabs 3 is the line number where <code>f</code> is declared
50 (see <a href="Line-Numbers.html#Line%20Numbers">Line Numbers</a>).
52 <p>GCC, at least on the 960, has another solution to the same problem. It
53 uses a single <code>p</code> symbol descriptor for an argument which is stored
54 as a local variable but uses <code>N_LSYM</code> instead of <code>N_PSYM</code>. In
55 this case, the value of the symbol is an offset relative to the local
56 variables for that function, not relative to the arguments; on some
57 machines those are the same thing, but not on all.
59 <p>On the VAX or on other machines in which the calling convention includes
60 the number of words of arguments actually passed, the debugger (GDB at
61 least) uses the parameter symbols to keep track of whether it needs to
62 print nameless arguments in addition to the formal parameters which it
63 has printed because each one has a stab. For example, in
65 <pre class="example"> extern int fprintf (FILE *stream, char *format, ...);
66 ...
67 fprintf (stdout, "%d\n", x);
68 </pre>
70 <p>there are stabs for <code>stream</code> and <code>format</code>. On most machines,
71 the debugger can only print those two arguments (because it has no way
72 of knowing that additional arguments were passed), but on the VAX or
73 other machines with a calling convention which indicates the number of
74 words of arguments, the debugger can print all three arguments. To do
75 so, the parameter symbol (symbol descriptor <code>p</code>) (not necessarily
76 <code>r</code> or symbol descriptor omitted symbols) needs to contain the
77 actual type as passed (for example, <code>double</code> not <code>float</code> if it
78 is passed as a double and converted to a float).
80 </body></html>