break

Set breakpoint at specified line or function.

break [LOCATION] [thread THREADNUM] [if CONDITION]

  • LOCATION may be a line number, function name, or “*” and an address.

    • If a line number is specified, break at start of code for that line.
    • If a function is specified, break at start of code for that function.
    • If an address is specified, break at that exact address.
    • With no LOCATION, uses current execution address of the selected stack frame. This is useful for breaking on return to a stack frame.

    Here are all the different ways of specifying a LOCATION:

    • linenum – Specifies the line number linenum of the current source file.

    • 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 ‘directory/expr.c’, then it will match source file name of ‘/build/trunk/directory/expr.c’, but not ‘/build/trunk/dir/expr.c’ or ‘/build/trunk/directory/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.

    • address – Specifies the program address. 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 C expression that specifies a code address. Here are the various forms of address:

      • expression: Any C expression.
      • funcaddr: An address of a function or procedure derived from its name (the function’s name). This form specifies the address of the function’s first instruction, before the stack frame and arguments have been set up.
  • THREADNUM is the number from “info threads”.

  • CONDITION is a boolean expression.

Multiple breakpoints at one place are permitted, and useful if their conditions are different.

Do “help breakpoints” for info on other commands dealing with breakpoints.