You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Local-Variable-Parameters.html 7.0KB

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