sighnd.inc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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);public name '_FPC_DEFAULTSIGHANDLER';cdecl;
  14. var
  15. res : word;
  16. addr, framebp : pointer;
  17. begin
  18. res:=0;
  19. addr:=nil;
  20. framebp:=nil;
  21. case sig of
  22. SIGFPE :
  23. begin
  24. if assigned(siginfo) then
  25. begin
  26. addr := siginfo^._sifields._sigfault._addr;
  27. case siginfo^.si_code of
  28. FPE_INTDIV:
  29. res:=200;
  30. FPE_INTOVF:
  31. res:=215;
  32. FPE_FLTDIV:
  33. res:=200;
  34. FPE_FLTOVF:
  35. res:=205;
  36. FPE_FLTUND:
  37. res:=206;
  38. else
  39. res:=207;
  40. end;
  41. end;
  42. end;
  43. SIGBUS :
  44. begin
  45. if assigned(siginfo) then
  46. addr := siginfo^._sifields._sigfault._addr;
  47. res:=214;
  48. end;
  49. SIGILL,
  50. SIGSEGV :
  51. begin
  52. if assigned(siginfo) then
  53. addr := siginfo^._sifields._sigfault._addr;
  54. res:=216;
  55. end;
  56. SIGINT:
  57. res:=217;
  58. SIGQUIT:
  59. res:=233;
  60. end;
  61. reenable_signal(sig);
  62. if assigned(sigcontext) then
  63. begin
  64. addr:=pointer(sigcontext^.sigc_pc);
  65. framebp:=pointer(sigcontext^.sigc_gregs[SIG_SP]);
  66. end;
  67. { give runtime error at the position where the signal was raised }
  68. if res<>0 then
  69. HandleErrorAddrFrame(res,addr,framebp);
  70. end;