Explorar o código

Generic.Reflection now alos contains TraceProcesses

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7228 8c9fc860-2736-0410-a75d-ab315db34111
felixf %!s(int64=8) %!d(string=hai) anos
pai
achega
492994171b
Modificáronse 1 ficheiros con 24 adicións e 1 borrados
  1. 24 1
      source/Generic.Reflection.Mod

+ 24 - 1
source/Generic.Reflection.Mod

@@ -1,7 +1,7 @@
 MODULE Reflection; 
 (** (c) Felix Friedrich, ETH Zurich, 2016 -- Reflection with more structured references section emitted by FoxCompiler *)
 
-IMPORT Modules, Streams, SYSTEM, Machine, Heaps, Objects, Trace;
+IMPORT Modules, Streams, SYSTEM, Machine, Heaps, Objects, Trace, Kernel;
 
 CONST 
 	ShowAllProcs = TRUE;
@@ -1230,7 +1230,30 @@ TYPE
 		END;
 	END Report;
 
+
+VAR trace: Streams.Writer;
+
+	PROCEDURE TraceH(process: Objects.Process; pc, bp: ADDRESS; stacklow, stackhigh: ADDRESS);
+	BEGIN
+		trace.String("----------- Process = "); 
+		trace.Address(process); 
+		trace.String(", Object = "); trace.Address(process.obj); 
+		trace.Ln;
+		StackTraceBack(trace, pc, bp, stacklow ,stackhigh, TRUE, FALSE);
+		trace.Update;
+	END TraceH;
+
+	(* tracing the stacks of all processes during GC phase (needs to identify and stop all processes) *)
+	PROCEDURE TraceProcesses*;
+	BEGIN
+		Objects.TraceProcessHook := TraceH;
+		
+		Kernel.GC;
+		Objects.TraceProcessHook := NIL;
+	END TraceProcesses;
+
 BEGIN
+	NEW(trace, Trace.Send, 4096); 
 	modes := " rdy run awl awc awe rip";   (* 4 characters per mode from Objects.Ready to Objects.Terminated *)
 END Reflection.