Printer Driver Debugging

Hi all,

I’m developing printer driver, but I’m unable to decide whether to start
developing the driver from scratch or to customize the Unidrv. Also I’m
unable to debug the printer drivers either through the WinDbg or SoftICE.
And at the sama time, I can debug other drivers. Is there any book or site
or community that can help me in developing the printer driver? Pls. let me
know.

Adi


The MSN Gamezone! http://www.msn.co.in/gamezone Ready for the challenge?

Anees:

I’m developing Printer Driver and I’m unable to debug the driver. But if I
try to debug other kinds of drivers, such as Port I/O, then I can debug them
without any difficulty. I’m getting the message such as Symbols could not be
located, and actually they are there in the specified directory, and also it
is set in the WinDbg. So if you have any idea abt the Printer Drivers, pls.
write me A.S.A.P.

Thanks,

Adi


The MSN Gamezone! http://www.msn.co.in/gamezone Ready for the challenge?

Hello,
I am having similar problem for my driver. I have set
path for symbols to point to directory where
driver.pdb is located. But debugger refuses to load
symbols. Any idea how to check the symbol file?
I posted a mail 2 days ago named " Need help on
Windbg" and found guidance that I should check symbol
file path. That seems to be OK. So I am still unable
to debug my driver.
If anybody can guide me further, that would be
helpful.
Thanks
Shamila
— adi bhapse wrote:
> Anees:
>
> I’m developing Printer Driver and I’m unable to
> debug the driver. But if I
> try to debug other kinds of drivers, such as Port
> I/O, then I can debug them
> without any difficulty. I’m getting the message such
> as Symbols could not be
> located, and actually they are there in the
> specified directory, and also it
> is set in the WinDbg. So if you have any idea abt
> the Printer Drivers, pls.
> write me A.S.A.P.
>
>
> Thanks,
>
>
> Adi
>
>
_______________
> The MSN Gamezone! http://www.msn.co.in/gamezone
> Ready for the challenge?
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

  1. Create the empy directory
  2. Copy the driver’s SYS and PDB there, and do this on each rebuild.
  3. Say .symfix and specify this directory as the additional symbol
    directory, so the symbol search path will be like:

d:\sym;srv*D:\SymCache*http://msdl.microsoft.com/download/symbols

Here “d:\sym” is the directory I was speaking about in items 1-2, and
D:\SymCache is the empty directory to cache the copies of the MS’s PDBs from
the Symbol Server.

After this, the thing works. Note: you need DSL-quality connection for
Symbol Server. There are very good chances that the debugger will like to
download 40MB at some operations like setting a breakpoint or mistyping the
name in “u” or “dd” commands. It is slow even on 1MBps. After the cache is
populated (and it is re-populated for each target OS, service pack and
sometimes hotfixes), such things cease to occur.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----

From: “Sharmila Panse”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, May 25, 2005 5:10 PM
Subject: Re: [ntdev] Printer Driver Debugging

> Hello,
> I am having similar problem for my driver. I have set
> path for symbols to point to directory where
> driver.pdb is located. But debugger refuses to load
> symbols. Any idea how to check the symbol file?
> I posted a mail 2 days ago named " Need help on
> Windbg" and found guidance that I should check symbol
> file path. That seems to be OK. So I am still unable
> to debug my driver.
> If anybody can guide me further, that would be
> helpful.
> Thanks
> Shamila
> — adi bhapse wrote:
> > Anees:
> >
> > I’m developing Printer Driver and I’m unable to
> > debug the driver. But if I
> > try to debug other kinds of drivers, such as Port
> > I/O, then I can debug them
> > without any difficulty. I’m getting the message such
> > as Symbols could not be
> > located, and actually they are there in the
> > specified directory, and also it
> > is set in the WinDbg. So if you have any idea abt
> > the Printer Drivers, pls.
> > write me A.S.A.P.
> >
> >
> > Thanks,
> >
> >
> > Adi
> >
> >
> _______________
> > The MSN Gamezone! http://www.msn.co.in/gamezone
> > Ready for the challenge?
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as:
> > xxxxx@yahoo.com
> > To unsubscribe send a blank email to
> > xxxxx@lists.osr.com
> >
>
>

> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

You should use the “!sym noisy” command in order to see verbose spew
about where the debugger is looking for the symbols and what module’s
symbols can’t be matched. As for debugging printer drivers in
particular, some of the details are different from debugging other
kernel mode drivers. So here is some info that is specific to printer
drivers. FYI, this info has been added to the next version of the driver
kit docs.

*******************************************
Debugging Printer Driver Components
[This is preliminary documentation and subject to change.]

If you are developing a printer driver rendering plug-in or user
interface plug-in, you can enable debug messages in these components. As
explained in the Global Debug Variable section, you can use a global
debug variable to control the level of detail in messages appearing in
the debugger window.

You can use the macros discussed in the Debug Message Macros section to
send messages to the debugger window under a variety of conditions. In
addition, you can use the information in this section to enable debug
messages in the Microsoft Universal Printer Driver (Unidrv) or
PostScript Printer Driver (Pscript) renderers, provided that you have
checked builds of these DLLs.

Steps for debugging a user-mode driver and some general debugging tips
are included in the next two sections.

Preparing for User-Mode Debugging

To start debugging printer drivers and their components:

Install the latest debugging tools from Debugging Tools for Windows on
the WHDC Web site.

Install the correct symbols from Debugging Tools and Symbols on the
WHDC Web site.

Note It is very important that you use the latest version of the
debugger.

It is advisable to install the checked build of only the components that
you are interested in debugging. Typically you would replace the
following retail binaries with their corresponding checked builds:

Unidrv.dll
Unidrvui.dll
Unires.dll

You should also install the checked build of the Oemuni sample or the
printer driver that you are debugging. The advantage of using this
approach, as opposed to installing an entire checked build system, is
that you won’t slow down the entire system.

Starting a User-Mode Debugging Session
To begin user-mode debugging, on the File menu in Windbg debugger select
Attach to a Process. The process that you attach the debugger to depends
on the scenario that you are attempting to debug. For printer drivers,
you must attach the debugger to either the printing application or to
the spooler process (Spoolsv.exe). Keep in mind that the printing
application loads the configuration/user interface module, while the
spooler process loads the rendering module. However, there are
differences for “FILE:” printing, where spooling does not take place and
as a result, the rendering module is also loaded by the printing
application. You must therefore ensure that you attach to the correct
process.

Tip You do not require two separate machines for user-mode debugging.

The following procedure will get you ready to debug the Oemuni sample.

Install the Oemuni sample on the “FILE:” port.
Launch the WordPad application by clicking the Start menu, selecting All
Programs, selecting Accessories, and then selecting WordPad.
On the WinDbg File menu, select Attach to a Process. In the list of
available processes, select WordPad.exe.
Start a print job from WordPad. You are now ready to debug the Oemuni
sample.

You can enable verbose debugging by turning on the giDebugLevel
variable. Its default value is 3, which denotes WARNING. If set to 1, it
denotes VERBOSE. To set the latter value wth Unidrv.dll, type the
following command in the debugger:

ed unidrv!giDebugLevel 1

When you are running the Oemuni sample, the same debugging variable also
applies, so to enable verbose debugging, type the following command:

ed oemuni!giDebugLevel 1

You can also add your own debug statements to the Oemuni sample.

For more information about setting debugging values, see the WinDbg
documentation, which describes the available commands and outlines steps
required to set up user-mode debugging. To access the documentation, on
the WinDbg Help menu, select Contents.

Global Debug Variable
The giDebugLevel global variable is declared by the Oemui and Oemuni
samples in their Debug.h and Debug.cpp files. The value of giDebugLevel
can be modified by:

Changing its value in the debugger.
Redefining its value in the plug-in.

You can set giDebugLevel to any of the following values:

#define DBG_VERBOSE 1
#define DBG_TERSE 2
#define DBG_WARNING 3
#define DBG_ERROR 4
#define DBG_RIP 5

Debug Message Macros
The following macros are used for debugging purposes. Several of them
take action only if the giDebugLevel global variable, which controls
which debug messages are emitted, is set to a specific value. The macros
expand to white spaces on a free build. Here are brief descriptions of
what they do and their parameters.

ASSERT(cond)
Verifies whether the Boolean expression in cond is TRUE. If it is not,
the macro forces a breakpoint.
ASSERTMSG(cond, (msg))
Verifies whether the Boolean expression in cond is TRUE. If it is not,
the macro displays the message in msg, and forces a breakpoint.
ERR((msg))
Displays the message in msg if the current debug level is <= DBG_ERROR.
The message format is:
ERR filename (linenumber): msg

RIP((msg))
Displays the message in msg and forces a breakpoint.
TERSE((msg))
Displays the message in msg if the current debug level is <= DBG_TERSE.
VERBOSE((msg))
Displays the message in msg if the current debug level is <=
DBG_VERBOSE.
WARNING((msg))
Displays the message in msg if the current debug level is <=
DBG_WARNING. The message format is:
WRN filename (linenumber): msg

Note that all of the macros with a msg argument require an extra pair of
parentheses surrounding this argument. Here are two examples that
illustrate this requirement:

ASSERTMSG(x > 0, (“x is less than 0\n”));

WARNING( (“App passed NULL pointer, ignoring…\n”) );

The macros that contain a msg argument are defined by the Oemui and
Oemuni samples in their Debug.h headers.

*******************************************

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sharmila Panse
Sent: Wednesday, May 25, 2005 6:11 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Printer Driver Debugging

Hello,
I am having similar problem for my driver. I have set path for symbols
to point to directory where driver.pdb is located. But debugger refuses
to load symbols. Any idea how to check the symbol file?
I posted a mail 2 days ago named " Need help on Windbg" and found
guidance that I should check symbol file path. That seems to be OK. So I
am still unable to debug my driver.
If anybody can guide me further, that would be helpful.
Thanks
Shamila
— adi bhapse wrote:
> Anees:
>
> I’m developing Printer Driver and I’m unable to debug the driver. But
> if I try to debug other kinds of drivers, such as Port I/O, then I can

> debug them without any difficulty. I’m getting the message such as
> Symbols could not be located, and actually they are there in the
> specified directory, and also it is set in the WinDbg. So if you have
> any idea abt the Printer Drivers, pls.
> write me A.S.A.P.
>
>
> Thanks,
>
>
> Adi
>
>
_______________
> The MSN Gamezone! http://www.msn.co.in/gamezone
> Ready for the challenge?
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com