Moving the execution point while debugging Delphi

Most people I know are already aware, I’ve been a Delphi programmer for years and years now. But every day I learn something new. In this article, I’d like to talk about execution points in the Delphi debugger.

The execution point is illustrated by an arrow in the left-hand gutter area, you know the one with all the blue dots, line numbers and breakpoint dots in it when you’ve compiled and run your app in debug mode.

Yesterday a colleague of mine showed me some odds and evens in the system I currently work on. It’s a new job for me, so there is a lot of digging to do, and he was helping me out.

So, we were stepping through a piece of code looking for what form class was created by a specific form object factory, and I missed my stop, so to speak. I moved to fast and stepped past the actual if statement determining what class to instantiate.

For all my years as a developer I’ve just sighed, stopped the debug session and started over on these occasions, and I did just so in this case.

My colleagues, who for some odd reason or other prefer c# and Visual Studio exclaimed ‘can’t Delphi go back in the code?’

I asked him what he meant, and he explained that in VS you can drag the execution point backwards and forwards in the code, and can’t you do that in Delphi?

‘No’, I said almost a little laugh in the corner of my mouth. For me, the tick-tock of a program’s execution flow was so fixed and static, that for all my years as a developer, I haven’t ever even stopped to think about the possibility of altering the clockwork of program execution while a programme is running.

So, when we landed at the same point of execution the next debugging session, he showed me, and I hardly believed what I saw.

He just clicked and held the little execution arrow and pulled it upwards in the code and continued from the new execution point.

I have no doubt in my mind that some, or even most, of you already knew this, and that you now regard me in a little bit lesser light.

But I was truly flabbergasted by this remarkably and utterly useful feature that’s been hidden from me for all these years, hidden by my own fixed and rigid frame of reference.

The moral of this story? Well, never ever think yourself an expert, but always have your eyes and ears open to things you can’t even imagine.