Parcourir la source

* More fixes for ppudump use

git-svn-id: trunk@17956 -
pierre il y a 14 ans
Parent
commit
322e3f8a16
1 fichiers modifiés avec 102 ajouts et 25 suppressions
  1. 102 25
      compiler/ppu.pas

+ 102 - 25
compiler/ppu.pas

@@ -230,6 +230,9 @@ type
       used by this unit. Reason: see mantis #13840 }
       used by this unit. Reason: see mantis #13840 }
     indirect_crc     : cardinal;
     indirect_crc     : cardinal;
     error,
     error,
+{$ifdef generic_cpu}
+    has_more,
+{$endif not generic_cpu}
     do_crc,
     do_crc,
     do_interface_crc,
     do_interface_crc,
     do_indirect_crc  : boolean;
     do_indirect_crc  : boolean;
@@ -250,6 +253,7 @@ type
     function  readentry:byte;
     function  readentry:byte;
     function  EndOfEntry:boolean;
     function  EndOfEntry:boolean;
     function  entrysize:longint;
     function  entrysize:longint;
+    function  entryleft:longint;
     procedure getdatabuf(var b;len:integer;var res:integer);
     procedure getdatabuf(var b;len:integer;var res:integer);
     procedure getdata(var b;len:integer);
     procedure getdata(var b;len:integer);
     function  getbyte:byte;
     function  getbyte:byte;
@@ -262,6 +266,7 @@ type
     function getasizeint:asizeint;
     function getasizeint:asizeint;
     function getaword:aword;
     function getaword:aword;
     function  getreal:ppureal;
     function  getreal:ppureal;
+    function  getrealsize(sizeofreal : longint):ppureal;
     function  getstring:string;
     function  getstring:string;
     function  getansistring:ansistring;
     function  getansistring:ansistring;
     procedure getnormalset(var b);
     procedure getnormalset(var b);
@@ -301,7 +306,7 @@ implementation
     fpccrc,
     fpccrc,
     cutils;
     cutils;
 
 
-{$ifdef GENERIC_CPU}
+{$ifdef generic_cpu}
 { We need to use the correct size of aint and pint for
 { We need to use the correct size of aint and pint for
   the target CPU }
   the target CPU }
 const
 const
@@ -339,7 +344,7 @@ const
     { 12 }  8 {'avr'},
     { 12 }  8 {'avr'},
     { 13 } 32 {'mipsel'}
     { 13 } 32 {'mipsel'}
     );
     );
-{$endif GENERIC_CPU}
+{$endif generic_cpu}
 
 
 
 
 
 
@@ -571,12 +576,20 @@ end;
 function tppufile.readentry:byte;
 function tppufile.readentry:byte;
 begin
 begin
   if entryidx<entry.size then
   if entryidx<entry.size then
-   skipdata(entry.size-entryidx);
+    begin
+{$ifdef generic_cpu}
+     has_more:=true;
+{$endif not generic_cpu}
+     skipdata(entry.size-entryidx);
+    end;
   readdata(entry,sizeof(tppuentry));
   readdata(entry,sizeof(tppuentry));
   if change_endian then
   if change_endian then
     entry.size:=swapendian(entry.size);
     entry.size:=swapendian(entry.size);
   entrystart:=bufstart+bufidx;
   entrystart:=bufstart+bufidx;
   entryidx:=0;
   entryidx:=0;
+{$ifdef generic_cpu}
+  has_more:=false;
+{$endif not generic_cpu}
   if not(entry.id in [mainentryid,subentryid]) then
   if not(entry.id in [mainentryid,subentryid]) then
    begin
    begin
      readentry:=iberror;
      readentry:=iberror;
@@ -589,7 +602,11 @@ end;
 
 
 function tppufile.endofentry:boolean;
 function tppufile.endofentry:boolean;
 begin
 begin
+{$ifdef generic_cpu}
+  endofentry:=(entryidx=entry.size);
+{$else not generic_cpu}
   endofentry:=(entryidx>=entry.size);
   endofentry:=(entryidx>=entry.size);
+{$endif not generic_cpu}
 end;
 end;
 
 
 
 
@@ -598,6 +615,11 @@ begin
   entrysize:=entry.size;
   entrysize:=entry.size;
 end;
 end;
 
 
+function tppufile.entryleft:longint;
+begin
+  entryleft:=entry.size-entryidx;
+end;
+
 
 
 procedure tppufile.getdatabuf(var b;len:integer;var res:integer);
 procedure tppufile.getdatabuf(var b;len:integer;var res:integer);
 begin
 begin
@@ -756,7 +778,12 @@ begin
   else if CpuAluBitSize[tsystemcpu(header.cpu)]=16 then
   else if CpuAluBitSize[tsystemcpu(header.cpu)]=16 then
     result:=smallint(getword)
     result:=smallint(getword)
   else if CpuAluBitSize[tsystemcpu(header.cpu)]=8 then
   else if CpuAluBitSize[tsystemcpu(header.cpu)]=8 then
