sighnd.inc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. procedure SignalToRunerror(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
  14. var
  15. res : word;
  16. addr : pointer;
  17. frame : pointer;
  18. begin
  19. res:=0;
  20. addr:=nil;
  21. case sig of
  22. SIGFPE :
  23. begin
  24. addr := siginfo^._sifields._sigfault._addr;
  25. res := 207;
  26. case siginfo^.si_code of
  27. FPE_INTDIV:
  28. res:=200;
  29. FPE_INTOVF:
  30. res:=205;
  31. FPE_FLTDIV:
  32. res:=200;
  33. FPE_FLTOVF:
  34. res:=205;
  35. FPE_FLTUND:
  36. res:=206;
  37. FPE_FLTRES,
  38. FPE_FLTINV,
  39. FPE_FLTSUB:
  40. res:=216;
  41. else
  42. res:=207;
  43. end;
  44. end;
  45. SIGILL,
  46. SIGBUS,
  47. SIGSEGV :
  48. begin
  49. addr := siginfo^._sifields._sigfault._addr;
  50. res:=216;
  51. end;
  52. end;
  53. reenable_signal(sig);
  54. { give runtime error at the position where the signal was raised }
  55. if res<>0 then
  56. begin
  57. if assigned(SigContext) then
  58. begin
  59. frame:=pointer(ptruint(SigContext^.sigc_regs[29])); { stack pointer }
  60. addr:=pointer(ptruint(SigContext^.sigc_pc)); { program counter }
  61. end
  62. else
  63. begin
  64. frame:=nil;
  65. addr:=nil;
  66. end;
  67. HandleErrorAddrFrame(res,addr,frame);
  68. end;
  69. end;