Lockdesign Diagnostic Tools Aid VB Debugging

Diagnostic Tools Overview

The Lockdesign Diagnostic Tools contain four tools designed to assist developers in tracing exactly how their VB6 programs are behaving and are available from the downloads page or directly from here.

The tools address the following areas:

In addition to these four tools there are a number of IDE enhancements to assist in everyday development. These are:

  • Indenting Tool.
  • Add/Remove Line Numbers for the current procedure, module, project or project group.
  • Add user configurable error handling code to the current procedure or module.
  • Open/Close all code/designer windows with a single click.
  • Configuration of the code pane right click menu.
  • Mechanism to include configurable standard pieces of text into the code pane, from the right click menu.
  • Clear the immediate window with a single click.
  • Automatically clear the immediate window when a project is run.

The addin is supplied as a single ActiveX DLL which comprises the code for both the addin functionality and the diagnostic reporting tools. When installed the Lockdesign Diagnostic toolbar is made available within the IDE. This toolbar (show below) may be docked or left floating in the same manner as the standard VB toolbars.

Access to some of the functions is also available from the right click menu in the code pane.

Full windows help is provided with the addin which details how to use the diagnostics form and lists the diagnostic tools API calls.

 

Dynamic Monitoring of Program Flow

This is provided through the tracer utility. Tracer code is added, via the Lockdesign Diagnostic Form, to those parts of your project (or project group) you wish to trace. This is a small section of code added to the start of those methods and properties to be traced. To enable the tracing a conditional compilation argument needs to be set (LOCKDES_TRACE) and the project run. When the project runs the path through the program is shown in a tree view with each node representing a procedure call. Expanding a node shows the procedures called by the parent node and the order in which they were made. By enabling tracing on an entire project quickly shows the program flow in response to the different inputs possible. The data generated in the tree view may be saved as either text or XML. A small number of diagnostic tool API calls are available to allow the tracer diagnostic data to be refreshed, reset or saved from within your projects code. This is particularly useful when the diagnostics are being used within a compiled program.

Click here to see an example of the output against a sample program. (This will open in a new window.)

 

Dynamic Monitoring of Object Creation/Deletion

This is provided through the object monitor utility. Object monitoring code is added, via the Lockdesign Diagnostic Form, to those classes in your project (or project group) for which monitoring is required. This is a small section of code in the Class_Initialise and Class_Terminate methods of each class. If your classes do not have a Class_Initialise or Class_Terminate method then one will be created specifically for the purpose of object monitoring. When the project runs the object monitor diagnostic form will be displayed and will, when refreshed, show the number of objects created, deleted and currently active for each class for which object monitoring was added. This can quickly highlight problem areas in your project if there are a large number of creation and deletions of objects of the same class. The data generated may be saved as either text, XML or comma separated. A small number of diagnostic tool API calls are available to allow the object monitor diagnostic data to be refreshed, reset or saved from with your projects code. This is particularly useful when the diagnostics are being used with a compiled program.

Click here to see an example of the output from an object monitoring session. (This will open in a new window.)

 

Profile Timings

This is provided through the profiler utility. Profiling code is added, via the Lockdesign Diagnostic Form, to those methods/properties for which you require profie timings. The timings gathered are for the duration of the scope of the procedure, i.e. from point of entry to point of exit regardless of the exit point. This is a small section of code at the start of each method/property. Additionally a specific area of code may be profiled by selecting the code in the code pane window and using the 'Profile Selection' option from the code pane right click menu. Diagnostic tools API calls also exist to allow handcoded profiling points to be added to the code. When a project with profiling is run the profiling diagnostic window, when refreshed, shows the profiling statistics for each profiling point. These statistics consist of number of times called, average time, standard deviation, minimum time and maximum time. The data generated may be saved as either text, XML or comma separated. A small number of diagnostic tool API calls are available to allow the profiling diagnostic data to be refreshed, reset or saved from within your projects code. This is particularly useful when the diagnostics are being used with a compiled program.

Click here to see an example of the output from a profiling session. (This will open in a new window.)

 

Diagnostic Reporting

This is a simple diagnostic reporting utility. Whilst the immediate window is an invaluable debugging aid it falls short for the reporting of diagnostic information and it is not available when running compiled. This diagnostic reporting tool is a simple VB form which is used to display time stamped diagnostic text reported from within a VB program. Text is reported using simple diagnostic tool API calls and such calls also exist to Refresh, Reset and Save the data in the diagnostic window. This is particularly useful when the diagnostics are being used with a compiled program.

Click here to see an example of the output of the diagnostic form. (This will open in a new window.)

 

IDE Enhancements

  • Indenter
    This tool provides the facility by which the source code may be indented to a predefined format specified in the Tool Options. Whilst I am a firm believer that code should indeed be written in an indented manner it is sometimes an invaluable tool, especially when you paste in a new piece of code or add an If/Else statement in the middle of a large piece of code. Another use is when you inherit code which has been written with a different Tab setting to your own preference, with a single click of the mouse the code could be indented to your liking. Code may be indented from a procedure right up to an entire project group at a single click.

  • Add/Remove Line Numbers
    Having line number in your code can ease fault finding by using the Erl method in your error handlers to report the line number that the error occurred on. However it is unlikely that you want to leave the line numbers in once your code is at production standard. This enhancement allows you easily add and remove line numbers from your procedure or module from the toolbar or the code pane right click menu. Note that this tool will not work correctly if you use line numbers (as opposed to labels) in your own code as removing line numbers would also remove your line numbers. The increment between the line numbers is a user configurable option.

  • Add Error Handling Code
    This facility allows standard user defined error handling code to be added to the current procedure or all procedures in the current module. In addition a constant with local scope is defined, in each procedure, which contains the name of the procedure. This makes reporting the location of an error in the error handler simpler as it may be done through a single method call passing the name of the procedure in which the error occurred.

  • Open/Close all code/designer windows with a single click or keypress.
    The VB environment can become quite cluttered with form windows and code panes. This toolbar button will close all open code and designer windows. Simple, but useful.

  • Configuration of the code pane right click menu.
    The right click menu in the code pane contains quite a large number of options, and now even more with the new ones added by the diagnostic tools. If you never use some of the options then they may now be disabled via the tools options.

  • Mechanism to include configurable standard pieces of text into the code pane, from the right click menu
    This provides the facility to specify standard pieces of text which may later be included via the right click menu in the code pane or via shrotcut keys.

  • Clear the immediate window with a single click or keypress.
    Many developers wish there was a Clear method for the Debug object to allow the immediate window to be cleared from code. This button saves clearing the immediate window manually. The keyboard shortcut may be used in design mode or in pause mode when running a program.

  • Automatically clear the immediate window when a project is run.
    Our ImmClear tool which clears the immediate window automatically when a project is run proved popular, so we decided to provide the functionality in the diagnostic tools. If you're an ImmClear user it is no longer required.