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.

162 satır
7.2KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Ambiguous Expressions (Debugging with GDB)</title>
  17. <meta name="description" content="Ambiguous Expressions (Debugging with GDB)">
  18. <meta name="keywords" content="Ambiguous Expressions (Debugging with GDB)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Data.html#Data" rel="up" title="Data">
  26. <link href="Variables.html#Variables" rel="next" title="Variables">
  27. <link href="Expressions.html#Expressions" rel="prev" title="Expressions">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style: oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; 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">
  57. <a name="Ambiguous-Expressions"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Variables.html#Variables" accesskey="n" rel="next">Variables</a>, Previous: <a href="Expressions.html#Expressions" accesskey="p" rel="prev">Expressions</a>, Up: <a href="Data.html#Data" accesskey="u" rel="up">Data</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  61. </div>
  62. <hr>
  63. <a name="Ambiguous-Expressions-1"></a>
  64. <h3 class="section">10.2 Ambiguous Expressions</h3>
  65. <a name="index-ambiguous-expressions"></a>
  66. <p>Expressions can sometimes contain some ambiguous elements. For instance,
  67. some programming languages (notably Ada, C<tt>++</tt> and Objective-C) permit
  68. a single function name to be defined several times, for application in
  69. different contexts. This is called <em>overloading</em>. Another example
  70. involving Ada is generics. A <em>generic package</em> is similar to C<tt>++</tt>
  71. templates and is typically instantiated several times, resulting in
  72. the same function name being defined in different contexts.
  73. </p>
  74. <p>In some cases and depending on the language, it is possible to adjust
  75. the expression to remove the ambiguity. For instance in C<tt>++</tt>, you
  76. can specify the signature of the function you want to break on, as in
  77. <kbd>break <var>function</var>(<var>types</var>)</kbd>. In Ada, using the fully
  78. qualified name of your function often makes the expression unambiguous
  79. as well.
  80. </p>
  81. <p>When an ambiguity that needs to be resolved is detected, the debugger
  82. has the capability to display a menu of numbered choices for each
  83. possibility, and then waits for the selection with the prompt &lsquo;<samp>&gt;</samp>&rsquo;.
  84. The first option is always &lsquo;<samp>[0] cancel</samp>&rsquo;, and typing <kbd>0 <span class="key">RET</span></kbd>
  85. aborts the current command. If the command in which the expression was
  86. used allows more than one choice to be selected, the next option in the
  87. menu is &lsquo;<samp>[1] all</samp>&rsquo;, and typing <kbd>1 <span class="key">RET</span></kbd> selects all possible
  88. choices.
  89. </p>
  90. <p>For example, the following session excerpt shows an attempt to set a
  91. breakpoint at the overloaded symbol <code>String::after</code>.
  92. We choose three particular definitions of that function name:
  93. </p>
  94. <div class="smallexample">
  95. <pre class="smallexample">(gdb) b String::after
  96. [0] cancel
  97. [1] all
  98. [2] file:String.cc; line number:867
  99. [3] file:String.cc; line number:860
  100. [4] file:String.cc; line number:875
  101. [5] file:String.cc; line number:853
  102. [6] file:String.cc; line number:846
  103. [7] file:String.cc; line number:735
  104. &gt; 2 4 6
  105. Breakpoint 1 at 0xb26c: file String.cc, line 867.
  106. Breakpoint 2 at 0xb344: file String.cc, line 875.
  107. Breakpoint 3 at 0xafcc: file String.cc, line 846.
  108. Multiple breakpoints were set.
  109. Use the &quot;delete&quot; command to delete unwanted
  110. breakpoints.
  111. (gdb)
  112. </pre></div>
  113. <dl compact="compact">
  114. <dd><a name="index-set-multiple_002dsymbols"></a>
  115. </dd>
  116. <dt><code>set multiple-symbols <var>mode</var></code></dt>
  117. <dd><a name="index-multiple_002dsymbols-menu"></a>
  118. <p>This option allows you to adjust the debugger behavior when an expression
  119. is ambiguous.
  120. </p>
  121. <p>By default, <var>mode</var> is set to <code>all</code>. If the command with which
  122. the expression is used allows more than one choice, then <small>GDB</small>
  123. automatically selects all possible choices. For instance, inserting
  124. a breakpoint on a function using an ambiguous name results in a breakpoint
  125. inserted on each possible match. However, if a unique choice must be made,
  126. then <small>GDB</small> uses the menu to help you disambiguate the expression.
  127. For instance, printing the address of an overloaded function will result
  128. in the use of the menu.
  129. </p>
  130. <p>When <var>mode</var> is set to <code>ask</code>, the debugger always uses the menu
  131. when an ambiguity is detected.
  132. </p>
  133. <p>Finally, when <var>mode</var> is set to <code>cancel</code>, the debugger reports
  134. an error due to the ambiguity and the command is aborted.
  135. </p>
  136. <a name="index-show-multiple_002dsymbols"></a>
  137. </dd>
  138. <dt><code>show multiple-symbols</code></dt>
  139. <dd><p>Show the current value of the <code>multiple-symbols</code> setting.
  140. </p></dd>
  141. </dl>
  142. <hr>
  143. <div class="header">
  144. <p>
  145. Next: <a href="Variables.html#Variables" accesskey="n" rel="next">Variables</a>, Previous: <a href="Expressions.html#Expressions" accesskey="p" rel="prev">Expressions</a>, Up: <a href="Data.html#Data" accesskey="u" rel="up">Data</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
  146. </div>
  147. </body>
  148. </html>