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-2021 Free Software Foundation, Inc. 4 5Permission is granted to copy, distribute and/or modify this document 6under the terms of the GNU Free Documentation License, Version 1.3 or 7any later version published by the Free Software Foundation; with the 8Invariant Sections being "Free Software" and "Free Software Needs 9Free Documentation", with the Front-Cover Texts being "A GNU Manual," 10and with the Back-Cover Texts as in (a) below. 11 12(a) The FSF's Back-Cover Text is: "You are free to copy and modify 13this GNU Manual. Buying copies from GNU Press supports the FSF in 14developing GNU and promoting software freedom." --> 15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 16<head> 17<title>Debugging with GDB: Explicit Locations</title> 18 19<meta name="description" content="Debugging with GDB: Explicit Locations"> 20<meta name="keywords" content="Debugging with GDB: Explicit Locations"> 21<meta name="resource-type" content="document"> 22<meta name="distribution" content="global"> 23<meta name="Generator" content="makeinfo"> 24<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 25<link href="index.html#Top" rel="start" title="Top"> 26<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> 27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 28<link href="Specify-Location.html#Specify-Location" rel="up" title="Specify Location"> 29<link href="Address-Locations.html#Address-Locations" rel="next" title="Address Locations"> 30<link href="Linespec-Locations.html#Linespec-Locations" rel="previous" title="Linespec Locations"> 31<style type="text/css"> 32<!-- 33a.summary-letter {text-decoration: none} 34blockquote.smallquotation {font-size: smaller} 35div.display {margin-left: 3.2em} 36div.example {margin-left: 3.2em} 37div.indentedblock {margin-left: 3.2em} 38div.lisp {margin-left: 3.2em} 39div.smalldisplay {margin-left: 3.2em} 40div.smallexample {margin-left: 3.2em} 41div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 42div.smalllisp {margin-left: 3.2em} 43kbd {font-style:oblique} 44pre.display {font-family: inherit} 45pre.format {font-family: inherit} 46pre.menu-comment {font-family: serif} 47pre.menu-preformatted {font-family: serif} 48pre.smalldisplay {font-family: inherit; font-size: smaller} 49pre.smallexample {font-size: smaller} 50pre.smallformat {font-family: inherit; font-size: smaller} 51pre.smalllisp {font-size: smaller} 52span.nocodebreak {white-space:nowrap} 53span.nolinebreak {white-space:nowrap} 54span.roman {font-family:serif; font-weight:normal} 55span.sansserif {font-family:sans-serif; font-weight:normal} 56ul.no-bullet {list-style: none} 57--> 58</style> 59 60 61</head> 62 63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 64<a name="Explicit-Locations"></a> 65<div class="header"> 66<p> 67Next: <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> [<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> 68</div> 69<hr> 70<a name="Explicit-Locations-1"></a> 71<h4 class="subsection">9.2.2 Explicit Locations</h4> 72<a name="index-explicit-locations"></a> 73 74<p><em>Explicit locations</em> allow the user to directly specify the source 75location’s parameters using option-value pairs. 76</p> 77<p>Explicit locations are useful when several functions, labels, or 78file names have the same name (base name for files) in the program’s 79sources. In these cases, explicit locations point to the source 80line you meant more accurately and unambiguously. Also, using 81explicit locations might be faster in large programs. 82</p> 83<p>For example, the linespec ‘<samp>foo:bar</samp>’ may refer to a function <code>bar</code> 84defined in the file named <samp>foo</samp> or the label <code>bar</code> in a function 85named <code>foo</code>. <small>GDB</small> must search either the file system or 86the symbol table to know. 87</p> 88<p>The list of valid explicit location options is summarized in the 89following table: 90</p> 91<dl compact="compact"> 92<dt><code>-source <var>filename</var></code></dt> 93<dd><p>The value specifies the source file name. To differentiate between 94files with the same base name, prepend as many directories as is necessary 95to uniquely identify the desired file, e.g., <samp>foo/bar/baz.c</samp>. Otherwise 96<small>GDB</small> will use the first file it finds with the given base 97name. This option requires the use of either <code>-function</code> or <code>-line</code>. 98</p> 99</dd> 100<dt><code>-function <var>function</var></code></dt> 101<dd><p>The value specifies the name of a function. Operations 102on function locations unmodified by other options (such as <code>-label</code> 103or <code>-line</code>) refer to the line that begins the body of the function. 104In C, for example, this is the line with the open brace. 105</p> 106<p>By default, in C<tt>++</tt> and Ada, <var>function</var> is interpreted as 107specifying all functions named <var>function</var> in all scopes. For 108C<tt>++</tt>, this means in all namespaces and classes. For Ada, this 109means in all packages. 110</p> 111<p>For example, assuming a program with C<tt>++</tt> symbols named 112<code>A::B::func</code> and <code>B::func</code>, both commands <kbd>break <span class="nolinebreak">-function</span> func</kbd><!-- /@w --> and <kbd>break <span class="nolinebreak">-function</span> B::func</kbd><!-- /@w --> set a 113breakpoint on both symbols. 114</p> 115<p>You can use the <kbd>-qualified</kbd> flag to override this (see below). 116</p> 117</dd> 118<dt><code>-qualified</code></dt> 119<dd> 120<p>This flag makes <small>GDB</small> interpret a function name specified with 121<kbd>-function</kbd> as a complete fully-qualified name. 122</p> 123<p>For example, assuming a C<tt>++</tt> program with symbols named 124<code>A::B::func</code> and <code>B::func</code>, the <kbd>break <span class="nolinebreak">-qualified</span> <span class="nolinebreak">-function</span> B::func</kbd><!-- /@w --> command sets a breakpoint on <code>B::func</code>, only. 125</p> 126<p>(Note: the <kbd>-qualified</kbd> option can precede a linespec as well 127(see <a href="Linespec-Locations.html#Linespec-Locations">Linespec Locations</a>), so the particular example above could be 128simplified as <kbd>break <span class="nolinebreak">-qualified</span> B::func</kbd><!-- /@w -->.) 129</p> 130</dd> 131<dt><code>-label <var>label</var></code></dt> 132<dd><p>The value specifies the name of a label. When the function 133name is not specified, the label is searched in the function of the currently 134selected stack frame. 135</p> 136</dd> 137<dt><code>-line <var>number</var></code></dt> 138<dd><p>The value specifies a line offset for the location. The offset may either 139be absolute (<code>-line 3</code>) or relative (<code>-line +3</code>), depending on 140the command. When specified without any other options, the line offset is 141relative to the current line. 142</p></dd> 143</dl> 144 145<p>Explicit location options may be abbreviated by omitting any non-unique 146trailing characters from the option name, e.g., <kbd>break <span class="nolinebreak">-s</span> main.c <span class="nolinebreak">-li</span> 3</kbd><!-- /@w -->. 147</p> 148<hr> 149<div class="header"> 150<p> 151Next: <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> [<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> 152</div> 153 154 155 156</body> 157</html> 158