Peter,
You know… when I posted my reply, I was exchanging emails
back-and-forth with Martin O’Brien. As soon I posted it, MM
said: “You should have added ‘Except, of course, if your name
is Michal Vodicka’…”
And he was certainly right.
:-))) I could name several other devs in our company but they don’t
write drivers.
Here’s the thing, though: Using a debugger doesn’t mean you
SHOULDN’T or CAN’T use print/trace.
OK, but it differs from your original statement a bit
In fact, all methods of
print/trace are available to you from within a debugger. But
by using a debugger you can do MORE. You can step into code,
view the state of variables across your code at any given
time, follow the evidence, dynamically change values and see
the effect.
But, if you limit yourself to print/trace you simply can’t do
the things you can do from within the debugger. Sure, you
can add more print/trace. But you can’t dynamically change
the state of your code, or observe each small change as it
occurs (without print/tracing every single line, of course).
This is what I believe experienced developer shouldn’t need (when debug
own code). Of course, there are rare cases when it helps and makes
things faster when one makes a sloppy bug but finally you need to
recompile anyway. What you described is very good for beginners who
learn how to code but as I said in other mail, I believe such devs
shouldn’t write drivers.
While I would never tell somebody NOT to build good quality
tracing into their code, likewise I would never counsel
somebody to debug their driver without using a debugger.
Here is the main problem. People who use debugger usually (there are
exceptions, of course) don’t build good quality tracing to their code.
If they ever use traces, it is because debugger doesn’t work (races,
real-time problems) and they add them just to solve a particular
problem. Such traces can’t be used for general debugging. It is
necessary to use them as integral part of the code. As minimal
(mandatory in our company) is every function parameters and return
value. It is more work when you write code and unless (most) devs are
forced too, they don’t do it because don’t see immeditate gain. It is
write once use many but why to do it when there is a debugger.
Traces need some not-so-small initial investment. It isn’t only writing
them to the code, it is also necessary infrastructure. Areas, levels,
how to configure them. Something as ETW/WPP where MS failed because made
it too complicated and too primitive at once. Who’d think about it when
there is a simple and beginners’ friendly technique?
Debugging by JUST using print/trace is failing to exploit the
full range of tools and aids available. I think it would be a
serious dis-service to the less experienced readers on this
list if I were to suggest to them that learning how to use
the debugger effectively is not a useful skill.
Well, it is about priorities. What is the main and what is auxilary
tool. Traces can only work as main tool and I agree debugger can be
helpful in some scenarios (I don’t use one mainly because WinDbg is
pathetic after using SoftICE and debuggers at embedded platforms where I
develop are less than useless). Of course, WinDbg is great for crashdump
analysis.
But, Michal… debugging with the debugger adds so much more.
I don’t think so. I started programming with primitive traces because
there was no debugger this time. Later I discovered the first debugger
and really liked it as a beginner. Used debuggers for long time I slowly
returned to traces because some problems couldn’t be solved without
them. And mainly, I missed a global view; what is all the code in
various threads doing. During time I found I use debugger (SoftICE)
mainly as traces interceptor and rarely used anything else. Then SoftICE
died, I switched to DebugView and don’t miss it because reverse
enginnering isn’t my hobby anymore
Do you remember how this discussion started long time before? It was
because Linus Torvalds’s aversion to kernel debugger in Linux. This time
I found it strange, as others. Now I understand him. Easy techniques can
be harmful when people stop on this level. And most Windows driver
developers do. Debuggers allow them to write miserable drivers which
work somewhat but not well. I even tend to believe Windows would be
better OS if MS devs don’t have kernel debugger available.
Hmm, it probably belongs to NTTALK which I haven’t subscribed. Yet?
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]