1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- Copyright (C) 1992-2021 Free Software Foundation, Inc.
4Contributed by Cygnus Support.  Written by Julia Menapace, Jim Kingdon,
5and David MacKenzie.
6
7Permission is granted to copy, distribute and/or modify this document
8under the terms of the GNU Free Documentation License, Version 1.3 or
9any later version published by the Free Software Foundation; with no
10Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
11Texts.  A copy of the license is included in the section entitled "GNU
12Free Documentation License". -->
13<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
14<head>
15<title>STABS: Local Variable Parameters</title>
16
17<meta name="description" content="STABS: Local Variable Parameters">
18<meta name="keywords" content="STABS: Local Variable Parameters">
19<meta name="resource-type" content="document">
20<meta name="distribution" content="global">
21<meta name="Generator" content="makeinfo">
22<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
23<link href="index.html#Top" rel="start" title="Top">
24<link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index">
25<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
26<link href="Parameters.html#Parameters" rel="up" title="Parameters">
27<link href="Reference-Parameters.html#Reference-Parameters" rel="next" title="Reference Parameters">
28<link href="Register-Parameters.html#Register-Parameters" rel="previous" title="Register Parameters">
29<style type="text/css">
30<!--
31a.summary-letter {text-decoration: none}
32blockquote.smallquotation {font-size: smaller}
33div.display {margin-left: 3.2em}
34div.example {margin-left: 3.2em}
35div.indentedblock {margin-left: 3.2em}
36div.lisp {margin-left: 3.2em}
37div.smalldisplay {margin-left: 3.2em}
38div.smallexample {margin-left: 3.2em}
39div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
40div.smalllisp {margin-left: 3.2em}
41kbd {font-style:oblique}
42pre.display {font-family: inherit}
43pre.format {font-family: inherit}
44pre.menu-comment {font-family: serif}
45pre.menu-preformatted {font-family: serif}
46pre.smalldisplay {font-family: inherit; font-size: smaller}
47pre.smallexample {font-size: smaller}
48pre.smallformat {font-family: inherit; font-size: smaller}
49pre.smalllisp {font-size: smaller}
50span.nocodebreak {white-space:nowrap}
51span.nolinebreak {white-space:nowrap}
52span.roman {font-family:serif; font-weight:normal}
53span.sansserif {font-family:sans-serif; font-weight:normal}
54ul.no-bullet {list-style: none}
55-->
56</style>
57
58
59</head>
60
61<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
62<a name="Local-Variable-Parameters"></a>
63<div class="header">
64<p>
65Next: <a href="Reference-Parameters.html#Reference-Parameters" accesskey="n" rel="next">Reference Parameters</a>, Previous: <a href="Register-Parameters.html#Register-Parameters" accesskey="p" rel="previous">Register Parameters</a>, Up: <a href="Parameters.html#Parameters" accesskey="u" rel="up">Parameters</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
66</div>
67<hr>
68<a name="Storing-Parameters-as-Local-Variables"></a>
69<h4 class="subsection">4.7.2 Storing Parameters as Local Variables</h4>
70
71<p>There is a case similar to an argument in a register, which is an
72argument that is actually stored as a local variable.  Sometimes this
73happens when the argument was passed in a register and then the compiler
74stores it as a local variable.  If possible, the compiler should claim
75that it&rsquo;s in a register, but this isn&rsquo;t always done.
76</p>
77<p>If a parameter is passed as one type and converted to a smaller type by
78the prologue (for example, the parameter is declared as a <code>float</code>,
79but the calling conventions specify that it is passed as a
80<code>double</code>), then GCC2 (sometimes) uses a pair of symbols.  The first
81symbol uses symbol descriptor &lsquo;<samp>p</samp>&rsquo; and the type which is passed.
82The second symbol has the type and location which the parameter actually
83has after the prologue.  For example, suppose the following C code
84appears with no prototypes involved:
85</p>
86<div class="example">
87<pre class="example">void
88subr (f)
89     float f;
90{
91</pre></div>
92
93<p>if <code>f</code> is passed as a double at stack offset 8, and the prologue
94converts it to a float in register number 0, then the stabs look like:
95</p>
96<div class="example">
97<pre class="example">.stabs &quot;f:p13&quot;,160,0,3,8   # <span class="roman">160 is <code>N_PSYM</code>, here 13 is <code>double</code></span>
98.stabs &quot;f:r12&quot;,64,0,3,0    # <span class="roman">64 is <code>N_RSYM</code>, here 12 is <code>float</code></span>
99</pre></div>
100
101<p>In both stabs 3 is the line number where <code>f</code> is declared
102(see <a href="Line-Numbers.html#Line-Numbers">Line Numbers</a>).
103</p>
104<a name="index-N_005fLSYM_002c-for-parameter"></a>
105<p>GCC, at least on the 960, has another solution to the same problem.  It
106uses a single &lsquo;<samp>p</samp>&rsquo; symbol descriptor for an argument which is stored
107as a local variable but uses <code>N_LSYM</code> instead of <code>N_PSYM</code>.  In
108this case, the value of the symbol is an offset relative to the local
109variables for that function, not relative to the arguments; on some
110machines those are the same thing, but not on all.
111</p>
112<p>On the VAX or on other machines in which the calling convention includes
113the number of words of arguments actually passed, the debugger (GDB at
114least) uses the parameter symbols to keep track of whether it needs to
115print nameless arguments in addition to the formal parameters which it
116has printed because each one has a stab.  For example, in
117</p>
118<div class="example">
119<pre class="example">extern int fprintf (FILE *stream, char *format, &hellip;);
120&hellip;
121fprintf (stdout, &quot;%d\n&quot;, x);
122</pre></div>
123
124<p>there are stabs for <code>stream</code> and <code>format</code>.  On most machines,
125the debugger can only print those two arguments (because it has no way
126of knowing that additional arguments were passed), but on the VAX or
127other machines with a calling convention which indicates the number of
128words of arguments, the debugger can print all three arguments.  To do
129so, the parameter symbol (symbol descriptor &lsquo;<samp>p</samp>&rsquo;) (not necessarily
130&lsquo;<samp>r</samp>&rsquo; or symbol descriptor omitted symbols) needs to contain the
131actual type as passed (for example, <code>double</code> not <code>float</code> if it
132is passed as a double and converted to a float).
133</p>
134<hr>
135<div class="header">
136<p>
137Next: <a href="Reference-Parameters.html#Reference-Parameters" accesskey="n" rel="next">Reference Parameters</a>, Previous: <a href="Register-Parameters.html#Register-Parameters" accesskey="p" rel="previous">Register Parameters</a>, Up: <a href="Parameters.html#Parameters" accesskey="u" rel="up">Parameters</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
138</div>
139
140
141
142</body>
143</html>
144