It has been many years since I used an ICE on an x86 system.
The question I have for the assembled wisdom here is: what do you use when
faced with an intractable problem?
In my particular case, turning on the kernel debugger (e.g. /debugport=1394
/channel=33) causes my problem to go away.
So the question I have for the geniuses here is: If you can’t get hold of an
ICE (too expensive) and you can’t get the debugger to replicate the problem,
then what do you do to debug?
Clearly, one thing that can be done is to do a KeBugCheck and get a static
dump when a certain condition happens in your code. But what do you do if
the condition occurs elsewhere?
A static dump doesn’t help in this case because a driver really doesn’t
maintain much in the way of state information.
One of the things that I do is create an in-memory buffer that collects
certain state information. File and line number are logged. This helps
localize what is happening when the crash occurs. When the crash occurs,
one can scan the MEMORY.DMP file for the human readable trace buffer.
Writing to a memory buffer is better than writing to a log file because the
timing is better. It is worse than writing to a log file because sometimes
you crash with a system hang.
Speaking of MEMORY.DMP, does anyone know the rules under which MEMORY.DMP is
generated from PAGEFILE.SYS? I’ve seen plenty of times when I see memory
being written but MEMORY.DMP is not created.
Specifically, the following does not seem to work on my system.
(1) Boot into Windows on partition C:.
(2) Create a crash dump (C:\Windows\pagefile.sys)
(3) Boot into Windows on partition D:.
(4) Delete c:\WINDOWS\system32\drivers\baddriver.sys
(5) Boot into Windows on partition C:
(6) C:\WINDOWS\MEMORY.DMP isn’t there (or it is an old copy)
What seems to work consistently for me is
(1) Boot into Windows on partition C:.
(2) Create a crash dump (C:\Windows\pagefile.sys)
(3) Boot into Windows safe mode partition C:.
(4) Shut down safe mode Windows.
(5) Boot into Windows on partition D:.
(6) C:\WINDOWS\MEMORY.DMP is there and can be examined by WinDBg, etc.
(7) Delete c:\WINDOWS\system32\drivers\baddriver.sys
(8) Boot into Windows on partition C: so that one can remove (using the
various SetupDi services) and reinstall the bad driver.
What I really want is to be able to use (in the absence of an ICE) are the
debug registers to trap certain conditions in other people’s code.
Is this doable in a reasonable amount of code?
Does anyone else have suggestions on how to do minimally invasive kernel
mode debugging?
Ralph Shnelvar