Jump to content
PeterPanettone

Uses Clause Manager - Project list does not work with map file in 64-bit programs

Recommended Posts

If you configure the Uses Clause Manager to use the map file to build the list of Project Units in a Windows 64-bit program then the list of Project Units does not contain the units from the map file: It contains only the list of units from the project file (.dpr).

 

I have investigated the problem and found out that the compiler generates a different map file with 32-bit programs and with 64-bit programs respectively:

 

• 32-bit programs: The ACBP alignment denomination is used

 

• 64-bit programs: The ALIGN alignment denomination is used

 

I will now fix this bug in GExperts and post a patch here.

  • Like 1
  • Thanks 1

Share this post


Link to post

Done:

 

In \Source\Utils\GX_dzMapFileReader.pas, the original TMapFileReader.ParseSegments method is as follows:

 

procedure TMapFileReader.ParseSegments(_StartIdx: Integer);
var
  i: Integer;
  s: string;
  p: Integer;
begin
  for i := _StartIdx to FContent.Count - 1 do
  begin
    s := FContent[i];
    if s = '' then
      Exit;
    if TryCutAt(' M=', s) then
    begin
      p := Pos(' ACBP=', s);
      if p > 0 then
      begin
        s := Copy(s, 1, p);
        s := Trim(s);
        FUnits.add(s);
      end;
    end;
  end;
end;

 

Replace it with this code:

 

procedure TMapFileReader.ParseSegments(_StartIdx: Integer);
const
  StrACBP  = ' ACBP=';
  StrALIGN = ' ALIGN=';
var
  i: Integer;
  s: string;
  p: Integer;
  AlignStr: string;
begin
  //CodeSite.Send('TMapFileReader.ParseSegments: AlignTest START');
  p := Pos(StrACBP, FContent.Text);
  if p > 0 then // 32-bit platform
    AlignStr := StrACBP
  else
  begin
    p := Pos(StrALIGN, FContent.Text);
    if p > 0 then // 64-bit platform
      AlignStr := StrALIGN
    else
      EXIT;
  end;
  //CodeSite.Send('TMapFileReader.ParseSegments: AlignTest END'); // time not measurable

  for i := _StartIdx to FContent.Count - 1 do
  begin
    s := FContent[i];
    if s = '' then
      Exit;
    if TryCutAt(' M=', s) then
    begin
      p := Pos({' ACBP='}AlignStr, s);
      if p > 0 then
      begin
        s := Copy(s, 1, p);
        s := Trim(s);
        FUnits.add(s);
      end;
    end;
  end;
  //CodeSite.Send('TMapFileReader.ParseSegments: FUnits-List at end of ParseSegments', FUnits.Text);
end;

 

Share this post


Link to post

Thanks a lot. I was expecting the reason for this functionlity to fail to be a compiler / map file incompatibility but didn't know if I was right.

This will solve it for Win64, but probably not for the other target platforms because they use yet another compiler.

Share this post


Link to post

Now the GExperts UCM MapFile-based ProjectUnitsList works for the Win32 platform and for the Win64 platform. Anybody is invited to add other platforms.

 

BTW, thanks to Thomas for the Uses Clause Manager which is a very good idea!

Share this post


Link to post

Committed (with changes)

 

Note: There is still a problem with the Uses manager not finding the .map file if the output directory contains the default place holders $(Platform) or $(Config). This probably also affects other places that can use the map file, like Grep or Open File. I'll file a bug report for this.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×