-    result:=shortint(getbyte);
+    result:=shortint(getbyte)
+  else
+    begin
+      error:=true;
+      result:=0;
+    end;
 {$else not generic_cpu}
 {$else not generic_cpu}
 {$ifdef cpu64bitalu}
 {$ifdef cpu64bitalu}
   result:=getint64;
   result:=getint64;
@@ -775,7 +802,12 @@ begin
   else if CpuAddrBitSize[tsystemcpu(header.cpu)]=32 then
   else if CpuAddrBitSize[tsystemcpu(header.cpu)]=32 then
     result:=getlongint
     result:=getlongint
   else if CpuAddrBitSize[tsystemcpu(header.cpu)]=16 then
   else if CpuAddrBitSize[tsystemcpu(header.cpu)]=16 then
-    result:=smallint(getword);
+    result:=smallint(getword)
+  else
+    begin
+      error:=true;
+      result:=0;
+    end;
 {$else not generic_cpu}
 {$else not generic_cpu}
 {$ifdef cpu64bitaddr}
 {$ifdef cpu64bitaddr}
   result:=getint64;
   result:=getint64;
@@ -796,7 +828,12 @@ begin
   else if CpuAluBitSize[tsystemcpu(header.cpu)]=16 then
   else if CpuAluBitSize[tsystemcpu(header.cpu)]=16 then
     result:=getword
     result:=getword
   else if CpuAluBitSize[tsystemcpu(header.cpu)]=8 then
   else if CpuAluBitSize[tsystemcpu(header.cpu)]=8 then
-    result:=getbyte;
+    result:=getbyte
+  else
+    begin
+      error:=true;
+      result:=0;
+    end;
 {$else not generic_cpu}
 {$else not generic_cpu}
 {$ifdef cpu64bitalu}
 {$ifdef cpu64bitalu}
   result:=getqword;
   result:=getqword;
@@ -806,41 +843,81 @@ begin
 {$endif not generic_cpu}
 {$endif not generic_cpu}
 end;
 end;
 
 
-
-function tppufile.getreal:ppureal;
+function  tppufile.getrealsize(sizeofreal : longint):ppureal;
 var
 var
-  d : ppureal;
-  hd : double;
+  e : ppureal;
+  d : double;
+  s : single;
 begin
 begin
-  if target_info.system=system_x86_64_win64 then
+  if sizeofreal=sizeof(e) then
     begin
     begin
-      if entryidx+sizeof(hd)>entry.size then
+      if entryidx+sizeof(e)>entry.size then
        begin
        begin
          error:=true;
          error:=true;
-         getreal:=0;
+         result:=0;
          exit;
          exit;
        end;
        end;
-      readdata(hd,sizeof(hd));
+      readdata(e,sizeof(e));
       if change_endian then
       if change_endian then
-        getreal:=swapendian(qword(hd))
+        result:=swapendian_ppureal(e)
       else
       else
-        getreal:=hd;
-      inc(entryidx,sizeof(hd));
-    end
-  else
+        result:=e;
+      inc(entryidx,sizeof(e));
+      result:=e;
+      exit;
+    end;
+  if sizeofreal=sizeof(d) then
+    begin
+      if entryidx+sizeof(d)>entry.size then
+       begin
+         error:=true;
+         result:=0;
+         exit;
+       end;
+      readdata(d,sizeof(d));
+      if change_endian then
+        result:=swapendian(pqword(@d)^)
+      else
+        result:=d;
+      inc(entryidx,sizeof(d));
+      result:=d;
+      exit;
+    end;
+  if sizeofreal=sizeof(s) then
     begin
     begin
-      if entryidx+sizeof(ppureal)>entry.size then
+      if entryidx+sizeof(s)>entry.size then
        begin
        begin
          error:=true;
          error:=true;
-         getreal:=0;
+         result:=0;
          exit;
          exit;
        end;
        end;
-      readdata(d,sizeof(ppureal));
+      readdata(s,sizeof(s));
       if change_endian then
       if change_endian then
-        getreal:=swapendian_ppureal(d)
+        result:=swapendian(pdword(@s)^)
       else
       else
-        getreal:=d;
-      inc(entryidx,sizeof(ppureal));
+        result:=s;
+      inc(entryidx,sizeof(s));
+      result:=s;
+      exit;
+    end;
+  error:=true;
+  result:=0.0;
+end;
+
+function tppufile.getreal:ppureal;
+var
+  d : ppureal;
+  hd : double;
+begin
+  if target_info.system=system_x86_64_win64 then
+    begin
+      hd:=getrealsize(sizeof(hd));
+      getreal:=hd;
+    end
+  else
+    begin
+      d:=getrealsize(sizeof(d));
+      getreal:=d;
     end;
     end;
 end;
 end;