Debugging a Program With dbx

Setting Multiple Breaks in C++ Programs

You may want to check for problems related to calls to members of different classes, calls to any members of a given class, or calls to overloaded top-level functions. You can use a keyword--inmember, inclass, infunction, or inobject--with a stop, when, or trace command to set multiple breaks in C++ code.

Setting Breakpoints in Member Functions of Different Classes

To set a breakpoint in each of the object-specific variants of a particular member function (same member function name, different classes), use stop inmember.

To set a when breakpoint, use when inmember.

For example, if the function draw is defined in several different classes, then to place a breakpoint in each function :


(dbx) stop inmember draw

Setting Breakpoints in Member Functions of Same Class

To set a breakpoint in all member functions of a specific class, use the stop inclass command.

To set a when breakpoint, use when inclass.

To set a breakpoint in all member functions of the class draw:


(dbx) stop inclass draw

Breakpoints are inserted in only the class member functions defined in the class. It does not include those that it may inherit from base classes.

Due to the large number of breakpoints that may be inserted by stop inclass and other breakpoint selections, you should be sure to set your dbxenv step_events to on to speed up step and next.

Setting Multiple Breakpoints in Nonmember Functions

To set multiple breakpoints in nonmember functions with overloaded names (same name, different type or number of arguments), use the stop infunction command.

To set a when breakpoint, use when infunction.

For example, if a C++ program has defined two versions of a function named sort(), one which passes an int type argument, the other a float, then, to place a breakpoint in both functions:


(dbx) when infunction sort {cmd;}

Setting Breakpoints in Objects

Set an In Object breakpoint to check the operations applied to a specific object. An In Object breakpoint suspends program execution in all nonstatic member functions of the object's class when called from the object.

To set a breakpoint in object foo:


(dbx) stop inobject foo