[fpc-devel]Recompile the RTL to trace bugs

Giulio Bernardi ugilio at hotmail.com
Mon May 3 11:25:28 CEST 2004

I'm writing a sort of "compiler" for a language similar to php (so it is not
a compiler since
it doesn't produce any object code, it only checks syntax and so on). I use
delphi 6 on
win32, and freepascal 1.9.x on Linux/i386 and Mac OS X. Sometimes I compile
it with
fpc under win32 too.
It works great when compiled with fpc 1.9.0, but I have strange problems
when using
fpc 1.9.2 and 1.9.3: it compiles correctly, but I have a lot of acces
violations when running
the program, and the program behaves differently when compiled with or
without range checking.
This program makes an heavy use of dynamic arrays and recursion.
I tried to debug it using gdb, and I noticed a bad behavoir in setlength
I have a method that adds things to a dynamic array, using setlength to
increase its size dinamically.
When the array is empty, everything is okay (array grows to 1, and data is
set). When I add another
item, array grows to 2, but contents of the first element (element 0) are
corrupted: when I try to
access it, sometimes i receive garbage data, sometimes I have an access
I have this same problem under win32, linux/i386 and MacOS X.

I wasn't able to reproduce the bug in a simple program, so I would like to
step into setlength to see
what does happen.

So, how can I compile a "debug version" of rtl so that I can use it when
debugging the program?

More information about the fpc-devel mailing list