jeDebug

09/16/99

Author:nebol@home.se
ICQ:
2110949
HOMEPAGE: http://www.omtanken.se/valheru


Created by Johan Eliasson. Copyright © Valheru Productions 1995 - 1999. 
All Rights Reserved

Documentation Copyright © Cyber Cow 1995 - 1999. All Rights Reserved.

OverView
File Members

 
OverView

#include <jeDebug.h>

Image 1
Image1

Image 2
Image 2

jeDebug is a runtime error tracing utility, useful for verifying input to functions etc.

How it works :
Perhaps you are familiar with the ASSERT macro ? jeDebug adds is a bunch of similar macros that you can use to verify your data. Example:

int ReadFromOpenedFile(FILE *fp)
{
    NEEDVALUE(fp);
    while (fgets(... etc ...
}

If this function is called with a null pointer instead of a valid file handle, the NEEDVALUE(fp) macro will start the jeDebug application (see image 1), and send a message to it that will be displayed in a list. (see image 2). The execution of your application will not be halted, as it is when using the ASSERT macro. If JESYS_DEBUG is not defined, the NEEDVALUE macro will be completely ignored, and will have no impact on your code.

Downloading :
Go to the Downloads page to download the lastest version of jeDebug.

Files in the zip archive :
jeDebugSetup.exe - the program that will install the jeDebug.exe app and set up the necessary registry entries.
jeDebug.h - header file for the client app (your application)
jeDebug.cpp - source file for the client app.

How to install jeDebug :
Run the jeDebugSetup.exe program, it will install the jeDebug.exe application and set up some registry info (like the path to jeDebug.exe so that your app can start the program if an error is generated). The first time it is run it will ask for a destination directory, but only the first time. If a newer version is installed, it will be done silently, automatically using the old directory.

How to add jeDebug functionality to your application :
Add the jeDebug.h and jeDebug.cpp files to your project.
Define JESYS_DEBUG when compiling the jeDebug version of your application.
You are now set to go!

Features :

  • There will only be one instance of the jeDebug app, it will collect error messages from any number of apps.
  • The jeDebug app will be started if, and only when, needed.
  • Enable/Disable debug output at runtime
  • Configurable max number of entries (useful if you're being flooded a lot, often only the first message is important)
  • The message listctrl has sortable columns.
  • Not MFC-dependant.
  • Built-in support for Win32, DirectDraw and DirectInput errors (more to come)

Todo :

  • Logging to file.
  • Save messages to custom file? Email them to app support?
  • add support for d3d etc

Background :

jeDebug was originally designed for use in my Amiga apps several years ago. It was ported to Win32 a year ago as a component of the JEPP class library, but I took it out and made a separate utility of it.

File Members

Macros

NEEDVALUE(x)

use to verify that x is not zero
NEEDVALUES(x,y) use to verify that both x and y has values other than zero (just a short for using two NEEDVALUE)
NEEDCLEAR(x) use to verify that x is indeed zero and not some other value
NEEDSAME(x,y) use to verify that x and y are equal
NEEDDIFF(x,y) use to verify that x and y are not equal but different
NEEDSTRING(x) use to verify that x has a value and that the first character is not zero, ie an empty string is invalid
NEEDLESS(x,y) use to verify that x is less than y
NEEDMORE(x,y) use to verify that x is more than y
DEBUGOUT(x) use to output a custom string x
DEBUGOUTR(x) ust to output a custom string resource
REPORTWIN32ERROR(x) use to output a report of the Win32 standard error code x
REPORTLASTWIN32ERROR use to output a report of the last Win32 error (no need to supply a code)
REPORTDIRECTDRAWERROR(x) use to output a report of the DirectDraw error code x
REPORTDIRECTINPUTERROR(x) use to output a report of the DirectInput error code x

Functions

jeDebug::StringOutF

Output a string using printf formatting style.

     
jeDebug::StringOutF()

static void StringOutF(const char *source, unsigned long line, const char *string, ...);

Return Value

None

Arguments

source

Source Code File

line

Source Code Line
string printf formatted string
... Optional arguments

Remarks
Output a string using printf formatting style, however I have not yet found a way to create a handy macro for it, so you'll have to do it like the example shows you.

Example

#ifdef JESYS_DEBUG
    jeDebug::StringOutF(__FILE__,__LINE__,

                        "the coordinates are (%d,%d)",coords.x,coords.y);
#endif