Debugging a Program With dbx

Calling a Function

When a program is stopped, you can call a function using the dbx call command, which accepts values for the parameters that must be passed to the called function.

To call a procedure, type the name of the function and supply its parameters. For eaxample:


(dbx) call change_glyph(1,3)

Notice that while the parameters may be optional, you must type in the parentheses after the function_name, for example:


(dbx) call type_vehicle()

A user may call a function explicitly, using the call command, or implicitly, by evaluating an expression containing function calls or using a conditional modifier such as stop in glyph -if animate().

If the source file in which the function is defined was compiled with the --g flag, or if the prototype declaration is visible at the current scope, dbx checks the number and type of arguments and issues an error message if there is a mismatch. Otherwise, dbx does not check the number of parameters an dproceeds with the call.

By default, after every call command, dbx automatically calls fflush(stdout) to ensure that any information stored in the I/O buffer is printed. To turn off automatic flushing, you can set the dbxenv output_autoflush to off.

For C++, dbx handles the implicit this pointer, default arguments, and function overloading. Automatic resolution of the C++ overloaded functions is done if possible. If any ambiguity remains (for example, functions not compiled with --g), dbx shows a list of the overloaded names.

When you use call, dbx behaves "next-like," returning from the called function. However, if the program hits a breakpoint in the called function, dbx stops the program at the breakpoint and emits a message. If you now issue a where command, the stack trace shows that the call originated from dbx command level.

If you continue execution, the call returns normally. If you attempt to kill, run, rerun, or debug, the command aborts as dbx tries to recover from the this nesting. You can then re-issue the command. Alternatively, you can use the command pop -c to pop all frames up to the most recent call.