Fun With DbgEng

After a bit of learning the hard way, I’ve managed to get my code coverage tool covering code. Long way to go yet… but when I’m done I’ll post code.

C:\dev\coverage>objfre_wnet_amd64\amd64\coverage.exe fontenum.exe

breakpoint at c:\dev\junk\fontenum.c:29 not hit

fontenum!enumFontFamExProc coverage: 90%

breakpoint at c:\dev\junk\fontenum.c:41 not hit

breakpoint at c:\dev\junk\fontenum.c:42 not hit

breakpoint at c:\dev\junk\fontenum.c:52 not hit

breakpoint at c:\dev\junk\fontenum.c:53 not hit

breakpoint at c:\dev\junk\fontenum.c:54 not hit

breakpoint at c:\dev\junk\fontenum.c:61 not hit

breakpoint at c:\dev\junk\fontenum.c:62 not hit

fontenum!enumFonts coverage: 61%

breakpoint at c:\dev\junk\fontenum.c:89 not hit

fontenum!windowProc coverage: 96%

breakpoint at c:\dev\junk\fontenum.c:149 not hit

breakpoint at c:\dev\junk\fontenum.c:151 not hit

breakpoint at c:\dev\junk\fontenum.c:173 not hit

breakpoint at c:\dev\junk\fontenum.c:175 not hit

breakpoint at c:\dev\junk\fontenum.c:185 not hit

breakpoint at c:\dev\junk\fontenum.c:187 not hit

breakpoint at c:\dev\junk\fontenum.c:209 not hit

breakpoint at c:\dev\junk\fontenum.c:214 not hit

fontenum!WinMain coverage: 72%

breakpoint at c:\winddk\3790.1830\inc\crt\strsafe.h:5060 not hit

breakpoint at c:\winddk\3790.1830\inc\crt\strsafe.h:5062 not hit

breakpoint at c:\winddk\3790.1830\inc\crt\strsafe.h:5069 not hit

fontenum!StringCchLengthW coverage: 66%

breakpoint at c:\winddk\3790.1830\inc\crt\strsafe.h:7162 not hit

breakpoint at c:\winddk\3790.1830\inc\crt\strsafe.h:7173 not hit

fontenum!StringLengthWorkerW coverage: 86%

Total code coverage: 89/111 lines, 80%


One Fifth Of The Human Genome Is Patented

Ken Johnson tells me this is old news, but it’s new to me, and I’m so appalled that I have to complain in public about it. I’m all for intellectual property (the study of which is kind of a hobby with me), and my own company, Positive Networks, works in the intellectual property business. Still, this is a shocker to me: one-fifth of the human genome is patented, according to this National Geographic article.

I can’t offer any solutions to the problem, and there are lots of aspects in which our IP system works well, but something about this story just seems broken. Wow.

Never Use An Important Computer As A Debug Target!

This was just posted to NTDEV:

Thank you for your reply. I disabled the host controller on target machine & so its not booting up. I don’t want to lose the data. If anybody can help me recover my system, it will be highly appreciated.

This is one of the most common early mistakes that driver writers make. Never test your drivers on a machine with valuable data on it. You could (and often will!) trash the whole box and be down to a re-install. This person may wind up having to chain his drive into another computer and do emergency data transfer. Better hope EFS isn’t on!

There are tons of ways to avoid this:

  • Use VMWare, which is amazingly good – it has all sorts of options for rolling back to known good configs, too. It’s like it was custom-designed for driver writers.
  • Microsoft has been shipping VirtualPC for a while now, and it’s part of your MSDN subscription if you have one. Nearly as good as VMWare.
  • Use Norton Ghost to copy and quickly restore your OS partition
  • Go to Wal-Mart and spend US$219.84 on a basic test computer.

More Code Coverage

Matt Miller pointed out Process Stalker, which has a lot of the capabilities I’m looking for. It still doesn’t quite hit the nail on the head, though, so I’m working on a little project to see if I can do better.

Upside: it looks like I can get exactly what I want.
Downside: it took me 12 hours to find the documentation for dbgeng. Sigh.

Ken also pointed out that Kernrate (to be discussed later) can do some of what I want, but it also doesn’t quite give me the metric I’m looking for.

Code Coverage Tools

