Hi,
It look like there is a severe problem when using local functions in class methods:
Once I create a local function in a class method strange things happen. It seems like the pointer to a methods stack frame is lost/currupted or points to some improper place. Local variables of the method shows nonsense values during debugging, it is not possible to see some properties of the class (No symbol in current context reported) and the code is using clearly not proper values of the properties.
Is the code actually malfunctioning, or is the debugger just showing wrong values?
use debugln(var) to output the variables.
Either build with console -WC
or use --debug-log=file to log to a file.
It may be that fpc 3.0 has changes that the debugger does not understand
------------------- EDIT
just tested.
debug info has indeed changed in fpc 3.0.0
Apparently gdb does not report the correct result. The changes make it impossible to detect this from the IDE, so this can currently not be fixed.
All you can do is change the current stackframe in the stack window, and see what the variable is in the parent frame.
Added to wiki
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Nested_Procedures_.2F_Function----- EDIT 2
http://lists.freepascal.org/pipermail/fpc-devel/2016-February/036677.html----- EDIT 4 (bit embarrassed)
I posted to fast. Did further tests.
All works as it should.
In my test, "i" must have been declared a global var in another unit. gdb will find that, even if it is not correct by pascal scope.
But if gdb does find a global var with the same name, then the local var of the outer procedure is not shown (even if it should be by pascal scoping rules)
So if you have problems with what the debugger displays, double check by explicitly selecting the outer stack frame.