Explicit-Locations.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 5.1, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>Debugging with GDB: Explicit Locations</title>
  16. <meta name="description" content="Debugging with GDB: Explicit Locations">
  17. <meta name="keywords" content="Debugging with GDB: Explicit Locations">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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="Specify-Location.html#Specify-Location" rel="up" title="Specify Location">
  26. <link href="Address-Locations.html#Address-Locations" rel="next" title="Address Locations">
  27. <link href="Linespec-Locations.html#Linespec-Locations" rel="previous" title="Linespec Locations">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.indentedblock {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.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  50. span.nolinebreak {white-space:nowrap}
  51. span.roman {font-family:serif; font-weight:normal}
  52. span.sansserif {font-family:sans-serif; font-weight:normal}
  53. ul.no-bullet {list-style: none}
  54. -->
  55. </style>
  56. </head>
  57. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  58. <a name="Explicit-Locations"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Address-Locations.html#Address-Locations" accesskey="n" rel="next">Address Locations</a>, Previous: <a href="Linespec-Locations.html#Linespec-Locations" accesskey="p" rel="previous">Linespec Locations</a>, Up: <a href="Specify-Location.html#Specify-Location" accesskey="u" rel="up">Specify Location</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>
  62. </div>
  63. <hr>
  64. <a name="Explicit-Locations-1"></a>
  65. <h4 class="subsection">9.2.2 Explicit Locations</h4>
  66. <a name="index-explicit-locations"></a>
  67. <p><em>Explicit locations</em> allow the user to directly specify the source
  68. location&rsquo;s parameters using option-value pairs.
  69. </p>
  70. <p>Explicit locations are useful when several functions, labels, or
  71. file names have the same name (base name for files) in the program&rsquo;s
  72. sources. In these cases, explicit locations point to the source
  73. line you meant more accurately and unambiguously. Also, using
  74. explicit locations might be faster in large programs.
  75. </p>
  76. <p>For example, the linespec &lsquo;<samp>foo:bar</samp>&rsquo; may refer to a function <code>bar</code>
  77. defined in the file named <samp>foo</samp> or the label <code>bar</code> in a function
  78. named <code>foo</code>. <small>GDB</small> must search either the file system or
  79. the symbol table to know.
  80. </p>
  81. <p>The list of valid explicit location options is summarized in the
  82. following table:
  83. </p>
  84. <dl compact="compact">
  85. <dt><code>-source <var>filename</var></code></dt>
  86. <dd><p>The value specifies the source file name. To differentiate between
  87. files with the same base name, prepend as many directories as is necessary
  88. to uniquely identify the desired file, e.g., <samp>foo/bar/baz.c</samp>. Otherwise
  89. <small>GDB</small> will use the first file it finds with the given base
  90. name. This option requires the use of either <code>-function</code> or <code>-line</code>.
  91. </p>
  92. </dd>
  93. <dt><code>-function <var>function</var></code></dt>
  94. <dd><p>The value specifies the name of a function. Operations
  95. on function locations unmodified by other options (such as <code>-label</code>
  96. or <code>-line</code>) refer to the line that begins the body of the function.
  97. In C, for example, this is the line with the open brace.
  98. </p>
  99. <p>By default, in C<tt>++</tt> and Ada, <var>function</var> is interpreted as
  100. specifying all functions named <var>function</var> in all scopes. For
  101. C<tt>++</tt>, this means in all namespaces and classes. For Ada, this
  102. means in all packages.
  103. </p>
  104. <p>For example, assuming a program with C<tt>++</tt> symbols named
  105. <code>A::B::func</code> and <code>B::func</code>, both commands <kbd>break&nbsp;<span class="nolinebreak">-function</span>&nbsp;func</kbd><!-- /@w --> and <kbd>break&nbsp;<span class="nolinebreak">-function</span>&nbsp;B::func</kbd><!-- /@w --> set a
  106. breakpoint on both symbols.
  107. </p>
  108. <p>You can use the <kbd>-qualified</kbd> flag to override this (see below).
  109. </p>
  110. </dd>
  111. <dt><code>-qualified</code></dt>
  112. <dd>
  113. <p>This flag makes <small>GDB</small> interpret a function name specified with
  114. <kbd>-function</kbd> as a complete fully-qualified name.
  115. </p>
  116. <p>For example, assuming a C<tt>++</tt> program with symbols named
  117. <code>A::B::func</code> and <code>B::func</code>, the <kbd>break&nbsp;<span class="nolinebreak">-qualified</span>&nbsp;<span class="nolinebreak">-function</span>&nbsp;B::func</kbd><!-- /@w --> command sets a breakpoint on <code>B::func</code>, only.
  118. </p>
  119. <p>(Note: the <kbd>-qualified</kbd> option can precede a linespec as well
  120. (see <a href="Linespec-Locations.html#Linespec-Locations">Linespec Locations</a>), so the particular example above could be
  121. simplified as <kbd>break&nbsp;<span class="nolinebreak">-qualified</span>&nbsp;B::func</kbd><!-- /@w -->.)
  122. </p>
  123. </dd>
  124. <dt><code>-label <var>label</var></code></dt>
  125. <dd><p>The value specifies the name of a label. When the function
  126. name is not specified, the label is searched in the function of the currently
  127. selected stack frame.
  128. </p>
  129. </dd>
  130. <dt><code>-line <var>number</var></code></dt>
  131. <dd><p>The value specifies a line offset for the location. The offset may either
  132. be absolute (<code>-line 3</code>) or relative (<code>-line +3</code>), depending on
  133. the command. When specified without any other options, the line offset is
  134. relative to the current line.
  135. </p></dd>
  136. </dl>
  137. <p>Explicit location options may be abbreviated by omitting any non-unique
  138. trailing characters from the option name, e.g., <kbd>break&nbsp;<span class="nolinebreak">-s</span>&nbsp;main.c&nbsp;<span class="nolinebreak">-li</span>&nbsp;3</kbd><!-- /@w -->.
  139. </p>
  140. <hr>
  141. <div class="header">
  142. <p>
  143. Next: <a href="Address-Locations.html#Address-Locations" accesskey="n" rel="next">Address Locations</a>, Previous: <a href="Linespec-Locations.html#Linespec-Locations" accesskey="p" rel="previous">Linespec Locations</a>, Up: <a href="Specify-Location.html#Specify-Location" accesskey="u" rel="up">Specify Location</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>
  144. </div>
  145. </body>
  146. </html>