Hi,

Attached patch tries to give more verbose PPU error messages, but only
in case a unit cannot be found. Selected, common mistakes like wrong
target, wrong compiler version are queued in a list, and upon error
printed to output.

Thoughts ?

Micha
Index: verbose.pas
===================================================================
--- verbose.pas (revision 4805)
+++ verbose.pas (working copy)
@@ -68,6 +68,9 @@
     var
       msg : pmessage;
 
+    type
+      tmsgqueueevent = procedure(s:string;v,w:longint) of object;
+
     const
       msgfilename : string = '';
 
@@ -84,16 +87,16 @@
     procedure Internalerror(i:longint);
     procedure Comment(l:longint;s:string);
     function  MessagePchar(w:longint):pchar;
-    procedure Message(w:longint);
-    procedure Message1(w:longint;const s1:string);
-    procedure Message2(w:longint;const s1,s2:string);
-    procedure Message3(w:longint;const s1,s2,s3:string);
-    procedure Message4(w:longint;const s1,s2,s3,s4:string);
-    procedure MessagePos(const pos:tfileposinfo;w:longint);
-    procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string);
-    procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string);
-    procedure MessagePos3(const pos:tfileposinfo;w:longint;const 
s1,s2,s3:string);
-    procedure MessagePos4(const pos:tfileposinfo;w:longint;const 
s1,s2,s3,s4:string);
+    procedure Message(w:longint;onqueue:tmsgqueueevent=nil);
+    procedure Message1(w:longint;const s1:string;onqueue:tmsgqueueevent=nil);
+    procedure Message2(w:longint;const 
s1,s2:string;onqueue:tmsgqueueevent=nil);
+    procedure Message3(w:longint;const 
s1,s2,s3:string;onqueue:tmsgqueueevent=nil);
+    procedure Message4(w:longint;const 
s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos(const 
pos:tfileposinfo;w:longint;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos1(const pos:tfileposinfo;w:longint;const 
s1:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos2(const pos:tfileposinfo;w:longint;const 
s1,s2:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos3(const pos:tfileposinfo;w:longint;const 
s1,s2,s3:string;onqueue:tmsgqueueevent=nil);
+    procedure MessagePos4(const pos:tfileposinfo;w:longint;const 
s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil);
 
     { message calls with codegenerror support }
     procedure cgmessage(t : longint);
@@ -486,13 +489,15 @@
       end;
 
 
-    Procedure Msg2Comment(s:string);
+    Procedure Msg2Comment(s:string;w:longint;onqueue:tmsgqueueevent);
       var
         idx,i,v : longint;
         dostop  : boolean;
+        doqueue : boolean;
       begin
       {Reset}
         dostop:=false;
+        doqueue:=false;
         v:=0;
       {Parse options}
         idx:=pos('_',s);
@@ -564,13 +569,22 @@
         Delete(s,1,idx);
       { check verbosity level }
         if not CheckVerbosity(v) then
-          exit;
+        begin
+          doqueue := onqueue <> nil;
+          if not doqueue then
+            exit;
+        end;
         if (v and V_LineInfoMask)<>0 then
           v:=v or V_LineInfo;
       { fix status }
         UpdateStatus;
       { Fix replacements }
         DefaultReplacements(s);
+        if doqueue then
+        begin
+          onqueue(s,v,w);
+          exit;
+        end;
       { show comment }
         if do_comment(v,s) or dostop then
           raise ECompilerAbort.Create;
@@ -590,98 +604,98 @@
       end;
 
 
-    procedure Message(w:longint);
+    procedure Message(w:longint;onqueue:tmsgqueueevent=nil);
       begin
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[]));
+        Msg2Comment(msg^.Get(w,[]),w,onqueue);
       end;
 
 
-    procedure Message1(w:longint;const s1:string);
+    procedure Message1(w:longint;const s1:string;onqueue:tmsgqueueevent=nil);
 
       begin
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1]));
+        Msg2Comment(msg^.Get(w,[s1]),w,onqueue);
       end;
 
 
