Self-displaying C++ objects

This is an experimental feature of Xcdb that allows C++ objects in a program to show themselves in response to a request from the debugger. When a C++ object is selected on the Locals or NonLocals window, and you choose Show self from the menu, Xcdb executes a member function named xcdb(), if found. For every class you wish to examine, write an xcdb() member function with these constraints:

When you want a class instance to run its xcdb() member function, click on the object (as usual), format the object as a "structure" (choose More Detail if you only have a pointer to the object), and choose Show self, which runs the object's xcdb() member function. Control then returns to the debugger.

An xcdb() member function can be written to do anything at all. It might say something interesting, display pretty pictures, and so on. Use your imagination.

Example

      class Mumble
          {
          private:    const char *name;
          public:     Mumble(const char *name) : name(name) {}
          public:     const char *name() { return name; }
          public:     void xcdb();
         };
       
      void Mumble::xcdb() { printf("My name is '%s'.\n", name()); }
      
      main()
          {
          Mumble&  mumble = *new Mumble("mumble");
          }
Clicking on the variable mumble in the Locals pane and choosing Show self from the menu displays

    My name is 'mumble'.
in the xterm window that invoked the debugger.

Notes

Attempting to Show self on a class or struct for which no xcdb() member function is defined produces a warning message but is otherwise harmless.

Any breakpoint or exception inside the xcdb() member function, while running in the context of Show self, terminates the function (returning control to Xcdb) and is otherwise ignored.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker