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: Register Parameters</title>
16
17<meta name="description" content="STABS: Register Parameters">
18<meta name="keywords" content="STABS: Register 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="Local-Variable-Parameters.html#Local-Variable-Parameters" rel="next" title="Local Variable Parameters">
28<link href="Parameters.html#Parameters" rel="previous" title="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="Register-Parameters"></a>
63<div class="header">
64<p>
65Next: <a href="Local-Variable-Parameters.html#Local-Variable-Parameters" accesskey="n" rel="next">Local Variable 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="Passing-Parameters-in-Registers"></a>
69<h4 class="subsection">4.7.1 Passing Parameters in Registers</h4>
70
71<p>If the parameter is passed in a register, then traditionally there are
72two symbols for each argument:
73</p>
74<div class="example">
75<pre class="example">.stabs &quot;arg:p1&quot; . . .       ; N_PSYM
76.stabs &quot;arg:r1&quot; . . .       ; N_RSYM
77</pre></div>
78
79<p>Debuggers use the second one to find the value, and the first one to
80know that it is an argument.
81</p>
82<a name="index-C_005fRPSYM"></a>
83<a name="index-N_005fRSYM_002c-for-parameters"></a>
84<p>Because that approach is kind of ugly, some compilers use symbol
85descriptor &lsquo;<samp>P</samp>&rsquo; or &lsquo;<samp>R</samp>&rsquo; to indicate an argument which is in a
86register.  Symbol type <code>C_RPSYM</code> is used in XCOFF and <code>N_RSYM</code>
87is used otherwise.  The symbol&rsquo;s value is the register number.  &lsquo;<samp>P</samp>&rsquo;
88and &lsquo;<samp>R</samp>&rsquo; mean the same thing; the difference is that &lsquo;<samp>P</samp>&rsquo; is a
89GNU invention and &lsquo;<samp>R</samp>&rsquo; is an IBM (XCOFF) invention.  As of version
904.9, GDB should handle either one.
91</p>
92<p>There is at least one case where GCC uses a &lsquo;<samp>p</samp>&rsquo; and &lsquo;<samp>r</samp>&rsquo; pair
93rather than &lsquo;<samp>P</samp>&rsquo;; this is where the argument is passed in the
94argument list and then loaded into a register.
95</p>
96<p>According to the AIX documentation, symbol descriptor &lsquo;<samp>D</samp>&rsquo; is for a
97parameter passed in a floating point register.  This seems
98unnecessary&mdash;why not just use &lsquo;<samp>R</samp>&rsquo; with a register number which
99indicates that it&rsquo;s a floating point register?  I haven&rsquo;t verified
100whether the system actually does what the documentation indicates.
101</p>
102<p>On the sparc and hppa, for a &lsquo;<samp>P</samp>&rsquo; symbol whose type is a structure
103or union, the register contains the address of the structure.  On the
104sparc, this is also true of a &lsquo;<samp>p</samp>&rsquo; and &lsquo;<samp>r</samp>&rsquo; pair (using Sun
105<code>cc</code>) or a &lsquo;<samp>p</samp>&rsquo; symbol.  However, if a (small) structure is
106really in a register, &lsquo;<samp>r</samp>&rsquo; is used.  And, to top it all off, on the
107hppa it might be a structure which was passed on the stack and loaded
108into a register and for which there is a &lsquo;<samp>p</samp>&rsquo; and &lsquo;<samp>r</samp>&rsquo; pair!  I
109believe that symbol descriptor &lsquo;<samp>i</samp>&rsquo; is supposed to deal with this
110case (it is said to mean &quot;value parameter by reference, indirect
111access&quot;; I don&rsquo;t know the source for this information), but I don&rsquo;t know
112details or what compilers or debuggers use it, if any (not GDB or GCC).
113It is not clear to me whether this case needs to be dealt with
114differently than parameters passed by reference (see <a href="Reference-Parameters.html#Reference-Parameters">Reference Parameters</a>).
115</p>
116<hr>
117<div class="header">
118<p>
119Next: <a href="Local-Variable-Parameters.html#Local-Variable-Parameters" accesskey="n" rel="next">Local Variable 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>
120</div>
121
122
123
124</body>
125</html>
126