+ Added support for ErrorProc variable. All internal functions are required

to call HandleError instead of runerror from now on.
  This is necessary for exception support.
This commit is contained in:
michael 1998-07-30 13:26:14 +00:00
parent f86a9ccb28
commit 4e11459938
8 changed files with 172 additions and 64 deletions

View File

@ -181,7 +181,7 @@ __short_on_stack:
popl %ebx popl %ebx
popl %eax popl %eax
end['EAX','EBX']; end['EAX','EBX'];
RunError(202); HandleError(202);
end; end;
@ -489,13 +489,13 @@ end;
procedure syscopytodos(addr : longint; len : longint); procedure syscopytodos(addr : longint; len : longint);
begin begin
if len > tb_size then runerror(217); if len > tb_size then HandleError(217);
sysseg_move(get_ds,addr,dos_selector,tb,len); sysseg_move(get_ds,addr,dos_selector,tb,len);
end; end;
procedure syscopyfromdos(addr : longint; len : longint); procedure syscopyfromdos(addr : longint; len : longint);
begin begin
if len > tb_size then runerror(217); if len > tb_size then HandleError(217);
sysseg_move(dos_selector,tb,get_ds,addr,len); sysseg_move(dos_selector,tb,get_ds,addr,len);
end; end;
@ -627,7 +627,7 @@ begin
AllowSlash(p1); AllowSlash(p1);
AllowSlash(p2); AllowSlash(p2);
if strlen(p1)+strlen(p2)+3>tb_size then if strlen(p1)+strlen(p2)+3>tb_size then
RunError(217); HandleError(217);
sysseg_move(get_ds,longint(p2),dos_selector,tb,strlen(p2)+1); sysseg_move(get_ds,longint(p2),dos_selector,tb,strlen(p2)+1);
sysseg_move(get_ds,longint(p1),dos_selector,tb+strlen(p2)+2,strlen(p1)+1); sysseg_move(get_ds,longint(p1),dos_selector,tb+strlen(p2)+2,strlen(p1)+1);
regs.realedi:=tb and 15; regs.realedi:=tb and 15;
@ -1057,7 +1057,12 @@ Begin
End. End.
{ {
$Log$ $Log$
Revision 1.12 1998-07-13 21:19:08 florian Revision 1.13 1998-07-30 13:26:22 michael
+ Added support for ErrorProc variable. All internal functions are required
to call HandleError instead of runerror from now on.
This is necessary for exception support.
Revision 1.12 1998/07/13 21:19:08 florian
* some problems with ansi string support fixed * some problems with ansi string support fixed
Revision 1.11 1998/07/07 12:33:08 carl Revision 1.11 1998/07/07 12:33:08 carl

View File

@ -192,7 +192,7 @@
if (pp^.sig<>$DEADBEEF) and (pp^.sig <> $AAAAAAAA) then if (pp^.sig<>$DEADBEEF) and (pp^.sig <> $AAAAAAAA) then
begin begin
writeln('error in linked list of heap_mem_info'); writeln('error in linked list of heap_mem_info');
runerror(204); HandleError(204);
end end
if pp=p then if pp=p then
@ -637,13 +637,13 @@
if assigned(heaperror) then if assigned(heaperror) then
begin begin
case call_heaperror(heaperror,size) of case call_heaperror(heaperror,size) of
0 : runerror(203); 0 : HandleError(203);
1 : p:=nil; 1 : p:=nil;
2 : nochmal:=true; 2 : nochmal:=true;
end; end;
end end
else else
runerror(203); HandleError(203);
end end
else else
begin begin
@ -701,7 +701,7 @@ check_new:
p:=p-sizeof(heap_mem_info); p:=p-sizeof(heap_mem_info);
{ made after heap_switch { made after heap_switch
if not (is_in_getmem_list(p)) then if not (is_in_getmem_list(p)) then
runerror(204); } HandleError(204); }
end; end;
{$endif CHECKHEAP} {$endif CHECKHEAP}
if size=0 then if size=0 then
@ -738,7 +738,7 @@ check_new:
begin begin
writeln('pointer ',hexstr(longint(@p),8),' at ', writeln('pointer ',hexstr(longint(@p),8),' at ',
hexstr(longint(p),8),' doesn''t points to the heap'); hexstr(longint(p),8),' doesn''t points to the heap');
runerror(204); HandleError(204);
end; end;
end; end;
{$endif TEMPHEAP} {$endif TEMPHEAP}
@ -746,7 +746,7 @@ check_new:
if trace then if trace then
begin begin
if not (is_in_getmem_list(p)) then if not (is_in_getmem_list(p)) then
runerror(204); HandleError(204);
if pheap_mem_info(p)^.sig=$AAAAAAAA then if pheap_mem_info(p)^.sig=$AAAAAAAA then
dump_free(p); dump_free(p);
if pheap_mem_info(p)^.next<>nil then if pheap_mem_info(p)^.next<>nil then
@ -823,7 +823,7 @@ check_new:
writeln('pointer to dispose at ',hexstr(longint(p),8), writeln('pointer to dispose at ',hexstr(longint(p),8),
' has already been disposed'); ' has already been disposed');
{$endif CHECKHEAP} {$endif CHECKHEAP}
runerror(204); HandleError(204);
end; end;
{ connecting two blocks ? } { connecting two blocks ? }
if hp+hp^.size=p then if hp+hp^.size=p then
@ -845,7 +845,7 @@ check_new:
writeln('pointer to dispose at ',hexstr(longint(p),8), writeln('pointer to dispose at ',hexstr(longint(p),8),
' is too big !!'); ' is too big !!');
{$endif CHECKHEAP} {$endif CHECKHEAP}
runerror(204); HandleError(204);
end; end;
break; break;
end end
@ -1062,7 +1062,12 @@ end;
{ {
$Log$ $Log$
Revision 1.13 1998-07-02 14:24:09 michael Revision 1.14 1998-07-30 13:26:21 michael
+ Added support for ErrorProc variable. All internal functions are required
to call HandleError instead of runerror from now on.
This is necessary for exception support.
Revision 1.13 1998/07/02 14:24:09 michael
Undid carls changes, but renamed _heapsize to _internal_heapsize. Make cycle now works Undid carls changes, but renamed _heapsize to _internal_heapsize. Make cycle now works
Revision 1.11 1998/06/25 09:26:10 daniel Revision 1.11 1998/06/25 09:26:10 daniel

View File

@ -272,8 +272,8 @@ asm
popl %edi popl %edi
ret $4 ret $4
.Lco_re: .Lco_re:
pushw $210 pushl $210
call runerror call handleerror
end; end;
@ -523,35 +523,54 @@ asm
end ['EAX']; end ['EAX'];
Procedure HandleError (Errno : longint);[alias : 'handleerror'];
{
Procedure to handle internal errors, i.e. not user-invoked errors
Internal function should ALWAYS call HandleError instead of RunError.
}
function get_addr : Pointer;assembler;
asm
movl (%ebp),%eax
movl 4(%eax),%eax
end;
function get_error_bp : Longint;assembler;
asm
movl (%ebp),%eax
end;
begin
If ErrorProc<>Nil then
TErrorProc (ErrorProc)(Errno,get_addr);
errorcode:=Errno;
exitcode:=Errno;
erroraddr:=Get_addr;
DoError := TRUE;
errorbase:=get_error_bp;
halt(errorcode);
end;
procedure runerror(w : word);[alias: 'runerror']; procedure runerror(w : word);[alias: 'runerror'];
function get_addr : longint; function get_addr : Pointer;assembler;
asm
movl (%ebp),%eax
movl 4(%eax),%eax
end;
begin function get_error_bp : Longint;assembler;
asm asm
movl (%ebp),%eax movl (%ebp),%eax {%ebp of run_error}
movl 4(%eax),%eax end;
movl %eax,__RESULT
end ['EAX'];
end;
function get_error_bp : longint; begin
errorcode:=w;
begin exitcode:=w;
asm erroraddr:=pointer(get_addr);
movl (%ebp),%eax {%ebp of run_error} DoError := TRUE;
movl %eax,__RESULT errorbase:=get_error_bp;
end ['EAX']; halt(errorcode);
end; end;
begin
errorcode:=w;
exitcode:=w;
erroraddr:=pointer(get_addr);
DoError := TRUE;
errorbase:=get_error_bp;
halt(errorcode);
end;
procedure int_iocheck(addr : longint);[public,alias: 'IOCHECK']; procedure int_iocheck(addr : longint);[public,alias: 'IOCHECK'];
var var
@ -565,12 +584,14 @@ begin
l:=ioresult; l:=ioresult;
if l<>0 then if l<>0 then
begin begin
If ErrorProc<>Nil then
TErrorProc(Errorproc)(l,pointer(addr));
{$ifndef RTLLITE} {$ifndef RTLLITE}
writeln('IO-Error ',l,' at 0x',HexStr(addr,8)); writeln('IO-Error ',l,' at 0x',HexStr(addr,8));
{$else} {$else}
writeln('IO-Error ',l,' at ',addr); writeln('IO-Error ',l,' at ',addr);
{$endif} {$endif}
halt(byte(l)); Halt(byte(l));
end; end;
asm asm
popal popal
@ -587,12 +608,14 @@ begin
movl 4(%ebp),%edi movl 4(%ebp),%edi
movl %edi,addr movl %edi,addr
end; end;
If ErrorProc<>Nil then
TErrorProc (ErrorProc)(215,Pointer(Addr));
{$ifndef RTLLITE} {$ifndef RTLLITE}
writeln('Overflow at 0x',HexStr(addr,8)); writeln('Overflow at 0x',HexStr(addr,8));
{$else} {$else}
writeln('Overflow at ',addr); writeln('Overflow at ',addr);
{$endif} {$endif}
RunError(215); HandleError(215);
end; end;
@ -728,7 +751,12 @@ end;
{ {
$Log$ $Log$
Revision 1.16 1998-07-02 12:55:04 carl Revision 1.17 1998-07-30 13:26:20 michael
+ Added support for ErrorProc variable. All internal functions are required
to call HandleError instead of runerror from now on.
This is necessary for exception support.
Revision 1.16 1998/07/02 12:55:04 carl
* Put back DoError, DO NOT TOUCH! * Put back DoError, DO NOT TOUCH!
Revision 1.15 1998/07/02 12:19:32 carl Revision 1.15 1998/07/02 12:19:32 carl

View File

@ -25,6 +25,8 @@
{$i filerec.inc} {$i filerec.inc}
{$i textrec.inc} {$i textrec.inc}
Procedure HandleError (Errno : Longint); forward;
type type
FileFunc = Procedure(var t : TextRec); FileFunc = Procedure(var t : TextRec);
@ -509,7 +511,7 @@ begin
write (stderr,msg); write (stderr,msg);
writeln (stderr,'(File : ',name,', line ',LineNo,'.'); writeln (stderr,'(File : ',name,', line ',LineNo,'.');
flush (stderr); flush (stderr);
runerror (227); HandleError (227);
end; end;
{***************************************************************************** {*****************************************************************************
@ -527,7 +529,12 @@ end;
{ {
$Log$ $Log$
Revision 1.24 1998-07-28 20:37:45 michael Revision 1.25 1998-07-30 13:26:18 michael
+ Added support for ErrorProc variable. All internal functions are required
to call HandleError instead of runerror from now on.
This is necessary for exception support.
Revision 1.24 1998/07/28 20:37:45 michael
+ added setjmp/longjmp and exception support + added setjmp/longjmp and exception support
Revision 1.23 1998/07/23 19:53:20 michael Revision 1.23 1998/07/23 19:53:20 michael

View File

@ -93,6 +93,8 @@ const
fmAppend = $D7B4; fmAppend = $D7B4;
Filemode : byte = 2; Filemode : byte = 2;
Type TErrorProc = Procedure (ErrNo : Longint; Address : Pointer);
var var
{ Standard In- and Output } { Standard In- and Output }
Output, Output,
@ -104,6 +106,9 @@ var
LowestStack, LowestStack,
RandSeed : Longint; RandSeed : Longint;
Const
ErrorProc : Pointer = nil;
{**************************************************************************** {****************************************************************************
Processor specific routines Processor specific routines
****************************************************************************} ****************************************************************************}
@ -405,7 +410,12 @@ Procedure halt;
{ {
$Log$ $Log$
Revision 1.20 1998-07-28 20:37:47 michael Revision 1.21 1998-07-30 13:26:17 michael
+ Added support for ErrorProc variable. All internal functions are required
to call HandleError instead of runerror from now on.
This is necessary for exception support.
Revision 1.20 1998/07/28 20:37:47 michael
+ added setjmp/longjmp and exception support + added setjmp/longjmp and exception support
Revision 1.19 1998/07/20 23:36:57 michael Revision 1.19 1998/07/20 23:36:57 michael

View File

@ -60,7 +60,7 @@ Begin
fmOutput : Flags:=$1101; fmOutput : Flags:=$1101;
fmAppend : Flags:=$1011; fmAppend : Flags:=$1011;
else else
RunError(102); HandleError(102);
End; End;
Do_Open(t,PChar(@t.Name),Flags); Do_Open(t,PChar(@t.Name),Flags);
t.CloseFunc:=@FileCloseFunc; t.CloseFunc:=@FileCloseFunc;
@ -957,7 +957,7 @@ Begin
ReadNumeric(f,hs,Base); ReadNumeric(f,hs,Base);
Val(hs,l,code); Val(hs,l,code);
If code<>0 Then If code<>0 Then
RunError(106); HandleError(106);
End; End;
@ -969,7 +969,7 @@ Begin
If InOutRes <> 0 then exit; If InOutRes <> 0 then exit;
Read_Longint(f,ll); Read_Longint(f,ll);
If (ll<-32768) or (ll>32767) Then If (ll<-32768) or (ll>32767) Then
RunError(106); HandleError(106);
l:=ll; l:=ll;
End; End;
@ -982,7 +982,7 @@ Begin
If InOutRes <> 0 then exit; If InOutRes <> 0 then exit;
Read_Longint(f,ll); Read_Longint(f,ll);
If (ll<0) or (ll>$ffff) Then If (ll<0) or (ll>$ffff) Then
RunError(106); HandleError(106);
l:=ll; l:=ll;
End; End;
@ -995,7 +995,7 @@ Begin
If InOutRes <> 0 then exit; If InOutRes <> 0 then exit;
Read_Longint(f,ll); Read_Longint(f,ll);
If (ll<0) or (ll>255) Then If (ll<0) or (ll>255) Then
RunError(106); HandleError(106);
l:=ll; l:=ll;
End; End;
@ -1008,7 +1008,7 @@ Begin
If InOutRes <> 0 then exit; If InOutRes <> 0 then exit;
Read_Longint(f,ll); Read_Longint(f,ll);
If (ll<-128) or (ll>127) Then If (ll<-128) or (ll>127) Then
RunError(106); HandleError(106);
l:=ll; l:=ll;
End; End;
@ -1028,7 +1028,7 @@ Begin
ReadNumeric(f,hs,Base); ReadNumeric(f,hs,Base);
val(hs,l,code); val(hs,l,code);
If code<>0 Then If code<>0 Then
RunError(106); HandleError(106);
End; End;
@ -1066,7 +1066,7 @@ Begin
end; end;
val(hs,d,code); val(hs,d,code);
If code<>0 Then If code<>0 Then
RunError(106); HandleError(106);
End; End;
@ -1105,7 +1105,7 @@ Begin
end; end;
val(hs,d,code); val(hs,d,code);
If code<>0 Then If code<>0 Then
RunError(106); HandleError(106);
End; End;
{$endif SUPPORT_EXTENDED} {$endif SUPPORT_EXTENDED}
@ -1145,7 +1145,7 @@ Begin
end; end;
val(hs,d,code); val(hs,d,code);
If code<>0 Then If code<>0 Then
RunError(106); HandleError(106);
End; End;
{$endif SUPPORT_COMP} {$endif SUPPORT_COMP}
@ -1185,14 +1185,19 @@ begin
TextRec(f).FlushFunc:=@FileWriteFunc; TextRec(f).FlushFunc:=@FileWriteFunc;
end; end;
else else
RunError(102); HandleError(102);
end; end;
end; end;
{ {
$Log$ $Log$
Revision 1.18 1998-07-29 21:44:35 michael Revision 1.19 1998-07-30 13:26:16 michael
+ Added support for ErrorProc variable. All internal functions are required
to call HandleError instead of runerror from now on.
This is necessary for exception support.
Revision 1.18 1998/07/29 21:44:35 michael
+ Implemented reading/writing of ansistrings + Implemented reading/writing of ansistrings
Revision 1.17 1998/07/19 19:55:33 michael Revision 1.17 1998/07/19 19:55:33 michael

View File

@ -646,7 +646,7 @@ end;
Procedure SegFaultHandler (Sig : longint); Procedure SegFaultHandler (Sig : longint);
begin begin
if sig=11 then if sig=11 then
RunError (216); HandleError (216);
end; end;
@ -675,7 +675,12 @@ End.
{ {
$Log$ $Log$
Revision 1.9 1998-07-20 23:40:20 michael Revision 1.10 1998-07-30 13:26:15 michael
+ Added support for ErrorProc variable. All internal functions are required
to call HandleError instead of runerror from now on.
This is necessary for exception support.
Revision 1.9 1998/07/20 23:40:20 michael
changed sbrk to fc_sbrk, to avoid conflicts with C library. changed sbrk to fc_sbrk, to avoid conflicts with C library.
Revision 1.8 1998/07/13 21:19:14 florian Revision 1.8 1998/07/13 21:19:14 florian

View File

@ -52,10 +52,12 @@
asm asm
move.b d0,b move.b d0,b
end; end;
RunError(b); HandleError(b);
end; end;
Procedure FillChar(var x; count: longint; value: byte); Procedure FillChar(var x; count: longint; value: byte);
begin begin
asm asm
@ -332,6 +334,42 @@
end ['a0']; end ['a0'];
end; end;
Procedure HandleError (Errno : longint);[alias : 'handleerror'];
{
Procedure to handle internal errors, i.e. not user-invoked errors
Internal function should ALWAYS call HandleError instead of RunError.
}
function get_addr : pointer;
begin
asm
move.l (a6),a0
move.l 4(a0),a0
move.l a0,@RESULT
end ['a0'];
end;
function get_error_bp : longint;
begin
asm
{ get base pointer of error }
move.l (a6),d0
move.l d0,@RESULT
end ['d0'];
end;
begin
If ErrorProc<>Nil then
TErrorProc (ErrorProc)(Errno,get_addr);
errorcode:=Errno;
exitcode:=Errno;
erroraddr:=Get_addr;
DoError := TRUE;
errorbase:=get_error_bp;
halt(errorcode);
end;
procedure runerror(w : word); procedure runerror(w : word);
function get_addr : longint; function get_addr : longint;
@ -398,7 +436,7 @@
move.l d0,addr move.l d0,addr
end; end;
writeln('Overflow at 0x',HexStr(addr,8)); writeln('Overflow at 0x',HexStr(addr,8));
RunError(215); HandleError(215);
end; end;
{ procedure strcopy(dstr,sstr : pointer;len : longint);[public,alias: 'STRCOPY'];} { procedure strcopy(dstr,sstr : pointer;len : longint);[public,alias: 'STRCOPY'];}
@ -748,7 +786,12 @@ XDEF RE_BOUNDS_CHECK
{ {
$Log$ $Log$
Revision 1.8 1998-07-10 11:02:41 peter Revision 1.9 1998-07-30 13:26:14 michael
+ Added support for ErrorProc variable. All internal functions are required
to call HandleError instead of runerror from now on.
This is necessary for exception support.
Revision 1.8 1998/07/10 11:02:41 peter
* support_fixed, becuase fixed is not 100% yet for the m68k * support_fixed, becuase fixed is not 100% yet for the m68k
Revision 1.7 1998/07/02 12:20:58 carl Revision 1.7 1998/07/02 12:20:58 carl