-    procedure Message2(w:longint;const s1,s2:string);
+    procedure Message2(w:longint;const 
s1,s2:string;onqueue:tmsgqueueevent=nil);
       begin
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1,s2]));
+        Msg2Comment(msg^.Get(w,[s1,s2]),w,onqueue);
       end;
 
 
-    procedure Message3(w:longint;const s1,s2,s3:string);
+    procedure Message3(w:longint;const 
s1,s2,s3:string;onqueue:tmsgqueueevent=nil);
       begin
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1,s2,s3]));
+        Msg2Comment(msg^.Get(w,[s1,s2,s3]),w,onqueue);
       end;
 
 
-    procedure Message4(w:longint;const s1,s2,s3,s4:string);
+    procedure Message4(w:longint;const 
s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil);
       begin
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]));
+        Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]),w,onqueue);
       end;
 
 
-    procedure MessagePos(const pos:tfileposinfo;w:longint);
+    procedure MessagePos(const 
pos:tfileposinfo;w:longint;onqueue:tmsgqueueevent=nil);
       var
         oldpos : tfileposinfo;
       begin
         oldpos:=aktfilepos;
         aktfilepos:=pos;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[]));
+        Msg2Comment(msg^.Get(w,[]),w,onqueue);
         aktfilepos:=oldpos;
       end;
 
 
-    procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string);
+    procedure MessagePos1(const pos:tfileposinfo;w:longint;const 
s1:string;onqueue:tmsgqueueevent=nil);
       var
         oldpos : tfileposinfo;
       begin
         oldpos:=aktfilepos;
         aktfilepos:=pos;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1]));
+        Msg2Comment(msg^.Get(w,[s1]),w,onqueue);
         aktfilepos:=oldpos;
       end;
 
 
-    procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string);
+    procedure MessagePos2(const pos:tfileposinfo;w:longint;const 
s1,s2:string;onqueue:tmsgqueueevent=nil);
       var
         oldpos : tfileposinfo;
       begin
         oldpos:=aktfilepos;
         aktfilepos:=pos;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1,s2]));
+        Msg2Comment(msg^.Get(w,[s1,s2]),w,onqueue);
         aktfilepos:=oldpos;
       end;
 
 
-    procedure MessagePos3(const pos:tfileposinfo;w:longint;const 
s1,s2,s3:string);
+    procedure MessagePos3(const pos:tfileposinfo;w:longint;const 
s1,s2,s3:string;onqueue:tmsgqueueevent=nil);
       var
         oldpos : tfileposinfo;
       begin
         oldpos:=aktfilepos;
         aktfilepos:=pos;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1,s2,s3]));
+        Msg2Comment(msg^.Get(w,[s1,s2,s3]),w,onqueue);
         aktfilepos:=oldpos;
       end;
 
 
-    procedure MessagePos4(const pos:tfileposinfo;w:longint;const 
s1,s2,s3,s4:string);
+    procedure MessagePos4(const pos:tfileposinfo;w:longint;const 
s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil);
       var
         oldpos : tfileposinfo;
       begin
         oldpos:=aktfilepos;
         aktfilepos:=pos;
         MaybeLoadMessageFile;
-        Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]));
+        Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]),w,onqueue);
         aktfilepos:=oldpos;
       end;
 
Index: fppu.pas
===================================================================
--- fppu.pas    (revision 4805)
+++ fppu.pas    (working copy)
@@ -43,6 +43,7 @@
        tppumodule = class(tmodule)
           ppufile    : tcompilerppufile; { the PPU file }
           sourcefn   : pstring; { Source specified with "uses .. in '..'" }
+          comments   : tstringlist;
 {$ifdef Test_Double_checksum}
           crc_array  : pointer;
           crc_size   : longint;
@@ -63,6 +64,8 @@
           procedure load_implementation;
           procedure load_symtable_refs;
           procedure load_usedunits;
