Next: Edit, Previous: List, Up: Source [Contents][Index]

### 9.2 Specifying a Location

Several GDB commands accept arguments that specify a location of your program’s code. Since GDB is a source-level debugger, a location usually specifies some line in the source code; for that reason, locations are also known as linespecs.

Here are all the different ways of specifying a code location that GDB understands:

`linenum`

  Specifies the line number linenum of the current source file.

`-offset`
`+offset`

  Specifies the line offset lines before or after the current line. For the `list` command, the current line is the last one printed; for the breakpoint commands, this is the line at which execution stopped in the currently selected stack frame (see Frames, for a description of stack frames.) When used as the second of the two linespecs in a `list` command, this specifies the line offset lines up or down from the first linespec.

`filename:linenum`

  Specifies the line linenum in the source file filename. If filename is a relative file name, then it will match any source file name with the same trailing components. For example, if filename is ‘`gcc/expr.c`’, then it will match source file name of `/build/trunk/gcc/expr.c`, but not `/build/trunk/libcpp/expr.c` or `/build/trunk/gcc/x-expr.c`.

`function`

  Specifies the line that begins the body of the function function. For example, in C, this is the line with the open brace.

`function:label`

  Specifies the line where label appears in function.

`filename:function`

  Specifies the line that begins the body of the function function in the file filename. You only need the file name with a function name to avoid ambiguity when there are identically named functions in different source files.

`label`

  Specifies the line at which the label named label appears. GDB searches for the label in the function corresponding to the currently selected stack frame. If there is no current selected stack frame (for instance, if the inferior is not running), then GDB will not search for a label.

`*address`

  Specifies the program address address. For line-oriented commands, such as `list` and `edit`, this specifies a source line that contains address. For `break` and other breakpoint oriented commands, this can be used to set breakpoints in parts of your program which do not have debugging information or source files.

  Here address may be any expression valid in the current working language (see working language) that specifies a code address. In addition, as a convenience, GDB extends the semantics of expressions used in locations to cover the situations that frequently happen during debugging. Here are the various forms of address:

  `expression`

    Any expression valid in the current working language.

  `funcaddr`

    An address of a function or procedure derived from its name. In C, C`++`, Java, Objective-C, Fortran, minimal, and assembly, this is simply the function’s name function (and actually a special case of a valid expression). In Pascal and Modula-2, this is `&function`. In Ada, this is `function'Address` (although the Pascal form also works).

    This form specifies the address of the function’s first instruction, before the stack frame and arguments have been set up.

  `'filename':funcaddr`

    Like funcaddr above, but also specifies the name of the source file explicitly. This is useful if the name of the function does not specify the function unambiguously, e.g., if there are several functions with identical names in different source files.

`-pstap|-probe-stap [objfile:[provider:]]name`

  The GNU/Linux tool `SystemTap` provides a way for applications to embed static probes. See Static Probe Points, for more information on finding and using static probes. This form of linespec specifies the location of such a static probe.

  If objfile is given, only probes coming from that shared library or executable matching objfile as a regular expression are considered. If provider is given, then only probes from that provider are considered. If several probes match the spec, GDB will insert a breakpoint at each one of those probes.

Next: Edit, Previous: List, Up: Source [Contents][Index]