Local-Variable-Parameters.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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-2019 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 5.2, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <title>STABS: Local Variable Parameters</title>
  15. <meta name="description" content="STABS: Local Variable Parameters">
  16. <meta name="keywords" content="STABS: Local Variable Parameters">
  17. <meta name="resource-type" content="document">
  18. <meta name="distribution" content="global">
  19. <meta name="Generator" content="makeinfo">
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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.smallquotation {font-size: smaller}
  31. div.display {margin-left: 3.2em}
  32. div.example {margin-left: 3.2em}
  33. div.indentedblock {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  37. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  49. span.nolinebreak {white-space:nowrap}
  50. span.roman {font-family:serif; font-weight:normal}
  51. span.sansserif {font-family:sans-serif; font-weight:normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  57. <a name="Local-Variable-Parameters"></a>
  58. <div class="header">
  59. <p>
  60. 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>
  61. </div>
  62. <hr>
  63. <a name="Storing-Parameters-as-Local-Variables"></a>
  64. <h4 class="subsection">4.7.2 Storing Parameters as Local Variables</h4>
  65. <p>There is a case similar to an argument in a register, which is an
  66. argument that is actually stored as a local variable. Sometimes this
  67. happens when the argument was passed in a register and then the compiler
  68. stores it as a local variable. If possible, the compiler should claim
  69. that it&rsquo;s in a register, but this isn&rsquo;t always done.
  70. </p>
  71. <p>If a parameter is passed as one type and converted to a smaller type by
  72. the prologue (for example, the parameter is declared as a <code>float</code>,
  73. but the calling conventions specify that it is passed as a
  74. <code>double</code>), then GCC2 (sometimes) uses a pair of symbols. The first
  75. symbol uses symbol descriptor &lsquo;<samp>p</samp>&rsquo; and the type which is passed.
  76. The second symbol has the type and location which the parameter actually
  77. has after the prologue. For example, suppose the following C code
  78. appears with no prototypes involved:
  79. </p>
  80. <div class="example">
  81. <pre class="example">void
  82. subr (f)
  83. float f;
  84. {
  85. </pre></div>
  86. <p>if <code>f</code> is passed as a double at stack offset 8, and the prologue
  87. converts it to a float in register number 0, then the stabs look like:
  88. </p>
  89. <div class="example">
  90. <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>
  91. .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>
  92. </pre></div>
  93. <p>In both stabs 3 is the line number where <code>f</code> is declared
  94. (see <a href="Line-Numbers.html#Line-Numbers">Line Numbers</a>).
  95. </p>
  96. <a name="index-N_005fLSYM_002c-for-parameter"></a>
  97. <p>GCC, at least on the 960, has another solution to the same problem. It
  98. uses a single &lsquo;<samp>p</samp>&rsquo; symbol descriptor for an argument which is stored
  99. as a local variable but uses <code>N_LSYM</code> instead of <code>N_PSYM</code>. In
  100. this case, the value of the symbol is an offset relative to the local
  101. variables for that function, not relative to the arguments; on some
  102. machines those are the same thing, but not on all.
  103. </p>
  104. <p>On the VAX or on other machines in which the calling convention includes
  105. the number of words of arguments actually passed, the debugger (GDB at
  106. least) uses the parameter symbols to keep track of whether it needs to
  107. print nameless arguments in addition to the formal parameters which it
  108. has printed because each one has a stab. For example, in
  109. </p>
  110. <div class="example">
  111. <pre class="example">extern int fprintf (FILE *stream, char *format, &hellip;);
  112. &hellip;
  113. fprintf (stdout, &quot;%d\n&quot;, x);
  114. </pre></div>
  115. <p>there are stabs for <code>stream</code> and <code>format</code>. On most machines,
  116. the debugger can only print those two arguments (because it has no way
  117. of knowing that additional arguments were passed), but on the VAX or
  118. other machines with a calling convention which indicates the number of
  119. words of arguments, the debugger can print all three arguments. To do
  120. so, the parameter symbol (symbol descriptor &lsquo;<samp>p</samp>&rsquo;) (not necessarily
  121. &lsquo;<samp>r</samp>&rsquo; or symbol descriptor omitted symbols) needs to contain the
  122. actual type as passed (for example, <code>double</code> not <code>float</code> if it
  123. is passed as a double and converted to a float).
  124. </p>
  125. <hr>
  126. <div class="header">
  127. <p>
  128. 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>
  129. </div>
  130. </body>
  131. </html>