Next: Patching, Previous: Returning, Up: Altering

### 17.5 Calling Program Functions

`print` expr
  Evaluate the expression expr and display the resulting value. The expression may include calls to functions in the program being debugged.

`call` expr
  Evaluate the expression expr without displaying `void` returned values.

  You can use this variant of the `print` command if you want to execute a function from your program that does not return anything (a.k.a. a void function), but without cluttering the output with `void` returned values that gdb will otherwise print. If the result is not void, it is printed and saved in the value history.

It is possible for the function you call via the `print` or `call` command to generate a signal (e.g., if there's a bug in the function, or if you passed it incorrect arguments). What happens in that case is controlled by the `set unwindonsignal` command.

Similarly, with a C`++` program it is possible for the function you call via the `print` or `call` command to generate an exception that is not handled due to the constraints of the dummy frame. In this case, any exception that is raised in the frame, but has an out-of-frame exception handler will not be found. GDB builds a dummy-frame for the inferior function call, and the unwinder cannot seek for exception handlers outside of this dummy-frame. What happens in that case is controlled by the `set unwind-on-terminating-exception` command.

`set unwindonsignal`
  Set unwinding of the stack if a signal is received while in a function that gdb called in the program being debugged. If set to on, gdb unwinds the stack it created for the call and restores the context to what it was before the call. If set to off (the default), gdb stops in the frame where the signal was received.
`show unwindonsignal`
  Show the current setting of stack unwinding in the functions called by gdb.
`set unwind-on-terminating-exception`
  Set unwinding of the stack if a C`++` exception is raised, but left unhandled while in a function that gdb called in the program being debugged. If set to on (the default), gdb unwinds the stack it created for the call and restores the context to what it was before the call. If set to off, gdb the exception is delivered to the default C`++` exception handler and the inferior terminated.
`show unwind-on-terminating-exception`
  Show the current setting of stack unwinding in the functions called by gdb.

Sometimes, a function you wish to call is actually a weak alias for another function. In such case, gdb might not pick up the type information, including the types of the function arguments, which causes gdb to call the inferior function incorrectly. As a result, the called function will function erroneously and may even crash. A solution to that is to use the name of the aliased function instead.