+          procedure printcomments;
+          procedure queuecomment(s:string;v,w:longint);
           procedure writesourcefiles;
           procedure writeusedunit(intf:boolean);
           procedure writelinkcontainer(var 
p:tlinkcontainer;id:byte;strippath:boolean);
@@ -93,7 +96,8 @@
   symtable, symsym,
   scanner,
   aasmbase,ogbase,
-  parser;
+  parser,
+  comphook;
 
 {****************************************************************************
                                  Helpers
@@ -121,6 +125,7 @@
     constructor tppumodule.create(LoadedFrom:TModule;const s:string;const 
fn:string;_is_unit:boolean);
       begin
         inherited create(LoadedFrom,s,_is_unit);
+        comments:=tstringlist.create;
         ppufile:=nil;
         sourcefn:=stringdup(fn);
       end;
@@ -131,6 +136,8 @@
         if assigned(ppufile) then
          ppufile.free;
         ppufile:=nil;
+        comments.free;
+        comments:=nil;
         stringdispose(sourcefn);
         inherited Destroy;
       end;
@@ -146,13 +153,30 @@
         inherited reset;
       end;
 
+    procedure tppumodule.queuecomment(s:string;v,w:longint);
+    begin
+      comments.insert(s);
+    end;
 
+    procedure tppumodule.printcomments;
+    var
+      comment: string;
+    begin
+      { comments are inserted in reverse order }
+      repeat
+        comment := comments.getlast;
+        if length(comment) = 0 then
+          exit;
+        do_comment(v_normal, comment);
+      until false;
+    end;
+
     function tppumodule.openppu:boolean;
       var
         ppufiletime : longint;
       begin
         openppu:=false;
-        Message1(unit_t_ppu_loading,ppufilename^);
+        Message1(unit_t_ppu_loading,ppufilename^,@queuecomment);
       { Get ppufile time (also check if the file exists) }
         ppufiletime:=getnamedfiletime(ppufilename^);
         if ppufiletime=-1 then
@@ -178,7 +202,7 @@
       { check for allowed PPU versions }
         if not (ppufile.GetPPUVersion = CurrentPPUVersion) then
          begin
-           Message1(unit_u_ppu_invalid_version,tostr(ppufile.GetPPUVersion));
+           
Message1(unit_u_ppu_invalid_version,tostr(ppufile.GetPPUVersion),@queuecomment);
            ppufile.free;
            ppufile:=nil;
            exit;
@@ -188,7 +212,7 @@
          begin
            ppufile.free;
            ppufile:=nil;
-           Message(unit_u_ppu_invalid_processor);
+           Message(unit_u_ppu_invalid_processor,@queuecomment);
            exit;
          end;
       { check target }
@@ -196,7 +220,7 @@
          begin
            ppufile.free;
            ppufile:=nil;
-           Message(unit_u_ppu_invalid_target);
+           Message(unit_u_ppu_invalid_target,@queuecomment);
            exit;
          end;
 {$ifdef cpufpemu}
@@ -1211,7 +1235,7 @@
                   (pu.u.crc<>pu.checksum)
                  ) then
                begin
-                 
Message2(unit_u_recompile_crc_change,realmodulename^,pu.u.realmodulename^);
+                 
Message2(unit_u_recompile_crc_change,realmodulename^,pu.u.realmodulename^,@queuecomment);
                  recompile_reason:=rr_crcchanged;
                  do_compile:=true;
                  exit;
@@ -1256,7 +1280,7 @@
               { need to recompile the current unit ? }
               if (pu.u.interface_crc<>pu.interface_checksum) then
                 begin
-                  
Message2(unit_u_recompile_crc_change,realmodulename^,pu.u.realmodulename^+' 
{impl}');
+                  
Message2(unit_u_recompile_crc_change,realmodulename^,pu.u.realmodulename^+' 
{impl}',@queuecomment);
                   recompile_reason:=rr_crcchanged;
                   do_compile:=true;
                   exit;
@@ -1445,6 +1469,7 @@
                    search_unit(true,true);
                  if not(sources_avail) then
                   begin
+                    printcomments;
                     if recompile_reason=rr_noppu then
                       Message1(unit_f_cant_find_ppu,realmodulename^)
                     else
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to