Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
7 Views

Final procedures and debugging

I have recently noticed that when I have a derived type with a "final" procedure, and I am debugging line by line with F11, when the instance of the derived type moves out of scope at the relevant "end subroutine" statement, the debugger just jumps to the next statement after the original "call", when I would really like it to (i.e. expect it to) jump to the first statement in the final procedure.

Now that I know this is what will happen I can put a break point in the final procedure, and that does work, but I do wonder if this is a "feature" of debugging that has been overlooked, or at least not documented very well.

0 Kudos
3 Replies
Highlighted
Black Belt Retired Employee
7 Views

From the debugger's viewpoint, it is doing what you asked. The finalization is part of the scope exit code, not the next statement. Setting a breakpoint in the final routine is what you'd need to do.

0 Kudos
Highlighted
New Contributor I
7 Views

In the debugger in VS on Windows: F11 is "step into", and F10 is "step over".

I would like and expect F11 to visit every line of my source code that gets executed.

I agree with Steve's response, had I been hitting F10 and sat at the end subroutine statement.

Just a thought (or is it a terrible warning?)

0 Kudos
Highlighted
Black Belt Retired Employee
7 Views

You would need to be in assembly view, I think, to step into finalization and even then you'd first enter a library routine which, after a while, calls the finalizer. 

0 Kudos