Next: Edit, Previous: List, Up: Source

### 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.
function
  Specifies the line that begins the body of the function function. For example, in C, this is the line with the open brace.
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.
`*`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.