njn | 0c24647 | 2005-05-31 01:00:08 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- POSIX signals. pub_core_signals.h ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
sewardj | b3a1e4b | 2015-08-21 11:32:26 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2015 Julian Seward |
njn | 0c24647 | 2005-05-31 01:00:08 +0000 | [diff] [blame] | 11 | jseward@acm.org |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
| 31 | #ifndef __PUB_CORE_SIGNALS_H |
| 32 | #define __PUB_CORE_SIGNALS_H |
| 33 | |
| 34 | //-------------------------------------------------------------------- |
| 35 | // PURPOSE: This module implements all the signal handling stuff. |
| 36 | //-------------------------------------------------------------------- |
| 37 | |
njn | 73c5134 | 2005-06-18 15:18:15 +0000 | [diff] [blame] | 38 | #include "pub_tool_signals.h" // I want to get rid of this header... |
florian | 8a46fe8 | 2013-09-19 14:55:27 +0000 | [diff] [blame] | 39 | #include "pub_core_vki.h" // vki_sigset_t et al. |
njn | 73c5134 | 2005-06-18 15:18:15 +0000 | [diff] [blame] | 40 | |
njn | 0c24647 | 2005-05-31 01:00:08 +0000 | [diff] [blame] | 41 | /* Highest signal the kernel will let us use */ |
| 42 | extern Int VG_(max_signal); |
| 43 | |
philippe | 886fde3 | 2012-03-29 21:56:47 +0000 | [diff] [blame] | 44 | /* Returns the name of the vki signal sigNo */ |
florian | 2b8059a | 2012-10-14 16:45:23 +0000 | [diff] [blame] | 45 | extern const HChar *VG_(signame)(Int sigNo); |
philippe | 886fde3 | 2012-03-29 21:56:47 +0000 | [diff] [blame] | 46 | |
njn | 351d006 | 2005-06-21 22:23:59 +0000 | [diff] [blame] | 47 | /* Use high signals because native pthreads wants to use low */ |
| 48 | #define VG_SIGVGKILL (VG_(max_signal)-0) |
| 49 | #define VG_SIGVGRTUSERMAX (VG_(max_signal)-1) |
| 50 | |
njn | 0c24647 | 2005-05-31 01:00:08 +0000 | [diff] [blame] | 51 | extern void VG_(sigstartup_actions) ( void ); |
| 52 | |
sewardj | a8d8e23 | 2005-06-07 20:04:56 +0000 | [diff] [blame] | 53 | /* Poll a thread's set of pending signals, and update the Thread's |
| 54 | context to deliver one (viz, create signal frames if needed) */ |
njn | 0c24647 | 2005-05-31 01:00:08 +0000 | [diff] [blame] | 55 | extern void VG_(poll_signals) ( ThreadId ); |
| 56 | |
| 57 | /* Fake system calls for signal handling. */ |
sewardj | a8d8e23 | 2005-06-07 20:04:56 +0000 | [diff] [blame] | 58 | extern SysRes VG_(do_sys_sigaltstack) ( ThreadId tid, vki_stack_t* ss, |
| 59 | vki_stack_t* oss ); |
| 60 | extern SysRes VG_(do_sys_sigaction) ( Int signo, |
njn | cda2f0f | 2009-05-18 02:12:08 +0000 | [diff] [blame] | 61 | const vki_sigaction_toK_t* new_act, |
| 62 | vki_sigaction_fromK_t* old_act ); |
sewardj | a8d8e23 | 2005-06-07 20:04:56 +0000 | [diff] [blame] | 63 | extern SysRes VG_(do_sys_sigprocmask) ( ThreadId tid, Int how, |
| 64 | vki_sigset_t* set, |
| 65 | vki_sigset_t* oldset ); |
njn | 0c24647 | 2005-05-31 01:00:08 +0000 | [diff] [blame] | 66 | |
| 67 | extern void VG_(clear_out_queued_signals) |
| 68 | ( ThreadId tid, /* OUT */ vki_sigset_t* saved_mask ); |
| 69 | |
| 70 | extern void VG_(kill_self)(Int sigNo); |
| 71 | |
| 72 | /* These function synthesize a fault, as if the running instruction |
| 73 | had had a fault. These functions do not return - they longjmp back |
| 74 | into the scheduler so the signal can be delivered. */ |
| 75 | extern void VG_(synth_fault) (ThreadId tid); |
| 76 | extern void VG_(synth_fault_mapping)(ThreadId tid, Addr addr); |
| 77 | extern void VG_(synth_fault_perms) (ThreadId tid, Addr addr); |
| 78 | extern void VG_(synth_sigill) (ThreadId tid, Addr addr); |
sewardj | 86df155 | 2006-02-07 20:56:41 +0000 | [diff] [blame] | 79 | extern void VG_(synth_sigtrap) (ThreadId tid); |
sewardj | 1c0ce7a | 2009-07-01 08:10:49 +0000 | [diff] [blame] | 80 | extern void VG_(synth_sigbus) (ThreadId tid); |
petarj | 80e5c17 | 2012-10-19 14:45:17 +0000 | [diff] [blame] | 81 | extern void VG_(synth_sigfpe) (ThreadId tid, UInt code); |
njn | 0c24647 | 2005-05-31 01:00:08 +0000 | [diff] [blame] | 82 | |
| 83 | /* Extend the stack to cover addr, if possible */ |
florian | 15fa8a2 | 2015-03-03 14:56:17 +0000 | [diff] [blame] | 84 | extern Bool VG_(extend_stack)(ThreadId tid, Addr addr); |
njn | 0c24647 | 2005-05-31 01:00:08 +0000 | [diff] [blame] | 85 | |
njn | 0c24647 | 2005-05-31 01:00:08 +0000 | [diff] [blame] | 86 | /* Forces the client's signal handler to SIG_DFL - generally just |
| 87 | before using that signal to kill the process. */ |
| 88 | extern void VG_(set_default_handler)(Int sig); |
| 89 | |
| 90 | #endif // __PUB_CORE_SIGNALS_H |
| 91 | |
| 92 | /*--------------------------------------------------------------------*/ |
| 93 | /*--- end ---*/ |
| 94 | /*--------------------------------------------------------------------*/ |