There has been some discussion in the newsgroups about the Delphi 7.1 update and the apparent mismatch between the patched System.dcu and the original System.pas source unit. Unfortunately, Borland did not include it in the original D7.1 patch, but I understand they are planning to include the correct version soon
. The problem occurs when you try to step into RTL code that resides in the System unit. For instance, fire up a new Console project (File | New | Other | Console Application - yeah, we D7'ers do envy you D8'ers the File | New | Customize... command) and add the following high-tech code:
Writeln('Look - no hands, ma!');
Now enable the RTL/VCL units with debug info enabled by selecting Project | Options | Compiler | [X] Use Debug DCUs. Put the cursor on the Writeln line and press F4 to run to cursor (assuming you use the 'correct' keyboard bindings). Then press F7 to step into the code. With the D7.1 update applied you'll now find yourself at the end of the _LStrOfChar procedure inside System.pas. In other words, you're lost.
You'll also see that the blue dots signifying breakpointable code-lines are not aligned correctly with the actual source code. This is a typical sign of a mismatch between the source code and the actually compiled code. So until Borland gets the correct version of System.pas published in an updated update, we are stuck.
Or are we? Hackers like us don't like twiddling our thumbs, declaring defeat. If you look a little more closely at the mis-aligned blue dots and the wrongly positioned cursor in System.pas (it should have been down in Write0LString a few lines below), we can quickly determine how many lines we're off.
To get it right, we have to delete some lines - 8 lines, actually. But what should we delete?. If we scroll back to the top of the System.pas unit, we find some interesting, but less-than-useful comments about the GNU GPL license. As luck should have it, there are 8 lines in there. So, I delete them. And re-run the test application. Lo and behold, we now end up were we expect - in the Write0LString function! Great! A quick testing shows that other System routines now map to the correct line numbers too. Neat!
The conclusions are:
- The original D7.0 System.pas included that extra 8 lines with GNU GPL info
- The D7.1 compiled System.dcu was apparently compiled with a version of System.pas without that extra comment header
- The D7.1 update did *not* include the updated System.pas
- Apparently, no other line-number changing modifications were made to System.pas
And finally: This is only a short-term stop-gap measure until the official update with the correct System.pas is available from Borland. That file probably will contain other changes as well (otherwise System.dcu wouldn't have been updated in the first place).
Update: The System unit was updated due to a 1K buffer-size issue in LoadResString, see BDN article.