Search code examples
delphidelphi-2007

Delphi: How to debug run until you get back to your source file?


If I run a program and an exception is raised I am asked if I want to continue or break.

If I choose break I can see where the exception is coming from but if the break is in a library or system file not one of my source files (Say the exception is in System.pas or Controls.pas) I need to manually step the execution forward using F8 until it returns to one of my files, so I can see what part of my code caused the exception.

This can take a long time.

I know I should be catching lower level exceptions in my code but in this instance it's not hitting one of my exception handlers.

Is there a way to say

  • run forward with execution until you get to file X or
  • until you get back into a project specific file.

I'm also interested out of general curiosity on how other compilers / IDEs handle this.

Apologies if I haven't made this as clear as a I should.


Solution

  • You can resolve this by using the Stack View window.

    1. Open the Stack View window (CTRL+ALT+S).
    2. Double click on the method in the stack view where you wish to insert a breakpoint.
    3. The unit, containing the caller method opens and the cursor is positioned on the caller method.
    4. Set your breakpoint.