Sun Studio 12 Update 1: Debugging a Program With dbx

Setting Multiple Breaks in C++ Programs

You can 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.

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


(dbx) stop inmember draw

For more information on specifying an inmember or inmethod event, see inmember function inmethod function.

Setting Breakpoints in All Member Functions of a Class

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

By default, breakpoints are inserted only in the class member functions defined in the class, not those that it might inherit from its base classes. To insert breakpoints in the functions inherited from the base classes also, specify the -recurse option.

To set a breakpoint in all member functions defined in the class shape, type:


(dbx) stop inclass shape

To set a breakpoint in all member functions defined in the class shape, and also in functions inherited from the class, type:


(dbx) stop inclass shape -recurse

For more information on specifying an inclass event, see inclass classname [-recurse | -norecurse] and stop Command.

Due to the large number of breakpoints that may be inserted by stop inclass and other breakpoint selections, you should be sure to set the dbx environment variable step_events to on to speed up the step and next commands (see Efficiency Considerations).

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.

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


(dbx) stop infunction sort 

For more information on specifying an infunction event, see infunction function.

Setting Breakpoints in Objects

Set an In Object breakpoint to check the operations applied to a specific object instance.

By default, an In Object breakpoint suspends program execution in all nonstatic member functions of the object’s class, including inherited ones, when called from the object. To set a breakpoint to suspend program execution in only nonstatic member functions defined in the object’s class and not inherited classes, specify the -norecurse option.

To set a breakpoint in all nonstatic member functions defined in the base class of object foo, and in all nonstatic member functions defined in inherited classes of object foo, type:


(dbx) stop inobject &foo

To set a breakpoint in all nonstatic member functions defined in the class of object foo, but not those defined in inherited classes of object foo, type:


(dbx) stop inobject &foo -norecurse

For more information on specifying an inobject event, see inobject object-expression [-recurse | -norecurse] and stop Command