Selaa lähdekoodia

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 vuotta sitten
vanhempi
commit
dc10d00f8c

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

@@ -353,23 +353,23 @@ TYPE
 	McontextDesc* = RECORD
 	McontextDesc* = RECORD
 				r_trapno-		: LONGINT;
 				r_trapno-		: LONGINT;
 				r_err-			: 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;
 				flavor-			: LONGINT;
 				count-		: LONGINT;
 				count-		: LONGINT;
@@ -803,7 +803,7 @@ VAR
 	END CopyContext;
 	END CopyContext;
 
 
 
 
-	PROCEDURE ModifyContext*( cont: Mcontext;  pc, bp, sp: LONGINT );
+	PROCEDURE ModifyContext*( cont: Mcontext;  pc, bp, sp: ADDRESS );
 	BEGIN
 	BEGIN
 		cont.r_pc := pc;
 		cont.r_pc := pc;
 		cont.r_bp := bp;
 		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) *)
 	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 *)
 	mhz-: HUGEINT;	(** clock rate of GetTimer in MHz, or 0 if not known *)
 	
 	
-	standaloneAppl-: BOOLEAN;
-	
 	gcThreshold-: SIZE;
 	gcThreshold-: SIZE;
 	memBlockHead-{UNTRACED}, memBlockTail-{UNTRACED}: MemoryBlock; (* head and tail of sorted list of memory blocks *)
 	memBlockHead-{UNTRACED}, memBlockTail-{UNTRACED}: MemoryBlock; (* head and tail of sorted list of memory blocks *)
 	
 	
@@ -866,8 +864,7 @@ END GetTimer;
 			pid := pid DIV 10;		
 			pid := pid DIV 10;		
 		UNTIL i = 3;
 		UNTIL i = 3;
 		logfile := Unix.open( ADDRESSOF( logname ), Unix.rdwr + Unix.creat + Unix.trunc, Unix.rwrwr );
 		logfile := Unix.open( ADDRESSOF( logname ), Unix.rdwr + Unix.creat + Unix.trunc, Unix.rwrwr );
-		SilentLog;
-		VerboseLog;
+		VerboseLog;	
 	END InitLog;
 	END InitLog;
 	
 	
 	PROCEDURE SilentLog*;
 	PROCEDURE SilentLog*;
@@ -893,10 +890,9 @@ END GetTimer;
 
 
 	PROCEDURE Init;
 	PROCEDURE Init;
 	VAR vendor: Vendor; ver: LONGINT;
 	VAR vendor: Vendor; ver: LONGINT;
-	BEGIN
-		standaloneAppl := FALSE;
-		
+	BEGIN		
 		COPY( Unix.Version, version );  Append( version, Version ); Append(version, S.Date);
 		COPY( Unix.Version, version );  Append( version, Version ); Append(version, S.Date);
+		
 		timer0 := GetTimer( );  ticks := 0;
 		timer0 := GetTimer( );  ticks := 0;
 		InitThreads;
 		InitThreads;
 		InitLocks;
 		InitLocks;

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

@@ -44,6 +44,7 @@ VAR
 	timerStopped: BOOLEAN;
 	timerStopped: BOOLEAN;
 	
 	
 	(* processes *)
 	(* processes *)
+	SystemA2Up- 	: BOOLEAN;
 	root-	: Process;	(*!  Anchor of all instantiated threads in system *)
 	root-	: Process;	(*!  Anchor of all instantiated threads in system *)
 	stacksize: LONGINT;		(* stack size of active objects, adjustable via boot parameter *)
 	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
 		the signals SIGHUP, SIGINT and SIGQUIT don't branch into SignalHandler
 		but terminate A2 (at least in Solaris).		
 		but terminate A2 (at least in Solaris).		
 		*)
 		*)
+		SystemA2Up := TRUE;
 		LOOP Sleep( 100 ) END
 		LOOP Sleep( 100 ) END
 	END GCLoop;		
 	END GCLoop;		
 	
 	
@@ -927,6 +929,7 @@ VAR
 	
 	
 BEGIN
 BEGIN
 	TraceProcessHook := NIL;
 	TraceProcessHook := NIL;
+	SystemA2Up := FALSE;
 	Init;
 	Init;
 END Objects.
 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	*)
 (* 2000.02.06	g.f.	UnixOberon release 2.3.6d	*)
 (* 2006.07.09	g.f.	UnixAos version	*)
 (* 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;
 		TrapWriters, Commands, StdIO;
 
 
 CONST
 CONST
@@ -113,6 +113,8 @@ VAR
 			(* ignore *) RETURN
 			(* ignore *) RETURN
 		END;
 		END;
 		
 		
+		IF ~Objects.SystemA2Up THEN  Machine.VerboseLog( )  END;
+		
 		LockTrap;
 		LockTrap;
 		
 		
 		INC( trapHandlingLevel );
 		INC( trapHandlingLevel );
@@ -187,23 +189,15 @@ VAR
 		UnlockTrap;
 		UnlockTrap;
 
 
 		IF handler.pc # 0 THEN
 		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;
 		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
 	END Trap;
 	END Trap;
 
 

+ 1 - 0
source/Unix.BootConsole.Mod

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