Technical Document #14

Technical Document #14        [Product Version: 5.4 and below]
How do I use the Debug Monitor utility on VxWorks?

On VxWorks you should use the wddebug.out utility. Its usage is similar to the wddebug command-line utility used on the other supported WinDriver operating systems in similar WinDriver versions.
There is no GUI version of the Debug Monitor for VxWorks.

To use wddebug.out on VxWorks, do the following:

  1. Load the program wddebug.out into your memory.
  2. Call wddebug_main. This will give you usage instructions.
  3. Call wddebug_main with parameters wddebug_main "on" "trace" "all"
    This activates the Debug Monitor.
  4. Call wddebug_main dump.

Now the program will continuously dump debug messages, until you press ENTER. You won't get the shell prompt back (until you press ENTER) so you need to start a new shell to work with your target.

The source code for wddebug.out is found in DriverBuilder/samples/wddebug/wddebug.c.

To ensure the correct usage of the debug utility, you can either add the source code to your application (changing, of-course, the name of the main() function in the source code); or preferably, add the following two function definitions to your code and call them from main(), in order to activate the debug utility:

    int debug_start()
    /* Call this function after the call to
       drvrInit(), in order to instruct the
       kernel to start sending debug messages: */

    {
        WD_DEBUG debug;
        HANDLE hWD = WD_Open();
        if(hWD==INVALID_HANDLE_VALUE)
            return -1;

        BZERO(debug);

        debug.dwCmd = DEBUG_SET_FILTER;
        debug.dwLevel = D_TRACE;
        debug.dwSection = (DWORD)S_ALL;

        WD_Debug(hWD, &debug);

        return 0;
    }

    int debug_dump()
    /* Call this function at the end of main(),
       after the system as booted and you get
       your shell. This function causes the debug
       messages that have been sent to be displayed
       of in the debug log: */

    {
        WD_DEBUG_DUMP debugDump;
        char buf[2048];
        HANDLE hWD = WD_Open();

        if(hWD==INVALID_HANDLE_VALUE)
            return -1;

        BZERO(debugDump);
        debugDump.pcBuffer = buf;
        debugDump.dwSize = sizeof (buf);

        WD_DebugDump(hWD, &debugDump);

        printf("%s", debugDump.pcBuffer);

        return 0;
    }