2 /*--------------------------------------------------------------------*/
3 /*--- POSIX signals. pub_core_signals.h ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2000-2017 Julian Seward
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.
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.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #ifndef __PUB_CORE_SIGNALS_H
30 #define __PUB_CORE_SIGNALS_H
32 //--------------------------------------------------------------------
33 // PURPOSE: This module implements all the signal handling stuff.
34 //--------------------------------------------------------------------
36 #include "pub_tool_signals.h" // I want to get rid of this header...
37 #include "pub_core_vki.h" // vki_sigset_t et al.
39 /* Highest signal the kernel will let us use */
40 extern Int
VG_(max_signal
);
42 /* Returns the name of the vki signal sigNo */
43 extern const HChar
*VG_(signame
)(Int sigNo
);
45 /* Use high signals because native pthreads wants to use low */
46 #define VG_SIGVGKILL (VG_(max_signal)-0)
47 #define VG_SIGVGRTUSERMAX (VG_(max_signal)-1)
49 extern void VG_(sigstartup_actions
) ( void );
51 /* Poll a thread's set of pending signals, and update the Thread's
52 context to deliver one (viz, create signal frames if needed) */
53 extern void VG_(poll_signals
) ( ThreadId
);
55 /* Fake system calls for signal handling. */
56 extern SysRes
VG_(do_sys_sigaltstack
) ( ThreadId tid
, vki_stack_t
* ss
,
58 extern SysRes
VG_(do_sys_sigaction
) ( Int signo
,
59 const vki_sigaction_toK_t
* new_act
,
60 vki_sigaction_fromK_t
* old_act
);
61 extern SysRes
VG_(do_sys_sigprocmask
) ( ThreadId tid
, Int how
,
63 vki_sigset_t
* oldset
);
65 extern void VG_(clear_out_queued_signals
)
66 ( ThreadId tid
, /* OUT */ vki_sigset_t
* saved_mask
);
68 extern void VG_(kill_self
)(Int sigNo
);
70 /* These function synthesize a fault, as if the running instruction
71 had had a fault. These functions do not return - they longjmp back
72 into the scheduler so the signal can be delivered. */
73 extern void VG_(synth_fault
) (ThreadId tid
);
74 extern void VG_(synth_fault_mapping
)(ThreadId tid
, Addr addr
);
75 extern void VG_(synth_fault_perms
) (ThreadId tid
, Addr addr
);
76 extern void VG_(synth_sigill
) (ThreadId tid
, Addr addr
);
77 extern void VG_(synth_sigtrap
) (ThreadId tid
);
78 extern void VG_(synth_sigbus
) (ThreadId tid
);
79 extern void VG_(synth_sigfpe
) (ThreadId tid
, UInt code
);
81 /* Extend the stack to cover addr, if possible */
82 extern Bool
VG_(extend_stack
)(ThreadId tid
, Addr addr
);
84 /* Forces the client's signal handler to SIG_DFL - generally just
85 before using that signal to kill the process. */
86 extern void VG_(set_default_handler
)(Int sig
);
88 #endif // __PUB_CORE_SIGNALS_H
90 /*--------------------------------------------------------------------*/
92 /*--------------------------------------------------------------------*/