Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find the current execution point in Delphi at runtime

I've written a delphi program, which has grown to some complexitiy. Now I'm facing the problem, that I introduced somewhere an infinite loop, but I can't find the location. The program is a realtime application and hang up indefinitely. Is there a possibility to pause the exectution and find out, where my program currently is?

When I use the pause button of the delphi debugger, it always breaks in the cpu-window at a line called ntdll.RtlUserThreadStart, seems to be some kind of os method, but I have no idea what that means. Even stepping through the assembler doesn't return me in any line of my code. Is there a possibility to say the debugger to stop at an arbitary line in my code, where it's executing?

like image 941
Gnietschow Avatar asked Nov 29 '22 12:11

Gnietschow


2 Answers

The debugger might be showing the stack trace of a different thread then what you expect when you pause the program. You can check that from the "Thread Status" window (Ctrl+Alt+T).

like image 166
Sertac Akyuz Avatar answered Dec 09 '22 13:12

Sertac Akyuz


When you pause in the debugger, it won't necessarily show you the "main" thread, but all the threads will be paused. Use the thread debug window to select a different thread.

The current execution point might not be in your code. Use the call-stack debug window to see how your program got to where it is and to select which point in the stack you're interested in. You can use the "step out" command to leave the current function and go back up to the caller. That's useful when the debugger pauses your program in a library function that you don't have the source for.

like image 39
Rob Kennedy Avatar answered Dec 09 '22 14:12

Rob Kennedy