When I code on Apple or Linux (both of which use the GNU Compiler Collection and its associated tools), I [occasionally] use gprof and gcov to do profiling and code coverage testing. The nice part about them is, well, they’re free – you don’t have to fork over hundreds of dollars to some irrational company. 🙂

So, my question is this: does anyone out there know of a free Windows-based, C/C++-based code coverage tool? I know something is on tap for VS2005, but it looks to be CLR-based to me. I know zippo about CLR, and I’d like to keep it that way.

The reason I bring it up is that I recently learned from some of the Windows OS devs that they are held accountable for code coverage testing during the development process. I don’t think many Windows driver developers do much code coverage testing during development yet.

Gratuitous Trackbacks

To all of the blogs whose articles I link to, please accept my apologies for the crazy number of trackbacks you are probably seeing from me. One of the many annoying attributes of the .Text engine that my blog hoster uses is that any links are automatically trackbacked, whether I want them to be or not. I promise I’m not trying to blindly spam your comments sections!

Reason #28 that I can’t wait for the [hopefully] upcoming Community Server migration.

An Example Of English Evolution

Warning: long, boring post of dubious value ahead. Proceed with care.

One of my interests is studying languages – English in particular. I love reading Language Log every day, and there are a few other language-related links in my Blogs I Read article.

Another totally unrelated blog that I read – in fact, the very blog that got me hooked on reading blogs in the first place – is Raymond Chen’s Old New Thing. Raymond is believed to be the best programmer in the world by at least one person, and his blog is one of the highest-quality tech blogs out there.

When those worlds collide, it’s too good to resist thinking/blogging about. In a recent article of his dealing with thread affinity of user interface objects, Raymond offers the following advice:

Leaving junk behind to be cleaned up is just plain sloppy. It suggests that your program is too lazy (or stupid) to keep track of its own resources and has abdicated this to the safety net. It’s like throwing your clothes on the floor because you know your mother will eventually come by to pick it up and put it away.

He is, of course, absolutely right on the programming principle, and it applies to kernel-mode development equally well as to the window management work Raymond was discussing. But the thing that caught my eye was his use of abdicate. You can abdicate intransitively – “King Lear abdicated at the beginning of the play” – or transitively – “King Lear abdicated his throne”, but my Oxford American Dictionary that came installed on my Mac doesn’t list any senses that take an indirect object – “…and has abdicated this to the safety net.” My American Heritage Dictionary, 4e is no help either. Even The Columbia Guide To Standard American English lacks any reference to abdicate with an indirect object in its article discussing the word.

Google turns up 11,800 hits on the phrase abdicate to, compared with 813,000 results for simply abdicate, and some are not representative of an indirect object construction. Then again, the indirect object often comes after the direct object, as in “abdicate the throne to his brother”, which that query doesn’t catch. Furthermore, The Columbia World of Quotations has this 1993quote from Melinda M. Marshall:

For the mother who has opted to stay home, the question remains: Having perfected her role as a caretaker, can she abdicate control to less practiced individuals? Having put all her identity eggs in one basket, can she hand over the basket freely? Having put aside her own ambitions, can she resist imposing them on her children? And having set one example, can she teach another?

So, this construction is obviously in use, and perhaps in common use. Even if it weren’t, it strikes me[1] as exactly the kind of evolution that would be likely to occur. Regardless, it’s an interesting case of a word gaining a new sense before the dictionaries and usage manuals catch on.

[1] It should be noted that I have no right to hold this opinion, such as, for example, any actual training in linguistics. Take with a grain of salt.

Traffic Engineering, Literally

This post is all about protocols. When protocols are violated, the whole system breaks down, and people get angry. To wit:

Like many people, nothing pisses me off faster than stupid drivers. And of all stupid driving techniques, none piss me off more than people driving slowly in the fast lane. And, let’s be perfectly clear, the “speed limit” (which is really a floor-type limit, not a ceiling) is considered slow.

I travel semi-regularly in Europe – I have some family in Switzerland – and I always rent a car and drive while I’m there. People in Europe seem to know how to operate the fast lane: it is for going faster than the slow[er] lanes. You get into the left lane to pass, and when you have passed, you get back into the right lane. That way, if someone (i.e. me) wants to pass you, you’re not camping out making that person yell obscenities and curse your very existence.

So, please, be kind: drive in the right lane, and pass in the left lane, and no matter what, don’t ever go slower in the left lane than the cars in the right lane!