次の方法で共有


Attaching a debugger to the print filter pipeline service

As you should know by now, Application Verifier (and Print Verifier) works by sending error messages to the debugger that is attached to the associated process. For XPSDrv drivers, the filters are hosted by the print filter pipeline service, so you must attach a debugger to printfilterpipelinesvc.exe.

Note: I am making the assumption that you are generally familiar with how to use WinDbg to debug user-mode applications. If not, you should first read the help documentation that is included with the Debugging Tools for Windows package. Since print drivers are user-mode components only the sections on user-mode debugging are relevant. You can skip those parts of the documentation that are specific to kernel-mode debugging.

There are two basic ways to attach WinDbg to a process.

· Use WinDbg from the command line to start the process.

· Attach WinDbg to an existing process.

The filter pipeline host must be started by the print spooler, so you must use the second option to attach WinDbg to the process. However, the filter pipeline host is not persistent. A new instance of the service is started when an application submits a job to the print queue and the service is terminated shortly after the job is complete. It is difficult, at best, to attach WinDbg to printfilterpipelinesvc.exe after the print job is submitted but before the filter that you are trying to debug starts running, especially if you want to debug the filter’s startup or initialization code.

To work around this problem, you can modify the amount of time that printfilterpipelinesvc.exe persists after a print job is finished. That value is controlled by the PipelineHostTimeout value of the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print registry key.

To change the filter pipeline service timeout value:

1. Run RegEdit and navigate to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print.

2. Add a PipelineHostTimeout REG_DWORD value to the key, if it is not already present.

3. Set PipelineHostTimeout to the timeout value, in milliseconds.

Set a large enough value to give yourself ample time to attach the process and set breakpoints. This paper assumes a 1.5 minute timeout, so PipelineHostTimeout is set to 90000.

After setting the PipelineHostTimeout value, use the following procedure to attach WinDbg to the pipeline filter service:

To Attach WinDbg to the filter pipeline service

1. Run WinDbg with elevated privileges, but do not attach it to a process.

2. Submit a print job to your driver and wait for it to complete.

The filter pipeline service continues running for the specified timeout value.

3. On the WinDbg File menu, click Attach to a Process.

4. In the Attach to Process dialog box, select printfilterpipelinesvc.exe and click OK.

Tip: If the process is listed as “Access Denied”, it probably means that WinDbg is not running with elevated privileges.

5. Set breakpoints, as appropriate.

6. Submit the print job again.

The filter host process should break into the debugger at the first breakpoint or the first verifier stop, whichever comes first. From there, you can step through code, examine variables, and so on.

Comments