Fix failures for rtl ppudump on sparc cpu

git-svn-id: trunk@37250 -
This commit is contained in:
pierre 2017-09-18 14:10:19 +00:00
parent 91fa2999ee
commit ce332eb2e2

View File

@ -1571,6 +1571,7 @@ var
first : boolean; first : boolean;
copy_size, min_size, tokenbufsize : longint; copy_size, min_size, tokenbufsize : longint;
tokenbuf : pbyte; tokenbuf : pbyte;
tbi : longint;
// idtoken, // idtoken,
token : ttoken; token : ttoken;
// state : tmsgstate; // state : tmsgstate;
@ -1584,26 +1585,29 @@ var
var var
b,b2 : byte; b,b2 : byte;
begin begin
b:=tokenbuf[i]; b:=tokenbuf[tbi];
inc(i); inc(tbi);
if (b and $80)<>0 then if (b and $80)<>0 then
begin begin
b2:=tokenbuf[i]; b2:=tokenbuf[tbi];
inc(i); inc(tbi);
result:=ttoken(((b and $7f) shl 8) or b2); result:=ttoken(((b and $7f) shl 8) or b2);
end end
else else
result:=ttoken(b); result:=ttoken(b);
end; end;
function gettokenbufdword : dword; function gettokenbufdword : dword;
var var
var32 : dword; var32 : dword;
begin begin
var32:=pdword(@tokenbuf[i])^; var32:=unaligned(pdword(@tokenbuf[tbi])^);
inc(i,sizeof(dword)); inc(tbi,sizeof(dword));
if ppufile.change_endian then if ppufile.change_endian then
var32:=swapendian(var32); var32:=swapendian(var32);
{$ifdef FPC_BIG_ENDIAN}
{ Tokens seems to be swapped to little endian in compiler code }
var32:=swapendian(var32);
{$endif}
result:=var32; result:=var32;
end; end;
@ -1611,10 +1615,14 @@ var
var var
var16 : word; var16 : word;
begin begin
var16:=pword(@tokenbuf[i])^; var16:=unaligned(pword(@tokenbuf[tbi])^);
inc(i,sizeof(word)); inc(tbi,sizeof(word));
if ppufile.change_endian then if ppufile.change_endian then
var16:=swapendian(var16); var16:=swapendian(var16);
{$ifdef FPC_BIG_ENDIAN}
{ Tokens seems to be swapped to little endian in compiler code }
var16:=swapendian(var16);
{$endif}
result:=var16; result:=var16;
end; end;
@ -1628,26 +1636,38 @@ var
begin begin
if CpuAddrBitSize[cpu]=64 then if CpuAddrBitSize[cpu]=64 then
begin begin
var64:=pint64(@tokenbuf[i])^; var64:=unaligned(pint64(@tokenbuf[tbi])^);
inc(i,sizeof(int64)); inc(tbi,sizeof(int64));
if ppufile.change_endian then if ppufile.change_endian then
var64:=swapendian(var64); var64:=swapendian(var64);
{$ifdef FPC_BIG_ENDIAN}
{ Tokens seems to be swapped to little endian in compiler code }
var64:=swapendian(var64);
{$endif}
result:=var64; result:=var64;
end end
else if CpuAddrBitSize[cpu]=32 then else if CpuAddrBitSize[cpu]=32 then
begin begin
var32:=plongint(@tokenbuf[i])^; var32:=unaligned(plongint(@tokenbuf[tbi])^);
inc(i,sizeof(longint)); inc(tbi,sizeof(longint));
if ppufile.change_endian then if ppufile.change_endian then
var32:=swapendian(var32); var32:=swapendian(var32);
{$ifdef FPC_BIG_ENDIAN}
{ Tokens seems to be swapped to little endian in compiler code }
var32:=swapendian(var32);
{$endif}
result:=var32; result:=var32;
end end
else if CpuAddrBitSize[cpu]=16 then else if CpuAddrBitSize[cpu]=16 then
begin begin
var16:=psmallint(@tokenbuf[i])^; var16:=unaligned(psmallint(@tokenbuf[tbi])^);
inc(i,sizeof(smallint)); inc(tbi,sizeof(smallint));
if ppufile.change_endian then if ppufile.change_endian then
var16:=swapendian(var16); var16:=swapendian(var16);
{$ifdef FPC_BIG_ENDIAN}
{ Tokens seems to be swapped to little endian in compiler code }
var16:=swapendian(var16);
{$endif}
result:=var16; result:=var16;
end end
else else
@ -1755,9 +1775,9 @@ begin
writeln([space,' Tokenbuffer size : ',tokenbufsize]); writeln([space,' Tokenbuffer size : ',tokenbufsize]);
tokenbuf:=allocmem(tokenbufsize); tokenbuf:=allocmem(tokenbufsize);
ppufile.getdata(tokenbuf^,tokenbufsize); ppufile.getdata(tokenbuf^,tokenbufsize);
i:=0; tbi:=0;
write([space,' Tokens: ']); write([space,' Tokens: ']);
while i<tokenbufsize do while tbi<tokenbufsize do
begin begin
token:=readtoken; token:=readtoken;
if token<>_GENERICSPECIALTOKEN then if token<>_GENERICSPECIALTOKEN then
@ -1778,44 +1798,44 @@ begin
begin begin
len:=gettokenbufsizeint; len:=gettokenbufsizeint;
setlength(wstring,len); setlength(wstring,len);
move(tokenbuf[i],wstring[1],len*2); move(tokenbuf[tbi],wstring[1],len*2);
write([' ',wstring]); write([' ',wstring]);
inc(i,len*2); inc(tbi,len*2);
end; end;
_CSTRING: _CSTRING:
begin begin
len:=gettokenbufsizeint; len:=gettokenbufsizeint;
setlength(astring,len); setlength(astring,len);
move(tokenbuf[i],astring[1],len); move(tokenbuf[tbi],astring[1],len);
write([' ',astring]); write([' ',astring]);
inc(i,len); inc(tbi,len);
end; end;
_CCHAR, _CCHAR,
_INTCONST, _INTCONST,
_REALNUMBER : _REALNUMBER :
begin begin
write([' ',pshortstring(@tokenbuf[i])^]); write([' ',unaligned(pshortstring(@tokenbuf[tbi])^)]);
inc(i,tokenbuf[i]+1); inc(tbi,tokenbuf[tbi]+1);
end; end;
_ID : _ID :
begin begin
write([' ',pshortstring(@tokenbuf[i])^]); write([' ',unaligned(pshortstring(@tokenbuf[tbi])^)]);
inc(i,tokenbuf[i]+1); inc(tbi,tokenbuf[tbi]+1);
end; end;
_GENERICSPECIALTOKEN: _GENERICSPECIALTOKEN:
begin begin
{ Short version of column change, { Short version of column change,
byte or $80 used } byte or $80 used }
if (tokenbuf[i] and $80)<>0 then if (tokenbuf[tbi] and $80)<>0 then
begin begin
write(['Col: ',tokenbuf[i] and $7f]); write(['Col: ',tokenbuf[tbi] and $7f]);
inc(i); inc(tbi);
end end
else else
case tspecialgenerictoken(tokenbuf[i]) of case tspecialgenerictoken(tokenbuf[tbi]) of
ST_LOADSETTINGS: ST_LOADSETTINGS:
begin begin
inc(i); inc(tbi);
write('Settings'); write('Settings');
{ This does not load pmessage pointer } { This does not load pmessage pointer }
new_settings.pmessage:=nil; new_settings.pmessage:=nil;
@ -1827,42 +1847,42 @@ begin
min_size:=copy_size min_size:=copy_size
else else
min_size:= sizeof(tsettings)-sizeof(pointer); min_size:= sizeof(tsettings)-sizeof(pointer);
move(tokenbuf[i],new_settings, min_size); move(tokenbuf[tbi],new_settings, min_size);
inc(i,copy_size); inc(tbi,copy_size);
end; end;
ST_LOADMESSAGES: ST_LOADMESSAGES:
begin begin
inc(i); inc(tbi);
write('Messages:'); write('Messages:');
mesgnb:=tokenbuf[i]; mesgnb:=tokenbuf[tbi];
inc(i); inc(tbi);
for nb:=1 to mesgnb do for nb:=1 to mesgnb do
begin begin
{msgvalue:=}gettokenbufsizeint; {msgvalue:=}gettokenbufsizeint;
inc(i,sizeof(sizeint)); inc(tbi,sizeof(sizeint));
//state:=tmsgstate(gettokenbufsizeint); //state:=tmsgstate(gettokenbufsizeint);
end; end;
end; end;
ST_LINE: ST_LINE:
begin begin
inc(i); inc(tbi);
write(['Line: ',gettokenbufdword]); write(['Line: ',gettokenbufdword]);
end; end;
ST_COLUMN: ST_COLUMN:
begin begin
inc(i); inc(tbi);
write(['Col: ',gettokenbufword]); write(['Col: ',gettokenbufword]);
end; end;
ST_FILEINDEX: ST_FILEINDEX:
begin begin
inc(i); inc(tbi);
write(['File: ',gettokenbufword]); write(['File: ',gettokenbufword]);
end; end;
end; end;
end; end;
end; end;
if i<tokenbufsize then if tbi<tokenbufsize then
write(','); write(',');
end; end;
writeln; writeln;