Jelajahi Sumber

small cleanups, exception handling (FINALLY) now works in the Darwin port too

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7640 8c9fc860-2736-0410-a75d-ab315db34111
eth.guenter 7 tahun lalu
induk
melakukan
dc10d00f8c

+ 18 - 18
source/Generic.Darwin.I386.Unix.Mod

@@ -353,23 +353,23 @@ TYPE
 	McontextDesc* = RECORD
 				r_trapno-		: LONGINT;
 				r_err-			: LONGINT;
-				r_faultvaddr-	: LONGINT;
-				r_ax-			: LONGINT;
-				r_bx-			: LONGINT;
-				r_cx-			: LONGINT;
-				r_dx-			: LONGINT;
-				r_di-			: LONGINT;
-				r_si-			: LONGINT;
-				r_bp*			: LONGINT;
-				r_sp*			: LONGINT;
-				r_ss-			: LONGINT;
-				r_flags-		: LONGINT;
-				r_pc*			: LONGINT;
-				r_cs-			: LONGINT;
-				r_ds-			: LONGINT;
-				r_es-			: LONGINT;
-				r_fs-			: LONGINT;
-				r_gs-			: LONGINT;
+				r_faultvaddr-	: ADDRESS;
+				r_ax-			: ADDRESS;
+				r_bx-			: ADDRESS;
+				r_cx-			: ADDRESS;
+				r_dx-			: ADDRESS;
+				r_di-			: ADDRESS;
+				r_si-			: ADDRESS;
+				r_bp*			: ADDRESS;
+				r_sp*			: ADDRESS;
+				r_ss-			: ADDRESS;
+				r_flags-		: ADDRESS;
+				r_pc*			: ADDRESS;
+				r_cs-			: ADDRESS;
+				r_ds-			: ADDRESS;
+				r_es-			: ADDRESS;
+				r_fs-			: ADDRESS;
+				r_gs-			: ADDRESS;
 				
 				flavor-			: LONGINT;
 				count-		: LONGINT;
@@ -803,7 +803,7 @@ VAR
 	END CopyContext;
 
 
-	PROCEDURE ModifyContext*( cont: Mcontext;  pc, bp, sp: LONGINT );
+	PROCEDURE ModifyContext*( cont: Mcontext;  pc, bp, sp: ADDRESS );
 	BEGIN
 		cont.r_pc := pc;
 		cont.r_bp := bp;

+ 3 - 7
source/Generic.Unix.I386.Machine.Mod

@@ -81,8 +81,6 @@ VAR
 	fcr-: SET;	(** default floating-point control register value (default rounding mode is towards -infinity, for ENTIER) *)
 	mhz-: HUGEINT;	(** clock rate of GetTimer in MHz, or 0 if not known *)
 	
-	standaloneAppl-: BOOLEAN;
-	
 	gcThreshold-: SIZE;
 	memBlockHead-{UNTRACED}, memBlockTail-{UNTRACED}: MemoryBlock; (* head and tail of sorted list of memory blocks *)
 	
@@ -866,8 +864,7 @@ END GetTimer;
 			pid := pid DIV 10;		
 		UNTIL i = 3;
 		logfile := Unix.open( ADDRESSOF( logname ), Unix.rdwr + Unix.creat + Unix.trunc, Unix.rwrwr );
-		SilentLog;
-		VerboseLog;
+		VerboseLog;	
 	END InitLog;
 	
 	PROCEDURE SilentLog*;
@@ -893,10 +890,9 @@ END GetTimer;
 
 	PROCEDURE Init;
 	VAR vendor: Vendor; ver: LONGINT;
-	BEGIN
-		standaloneAppl := FALSE;
-		
+	BEGIN		
 		COPY( Unix.Version, version );  Append( version, Version ); Append(version, S.Date);
+		
 		timer0 := GetTimer( );  ticks := 0;
 		InitThreads;
 		InitLocks;

+ 3 - 0
source/Generic.Unix.Objects.Mod

@@ -44,6 +44,7 @@ VAR
 	timerStopped: BOOLEAN;
 	
 	(* processes *)
+	SystemA2Up- 	: BOOLEAN;
 	root-	: Process;	(*!  Anchor of all instantiated threads in system *)
 	stacksize: LONGINT;		(* stack size of active objects, adjustable via boot parameter *)
 	
@@ -792,6 +793,7 @@ TYPE
 		the signals SIGHUP, SIGINT and SIGQUIT don't branch into SignalHandler
 		but terminate A2 (at least in Solaris).		
 		*)
+		SystemA2Up := TRUE;
 		LOOP Sleep( 100 ) END
 	END GCLoop;		
 	
@@ -927,6 +929,7 @@ VAR
 	
 BEGIN
 	TraceProcessHook := NIL;
+	SystemA2Up := FALSE;
 	Init;
 END Objects.
 

+ 9 - 15
source/Generic.Unix.Traps.Mod

@@ -6,7 +6,7 @@ MODULE Traps;  (** AUTHOR "G.F."; PURPOSE "Exception Trap and symbolic debugging
 (* 2000.02.06	g.f.	UnixOberon release 2.3.6d	*)
 (* 2006.07.09	g.f.	UnixAos version	*)
 
-IMPORT S := SYSTEM, Trace, Unix, Objects, Machine, Streams, Modules, Reflection,
+IMPORT S := SYSTEM, Unix, Objects, Machine, Streams, Modules, Reflection,
 		TrapWriters, Commands, StdIO;
 
 CONST
@@ -113,6 +113,8 @@ VAR
 			(* ignore *) RETURN
 		END;
 		
+		IF ~Objects.SystemA2Up THEN  Machine.VerboseLog( )  END;
+		
 		LockTrap;
 		
 		INC( trapHandlingLevel );
@@ -187,23 +189,15 @@ VAR
 		UnlockTrap;
 
 		IF handler.pc # 0 THEN
-			IF Unix.Version # "Darwin" THEN
-				(* in the Darwin port Unix.ModifyContext fails with bus error. Stack alignment problem? *)
-				w.Ln;
-				w.String( "### program continues with exception handler ###" );   w.Ln;
+			w.Ln;
+			w.String( "### program continues with exception handler ###" );   w.Ln;
 
-				Unix.ModifyContext( mc, handler.pc, handler.fp, handler.sp );
-				RETURN  (*! to exception handler !! *)
-			END
+			Unix.ModifyContext( mc, handler.pc, handler.fp, handler.sp );
+			RETURN  (*! to exception handler !! *)
 		END;
 
-		IF Machine.standaloneAppl THEN
-			unix.error.Ln;  unix.error.Ln;
-			unix.error.String( "### Program aborted. Stack traceback in logfile" );  unix.error.Ln;
-			unix.error.Update;
-			Machine.Shutdown( FALSE )
-		ELSE
-			Objects.ExitTrap()
+		IF Objects.SystemA2Up THEN  Objects.ExitTrap( )
+		ELSE  Machine.Shutdown( FALSE )
 		END
 	END Trap;
 

+ 1 - 0
source/Unix.BootConsole.Mod

@@ -165,6 +165,7 @@ VAR
 	PROCEDURE StartSystem;
 	BEGIN
 		IF ~TryCommand()  THEN
+			Machine.VerboseLog( );
 			KernelLog.String( Machine.version );  KernelLog.Ln;
 			(* normal system start *)
 			LoadModule( "Clock" );