Quellcode durchsuchen

* Add Logging of tasks under define

Michaël Van Canneyt vor 1 Jahr
Ursprung
Commit
42c9eb4096
2 geänderte Dateien mit 27 neuen und 2 gelöschten Zeilen
  1. 15 2
      compiler/ctask.pas
  2. 12 0
      compiler/fmodule.pas

+ 15 - 2
compiler/ctask.pas

@@ -23,6 +23,8 @@ unit ctask;
 
 {$mode ObjFPC}
 
+{ $DEFINE DEBUG_CTASK}
+
 interface
 
 uses
@@ -172,6 +174,7 @@ begin
       exit;
     result:=result.nexttask;
     end;
+  {$IFDEF DEBUG_CTASK}Writeln('No task found for '+m.ToString);{$ENDIF}
 end;
 
 function ttask_handler.cancontinue(m: tmodule; checksub : boolean; out firstwaiting: tmodule): boolean;
@@ -241,6 +244,7 @@ var
 
 begin
   m:=t.module;
+  {$IFDEF DEBUG_CTASK}Writeln(m.ToString,' Continues. State: ',m.state);{$ENDIF}
   if Assigned(t.state) then
     t.RestoreState;
   case m.state of
@@ -263,6 +267,13 @@ begin
       m.state:=ms_processed;
     end;
   Result:=m.state=ms_processed;
+  {$IFDEF DEBUG_CTASK}
+  Write(m.ToString,' done: ',Result);
+  if Result then
+    Writeln
+  else
+    Writeln(', state is now: ',m.state);
+  {$ENDIF}
   if not result then
     // Not done, save state
     t.SaveState;
@@ -273,7 +284,7 @@ procedure ttask_handler.processqueue;
 var
   t,t2 : ttask_list;
   process : boolean;
-  m,firstwaiting : tmodule;
+  dummy,firstwaiting : tmodule;
 
 begin
   t:=list.firsttask;
@@ -284,13 +295,14 @@ begin
       begin
       if continue(t) then
         begin
+        {$IFDEF DEBUG_CTASK}Writeln(t.module.ToString,' is finished, removing from task list');{$ENDIF}
         hash.Remove(t.module);
         list.Remove(t);
         end;
       // maybe the strategy can be improved.
       t:=list.firsttask;
       end
-    else if assigned(firstwaiting) and cancontinue(firstwaiting,true, m) then
+    else if assigned(firstwaiting) and cancontinue(firstwaiting,true, dummy) then
       begin
       t2:=findtask(firstwaiting);
       if t2=nil then
@@ -312,6 +324,7 @@ var
   t : ttask_list;
 
 begin
+  {$IFDEF DEBUG_CTASK}Writeln(m.ToString,' added to task scheduler. State: ',m.state);{$ENDIF}
   n:=m.modulename^;
   e:=tmodule(Hash.Find(n));
   if e=nil then

+ 12 - 0
compiler/fmodule.pas

@@ -270,6 +270,7 @@ interface
         procedure add_extern_asmsym(sym:TAsmSymbol);
         procedure add_extern_asmsym(const name:TSymStr;bind:TAsmsymbind;typ:Tasmsymtype);
         property ImportLibraryList : TFPHashObjectList read FImportLibraryList;
+        function ToString: RTLString; override;
       end;
 
        tused_unit = class(tlinkedlistitem)
@@ -1055,6 +1056,7 @@ implementation
       while Result and assigned(itm) do
         begin
         result:=tused_unit(itm).u.state in states;
+        {$IFDEF DEBUG_CTASK}writeln('  ',ToString,' checking state of ', tused_unit(itm).u.ToString,' : ',tused_unit(itm).u.state,' : ',Result);{$ENDIF}
         if not result then
            begin
            if firstwaiting=Nil then
@@ -1351,6 +1353,16 @@ implementation
         tasmsymbol.create(externasmsyms,name,bind,typ);
       end;
 
+    function tmodule.ToString: RTLString;
+      begin
+        // Assigned self so we can detect nil.
+        if assigned(modulename) then
+          Result:='('+ModuleName^+')'
+        else
+         Result:='(<'+inttostr(ptrint(self))+'>)';
+        // Possibly add some state ?
+      end;
+
 
 initialization
 {$ifdef MEMDEBUG}