Data Structure Visualization with Visual Debugger

A tool for automatic visualization of run-time data structures

The Data Structure Visualization software is intended for use by students of data structures classes. The software's main purpose is to allow students to see what data structures their code creates, in a visual form that can be easily recognized by the users. For example, a linked list could be displayed as a collection of boxes connected by arrows, perhaps in a straight line. The Data Structure Visualization software connects to Microsoft Visual C++, and visualizes a VC++ project at run-time with no modification to the project code.

An alpha version is available for download in zip format (144k). Included are the vdb.exe executable file, a doc directory containing a local version of the online documentation (the online version is usually more up-to-date), and a DemoTree directory containing a small demonstration Visual C++ project that uses a Tree class. Please note that the Visual Basic 6 Runtime Library is required in order to run the program.

John Costigan, Ben Wilhite
Faculty advisor: Chris North
Information Visualization Lab
Department of Computer Science
Virginia Tech

Supported by:

The following screen shots illustrate the use of the Visual Debugger in visualizing the structure of a binary tree. The code for the program being debugged is at the bottom of this page. In the program being debugged, there are four stack variables being monitored:



Screenshots


This is the screen the user sees when first opening the Visual Debugger program. The stack pane of the window is for stack variables that the user wishes to monitor. The heap pane is a drawing space for objects that are placed on the heap. Any stack variable that is a pointer to an object on the heap will have that stack variable on the stack pane and its corresponding heap object on the heap pane. If heap objects contain pointers to other heap objects, those will also be displayed on the heap pane, though they may not have a corresponding stack variable on the stack pane.



Adding stack variables to monitor is as easy as cutting and pasting the variable declaration lines into Visual Debugger. The built-in parser will extract the data type and variable name from the declaration line. When a user tries to specify a stack variable of a type that is not defined, the "Define Class" dialogue box appears to prompt the user for information regarding the class. Specifying all of the members of the class is optional, but it allows Visual Debugger to display data inside each object of that class. Also, if any of the class members are pointers to other objects, they must be defined in order for Visual Debugger to find and display the pointed objects.



After cutting and pasting the member declaration lines into Visual Debugger, the user should select which members should be displayed on the heap pane. If no members are selected, then the address of each object is shown. In this case, the user has selected elem, an integer member.



After a class is defined, it can be used to create other stack variables to monitor without redefining the class.



Classes can be created, edited, or deleted at any time--even during runtime--via the "Class Editor" dialog box.



After the user has entered the desired stack variables to monitor, the debugging process can begin. As heap objects are created, they appear on the heap pane (if there is a stack variable associated with it) with the field(s) the user specified to display. Blue arrows point from stack variables to their corresponding heap objects. The heap object appears green because it is newly allocated.



As the debugged program continues, additional heap objects are created and appear on the heap pane because they are referenced via pointers in other heap objects. Black arrows illustrate a reference from a heap object pointer to another heap object.



When the stack variables are set up to point to heap objects, blue arrows are displayed to illustrate these references.



When the object pointed to by del is deleted, it remains in the heap pane and turns red to indicate that it has been deallocated. Had it not been deallocated, but instead turned into a memory leak, this would have been apparent to the user because no pointers would be pointing to it and it would not have turned red.




The Debugged Program Code

#include "newVD.h"

class node
{
public:
node() { next1 = NULL; next2 = NULL; elem = 0; }
node* next1;
node* next2;
int elem;
};

int main() {

node* delNext = NULL;
node* del = NULL;
node* delPrev = NULL;
node* head = new node;

head->elem = 10;

head->next1 = new node;
head->next2 = new node;

head->next1->elem = 5;
head->next1->next1 = new node;
head->next1->next2 = new node;

head->next2->next1 = new node;

head->next1->next2->next1 = new node;

delPrev = head->next1;
del = head->next1->next2;
delNext = head->next1->next2->next1;

delPrev->next2 = delNext;
delete del;

del = NULL;
return 0;

}