used to have a similarly looking weirdness in Delphi
Delphi is not FPC down there, so no exact parallels, but still something could be similar. I had a number of cases when binary files did not match sources and debug info, or sources did not match binaries adnd debug info.
In the end, the Pascal code i saw running in IDE was not the code that actually was executed (and seen in assembler window). Yes, it was royally conusing.
I used SysInternals Process Monitor eventually, to have a list of source and intermediate (.DCU, .DCP, here it probably would be .PPU, .LIB .OBJ) files used in both compilation and debugging session and compare them. And also library binaries (BPL, this does not apply to FPC i think).
One case was Delphi XE2.4 installer is broken. It installes IDE extension that copies RTL XE2.3 into Windows folder. This made any program linked in "binary packaes" mode be compiled against newer RTL and on the run loadign the older RTL. This mismatch manifested in many small incompatibilities and fuzzy behavior, and when i tried to debug - IDE loadded debuginfo and sources from XE2.4 TRL while running XE2.3 RTL binaries. ProcMon allowed me to noitce, that linker used one set of BPLs while debugger used others.
Other cases where runtime packages, the project consisted off. There was not unified structure, all the packageswere made ad hoc by different people and with different projetc options. As i was unifyign it all, i had many cases that either i forgot to rebuild each and every binary package after some source changed, or the freshly compiled units of ProjectA were put in one folder, yet ProjectB picked stale files of ProjectA from another folder. Again, ProcMon made me see it. Clean and rebuild was not helping those cases, as related projects had different folders
Other cases where same-named source files, placed in different folders, some several years older than others. On top of that, {$ifDef} were switchig on and off big parts of those sources, differently for different projects. Both Delphi IDe and debugger were royally confused to have several different copies of same-named source units loaded into one process and exectued. The Pascal sources i was seeing were diferent (if same-named) files that the one compiled into code being executed.