sighnd.inc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Michael Van Canneyt,
  4. member of the Free Pascal development team.
  5. Signal handler is arch dependant due to processor to language
  6. exception conversion.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. { $define SYSTEM_DEBUG}
  14. procedure SignalToRunerror(Sig: longint; SigInfo: PSigInfo; UContext: PUContext); public name '_FPC_DEFAULTSIGHANDLER'; cdecl;
  15. var
  16. res : word;
  17. begin
  18. res:=0;
  19. case sig of
  20. SIGFPE:
  21. begin
  22. res:=207;
  23. {$ifdef SYSTEM_DEBUG}
  24. writeln('magic of FPSIMD_Context: $',hexstr(uContext^.uc_mcontext.FPSIMD_Context.head.magic,8));
  25. writeln('size of FPSIMD_Context: $',hexstr(uContext^.uc_mcontext.FPSIMD_Context.head.size,8));
  26. {$endif SYSTEM_DEBUG}
  27. if (uContext^.uc_mcontext.FPSIMD_Context.head.magic=$46508001) and
  28. (uContext^.uc_mcontext.FPSIMD_Context.head.size=$210) then
  29. begin
  30. with uContext^.uc_mcontext.FPSIMD_Context do
  31. fpsr:=fpsr and not(fpu_exception_mask shr fpu_exception_mask_to_status_mask_shift);
  32. end;
  33. end;
  34. SIGILL:
  35. res:=216;
  36. SIGSEGV :
  37. res:=216;
  38. SIGBUS:
  39. res:=214;
  40. SIGINT:
  41. res:=217;
  42. SIGQUIT:
  43. res:=233;
  44. end;
  45. reenable_signal(sig);
  46. { give runtime error at the position where the signal was raised }
  47. if res<>0 then
  48. begin
  49. uContext^.uc_mcontext.regs[0]:=res;
  50. uContext^.uc_mcontext.regs[1]:=uContext^.uc_mcontext.pc;
  51. uContext^.uc_mcontext.regs[2]:=uContext^.uc_mcontext.regs[29];
  52. pointer(uContext^.uc_mcontext.pc):=@HandleErrorAddrFrame;
  53. end;
  54. end;