May 2004 Entries

I've posted my new debugger article

I've posted my new debugger article here. This is another one that started out bigger and got simpler and simpler as I worked through it as I realised that all of the difficult concepts and code for creating debuggers is actually handled in part 3. In fact it's so simple I haven't even bothered with the sample application because it just made it look more complex than it really was, although that code is still going to be released as a little utility once I'm happy with it's functionality.

I've moved my debugger articles

My debugger articles are now hosted under .TEXT here, which means they now have comments enabled so get commenting. Next one up later today. Probably.

Why are the hard bits of a program always the easiest to write?

Writing a code coverage analysis tool: Easy Making meaningful html based output with colourised text: Harder Surely they should be the other way around? Escaping invalid characters from xhtml is harder than you would think when you have to preserve the original lines and columns as well so you can apply the formatting. At the moment I have a hideous algorithm that works backwards through the file inserting tags and calling HttpUtility.HtmlEncode on the rest of the text. At this point I'm very glad that I decided that I should do this properly and unit test using TDD because this algorithm is...

OutputDebugString

Dave Kong Writes I've always like the simpler things, take for instance, OutputDebugString.  I'm surprised to find that it's a lot more complicated than i previously thought, see this link: http://www.unixwiz.net/techtips/outputdebugstring.html. Speaking of debug outputs, does anyone here find it troubling or frustrated that it seems like every project you are on, there's a different debug/trace package (from simple .h macros to full blown libs) being used?  The TRACE macros in MFC and the AtlTrace functions in ATL are already more than adequate.  I wonder what *simple* functions others use if you dont want to include MFC or ATL just for debugging?  Or is there...

Support for Mono

We have a product that we're porting to .NET at the moment and one of the improvements we've made is to have a command line version for when a full GUI isn't needed. Today I decided to try running it under Mono to see if it would work. I wasn't expecting it to work, but shockingly it did. Now we have no advantage selling a version of our software that works under Linux, MacOS and the rest because our current and potential customers just don't use anything other than Windows but it's pretty cool none the less. You never know, we...

My token mention of the new Visual Studio team software

As long term readers of my blog will know I am the worlds biggest fan of the software produced by Rational (now part of IBM). OK, that's a lie./ I hate their software more than you can possibly imagine. So my token mention is "Yay Microsoft". But I have one question: How much will it cost?

I didn't realise that the BBC were posting some of their TV shows online too now.

The first thing you should be aware of is the fact that the BBC is great. Most people probably know that already, but they have the great advantage in being funded through a fixed fee and not advertising. This means, technically, that the BBC can take risks that a commercial station can never take. It also means that they can publish the last weeks radio programmers on the internet and not annoy any advertisers. You may have noticed that I like what the BBC does. So here I am on a Sunday night watching Police Academy and trying to find something better...

When example code gets out of control

The example code for my next article seems to have a life of it's own. It started off as a simple bit of code, then I decided to be more fancy and make it do something useful. After I made that decision I decided that it was the right time to add my wrapper because it opened up the possibilities for the example code becoming more powerful in the future. Now I'm at the stage of wanting to release the example code as a fully fledged application along side the article on how it works. I have the application working except...

Are you sourcing blogs properly?

Steve Rubel, via Scoble writes: Steve Rubel: A petition to commit to proper blog sourcing. The unfortunate reality here, however, is that many bloggers themselves often neglect to properly credit other webloggers who break hard news through real reporting. How can we expect the press to source us if we neglect to credit the other members of our own community? Many journalists have a code ethics they must abide by. We don't. [Scobleizer: Microsoft Geek Blogger] It was pointed out to me a little while ago that I was mostly quoting people and it wasn't clear that...

Getting the name of a class

One of the interesting things about the CLR's debugging API is that it's not as totally OO as it could be because implementation gets in the way of design. An example for this is there is no GetName member for ICorDebugClass because this needs to be performed by using other objects. One of the reasons why I'm implementing a wrapper around these APIs is to pull this information together and so today I implemented a Name property on the class object. The function that returns the class name is IMetaDataImport::GetTypeDefProps and so my wrapper function is just a basic call to...

A blog on graphic design and MMORPGs

A friend, colleague, and a fellow founding Chimp has started a blog that covers graphic design, massively multiplayer online games (MMORPGs) and other general rants. He's the guy behind hate of the day (which I must get back online after the server move) and so he's worth a read.

More on the benefits of inlining

My previous posts on inlining need some numbers and code to back them up so... Take the following code: void Run(){   System::Diagnostics::Debugger::Break(); // Break so we can see the x86 assembly   int i = Increment1();   i = Increment2();   System::Windows::MessageBox::Show(i.ToString()); // Stop the optimiser removing the code} public int Increment1(){   int p = pos;   p++;   if(p > 10)   {      p = 0;   }   pos = p;   return pos;} public int Increment2(){   pos++;   if(pos > 10)   {      pos = 0;   }   return pos;} This code demonstrates what I said in a previous post about accessing member variables in an if statement causing the optimiser not being able to inline your...

Why am I writing a wrapper around the debugging APIs

People seem to want to comment on this blog more than the last one, and in my last post it was pointed out that you don't need to use a wrapper assembly on the debugging APIs because you can just import the type library and go from there. There are reasons why I'm using a wrapper over the COM interop method. The first was that the type library contained things that needed modifying the last time I looked in order to make it correct (which was, admittedly, a long time ago and a different version). The main reason, though,  is...

Returning an array in managed C++

I spent a lot of Saturday working on my CLR debugger API wrapper assembly (which is providing a massive distraction from actually using it to write the code for my next article) and as I came to the ICorDebugCode class I came to the GetCode function, which returns you an array of bytes that can be decompiled into ILASM, and so I set about trying to write a function that returned an array. After a little while I decided that I wasn't going to figure out how to do it through experimentation and so I hit google. After a little bit...

More on inlining

In a comment to my last post Steve asks what the benefits are to inlining code, and does it make a difference. The answer to that is, of course, it can speed up your code and it depends by how much. The code that I was examining was called hundreds of thousands times per second and so the small overhead of calling into a function was exagerated to a point where inlining the code gained a saving that could be measured in seconds per minute. The real answer to the question is no, 99% of the time you don't care about the...

My first Windows XP Embedded post - DUA feedback?

Aaron Stebner writes: OK, I know I've focused my posts thusfar on setup experiences and technologies, but I've been working on a project on my new team - Windows Embedded - and I am hoping to solicit some feedback here.  Are there folks out there using Device Update Agent (DUA) to maintain their Windows XP Embedded images?  I have run across some oddities and difficulties as I ramp up on the technology and I'm curious what experiences everyone else is having.  If you have any comments, suggestions, complaints, feedback of any kind please let me know.  I'd like to...

Big important gotcha about inlining under the CLR

Right, new blog means being more disciplined about blogging. Expect much more technical details from now on. I've been experimenting with some code that has been written under C# in order to test that an archetecture will be fast enough for a new application and as part of trying to understand what's going on I've been looking into how the JITer inlines code. The rules are, apparently, quite simple like simple flow control and only 38 bytes of ilasm code. What this all means is that nice short functions with simple if statements get inlined. Sor should do. From what I've observed...

New Blog

I've moved to .Text and so this is just a post to see if it's working.