[fpc-devel] probably incorrect debug-line-info generated by fpc 2.6.2 and trunk

Martin lazarus at mfriebe.de
Sun Nov 10 22:42:26 CET 2013


On 10/11/2013 21:27, Jonas Maebe wrote:
> On 10 Nov 2013, at 22:24, Martin wrote:
>
>> Below is
>> - a small function
>> - an extract of what fpc generates with -la
>> - from the -la output, the debug info
>>
>> This was generated without optimization
>>
>> the statement for "i:=1" ends after " movl    $1,%eax ".
>> it ends before the value is written to memory (the "movl %eax,-12(%ebp)" is part of the next command)
>>
>> This means the debugger can not show the correct value.
> If you disable optimisations it will work as you expect. Even -O1 can slightly mess up the debug information in some cases.
>
Sorry my fault,

I had thought that I disabled all optimisation.
But I must have had some config in the depth of my IDE.

Using a clean IDE conf, and yes it works with optimization disabled.


It is still interesting though.

Why is the
movl    %eax,-12(%ebp)
generated at the start of i:=i+1

Why does a statement save an outdated value to memory?

It does not read it back, it continues with what is already on memory, 
and the at the end of the statement (this time in the statement)  the 
new value is writtes to memory.

Meaning "i := i+1" writes something to memory, that will never be used, 
and be replaced within the same statement.


I agree that -O1 is not guaranteed save (and I had tried to test it, but 
got caught by an IDE that outsmarted me...)

So it is ok for O1 to drop the
movl    %eax,-12(%ebp)
from the "i:=1"
I accept that.

But then for an optimization, to add a useless asm to the next command?






More information about the fpc-devel mailing list