Книга: Writing Windows WDM Device Drivers

Debugging Techniques

Debugging Techniques

Incremental Development

An incremental approach makes debugging far easier. Get each stage working and tested before moving onto the next stage.

An incremental approach still means that you should do proper design work. Think very carefully about how your driver is going to work before starting any development. Having decided upon a design, plan a development path that allows you to implement your design in stages.

Checked Version

Driver development environments are usually set up to produce two different builds: an optimized retail release version, called the free build, and an unoptimised test debug build, called the checked build.

Put any debug or test code so that it appears in the checked build. The simplest way to do this is to check the value of the preprocessor variable DBG, which is set to 1 in the checked build and 0 in free build. Here is an example of how to use this technique.

#if DBG
 DebugPrintInit("Wdm1 checked");
#else
 DebugPrintInit("Wdm1 free");
#endif

I shall soon look at the different types of debug code that you can put in your checked version.

Running under the checked build version of NT or W2000 can also pick up driver errors as the operating system makes more internal checks.

W2000 or W98

One decision you will need to make is whether to work primarily in Windows 2000 or Windows 98. You could set up the development environment in one operating system, and only do test installs in the other. As stated previously, you ought to be testing your driver in both operating systems.

My advice is to use Windows 2000 for development. A few useful tools are only available in W2000 (and NT). And, significantly, W2000 is better at detecting driver errors. For example, W2000 will usually cause a bugcheck when you try to access a bad address, such as writing to a NULL pointer. Windows 98 may not detect this sort of error and your driver will continue, oblivious to the problem. The downside to W2000 is that it takes a bit longer to restart.

It is useful to be able to dual boot a computer with Windows 2000 and Windows 98. If a device fails during system boot, you can use the other operating system to remove the offending driver temporarily. For this technique to work, you need the Windows 2000 system drive to be accessible to Windows 98 (i.e., not formatted in NTFS).

Оглавление книги


Генерация: 1.392. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз