TickShifter v0.1

Well, I figure that I’ve written about these debug tools that I’ve been working on for long enough. The time has come to make one available for other people to use and abuse. Given that I hope to sell some of these tools eventually I’ve decided not to give away early versions at present. Much as I will need feedback I think a properly structured beta program would be better for that. So, what I have done is write a cut down tool that demonstrates and uses the same technology that the other tools use. In essence if this runs OK for people then the chances are that the other tools will also run OK. I’ve also tried to make this cut down tool actually do something that’s possibly useful to some people other than just me.

The tool, TickShifter, is a cut down version of the Time Shift tool that I wrote about here. It allows you to take control of the value returned from the Win32 API GetTickCount(). You can set it to a specific value, you can freeze it so that every call returns the same value or you can offset it so that the value returned is a set amount displaced from the actual amount. That’s all this tool does but it can be useful to help in testing code that has bugs that relate to their usage of GetTickCount(); for an example of the kind of bugs that I’m talking about take a look at my Practical Testing series of articles.

You can download the tool here (x86) and here (x64) (If you want to run ON an x64 platform you can use either build but the build should match the build of the target process). I’m keen to hear any feedback that you might have. The zip file download contains TickShifter.exe itself and some sample projects that demonstrate it in action. The sample projects are as follows:

  • GetTickCount - a very simple program that simply calls GetTickCount() directly in a loop. Run under TickShifter to prove that it works.

  • GetTickCountCLR - a managed version of the above program that displays the value of the System.Environment.TickCount property in a loop. Run under TickShifter to prove that it works with managed code.

  • TimerExampleFails - an example built with the TimerQueue code that is used in the Practical Testing series of articles. This uses the code from the first article in the series, this code is broken in the respect that it fails to perform correctly when GetTickCount() rolls over to 0. The code sets 5 timers and they should go off in the correct order. Run under TickShifter with -setTicks -5000 to show the code fail when the tick count rolls over and run with -setTicks 5000 to see it work when the count doesn’t roll over.

  • TimerExampleWorks - an example built with the fixed TimerQueue code from the final article in the Practical Testing series. The code sets 5 timers and they will go off in the correct order. Run under TickShifter with -setTicks -5000 to show the code work correctly when the tick count rolls over.

  • ParentTestExe - an example that loops to display the results of GetTickCount() then launches another copy of itself, then loops again and finally pauses for 5 seconds before exiting. Note that due to the way each copy launches a further copy of itself the test will run indefinitely; well, until TickShifter runs out of memory. If you watch TickShifter in Task Manager you’ll see the threads coming and going as each new process is debugged and the memory growing as debug data for each process in the session is held until the end of the session. In a more advanced tool this would allow for cross-process reporting at the end of the session.

I quite expect that this tool will fail to run for various reasons, if it does, let me know and I’ll fix it for you.