[fpc-devel] line info for try finally except -> jumping forward and backward

Martin Frb lazarus at mfriebe.de
Wed Jun 24 17:30:14 CEST 2026


FPC generates the nodes for try blocks with just one line info => the 
line of the "try" statement.
Any code generated in addition (such as for the finally, except, or end) 
is generated with that line number.

That includes the implicit statement in begin/end (which is why stepping 
fpc code jumps to begin, before exiting at end...)

I have tried to find and fix the code generating those lines.
https://gitlab.com/freepascal.org/fpc/source/-/work_items/41801

Though this is a part of the compiler I have not looked at before, and I 
am not familiar with. Hence this will please need some review.

Doing some testing on Win-32, Win-64 (and Linux-64) has not shown any 
issues with the modified code.


----------
Mind that when testing, stepping on the "end;" line of a procedure still 
takes several steps. That needs to be worked around in the debugger. 
Since there is a call to a separate function (the $fin_*). The function 
is on the same line, but currently all stepping takes a new function as 
new line (even if it is not).


More information about the fpc-devel mailing list