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: Linespec Locations</title> 18 19<meta name="description" content="Debugging with GDB: Linespec Locations"> 20<meta name="keywords" content="Debugging with GDB: Linespec 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="Explicit-Locations.html#Explicit-Locations" rel="next" title="Explicit Locations"> 30<link href="Specify-Location.html#Specify-Location" rel="previous" title="Specify Location"> 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="Linespec-Locations"></a> 65<div class="header"> 66<p> 67Next: <a href="Explicit-Locations.html#Explicit-Locations" accesskey="n" rel="next">Explicit 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="Linespec-Locations-1"></a> 71<h4 class="subsection">9.2.1 Linespec Locations</h4> 72<a name="index-linespec-locations"></a> 73 74<p>A <em>linespec</em> is a colon-separated list of source location parameters such 75as file name, function name, etc. Here are all the different ways of 76specifying a linespec: 77</p> 78<dl compact="compact"> 79<dt><code><var>linenum</var></code></dt> 80<dd><p>Specifies the line number <var>linenum</var> of the current source file. 81</p> 82</dd> 83<dt><code>-<var>offset</var></code></dt> 84<dt><code>+<var>offset</var></code></dt> 85<dd><p>Specifies the line <var>offset</var> lines before or after the <em>current 86line</em>. For the <code>list</code> command, the current line is the last one 87printed; for the breakpoint commands, this is the line at which 88execution stopped in the currently selected <em>stack frame</em> 89(see <a href="Frames.html#Frames">Frames</a>, for a description of stack frames.) When 90used as the second of the two linespecs in a <code>list</code> command, 91this specifies the line <var>offset</var> lines up or down from the first 92linespec. 93</p> 94</dd> 95<dt><code><var>filename</var>:<var>linenum</var></code></dt> 96<dd><p>Specifies the line <var>linenum</var> in the source file <var>filename</var>. 97If <var>filename</var> is a relative file name, then it will match any 98source file name with the same trailing components. For example, if 99<var>filename</var> is ‘<samp>gcc/expr.c</samp>’, then it will match source file 100name of <samp>/build/trunk/gcc/expr.c</samp>, but not 101<samp>/build/trunk/libcpp/expr.c</samp> or <samp>/build/trunk/gcc/x-expr.c</samp>. 102</p> 103</dd> 104<dt><code><var>function</var></code></dt> 105<dd><p>Specifies the line that begins the body of the function <var>function</var>. 106For example, in C, this is the line with the open brace. 107</p> 108<p>By default, in C<tt>++</tt> and Ada, <var>function</var> is interpreted as 109specifying all functions named <var>function</var> in all scopes. For 110C<tt>++</tt>, this means in all namespaces and classes. For Ada, this 111means in all packages. 112</p> 113<p>For example, assuming a program with C<tt>++</tt> symbols named 114<code>A::B::func</code> and <code>B::func</code>, both commands <kbd>break func</kbd><!-- /@w --> and <kbd>break B::func</kbd><!-- /@w --> set a breakpoint on both symbols. 115</p> 116<p>Commands that accept a linespec let you override this with the 117<code>-qualified</code> option. For example, <kbd>break <span class="nolinebreak">-qualified</span> func</kbd><!-- /@w --> sets a breakpoint on a free-function named <code>func</code> ignoring 118any C<tt>++</tt> class methods and namespace functions called <code>func</code>. 119</p> 120<p>See <a href="Explicit-Locations.html#Explicit-Locations">Explicit Locations</a>. 121</p> 122</dd> 123<dt><code><var>function</var>:<var>label</var></code></dt> 124<dd><p>Specifies the line where <var>label</var> appears in <var>function</var>. 125</p> 126</dd> 127<dt><code><var>filename</var>:<var>function</var></code></dt> 128<dd><p>Specifies the line that begins the body of the function <var>function</var> 129in the file <var>filename</var>. You only need the file name with a 130function name to avoid ambiguity when there are identically named 131functions in different source files. 132</p> 133</dd> 134<dt><code><var>label</var></code></dt> 135<dd><p>Specifies the line at which the label named <var>label</var> appears 136in the function corresponding to the currently selected stack frame. 137If there is no current selected stack frame (for instance, if the inferior 138is not running), then <small>GDB</small> will not search for a label. 139</p> 140<a name="index-breakpoint-at-static-probe-point"></a> 141</dd> 142<dt><code>-pstap|-probe-stap <span class="roman">[</span><var>objfile</var>:<span class="roman">[</span><var>provider</var>:<span class="roman">]</span><span class="roman">]</span><var>name</var></code></dt> 143<dd><p>The <small>GNU</small>/Linux tool <code>SystemTap</code> provides a way for 144applications to embed static probes. See <a href="Static-Probe-Points.html#Static-Probe-Points">Static Probe Points</a>, for more 145information on finding and using static probes. This form of linespec 146specifies the location of such a static probe. 147</p> 148<p>If <var>objfile</var> is given, only probes coming from that shared library 149or executable matching <var>objfile</var> as a regular expression are considered. 150If <var>provider</var> is given, then only probes from that provider are considered. 151If several probes match the spec, <small>GDB</small> will insert a breakpoint at 152each one of those probes. 153</p></dd> 154</dl> 155 156<hr> 157<div class="header"> 158<p> 159Next: <a href="Explicit-Locations.html#Explicit-Locations" accesskey="n" rel="next">Explicit 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> 160</div> 161 162 163 164</body> 165</html> 166