Generating trace messages is a relatively easy way to record what your driver is doing. You can use the messages to track the path of an I/O request through your code, to figure out where bugs might be, and determine which routines are called frequently and which are rarely exercised. With this information, you can diagnose driver problems more easily.
To get the most out of tracing, observe these best practices:
Define trace flags that correspond to the types of information that you find most helpful during debugging.
For example, as you incrementally implement and test your code, you could define a new flag for each new driver module.
Do not conditionally compile the trace statements in your driver.
Leave them in the retail binaries-trace messages have a noticeable performance impact only if a trace consumer explicitly enables them.
Place a trace message in every error path.
The message can provide detailed information to help diagnose the cause of the error with relatively little overhead.