replace: Add check for variable program_invocation_short_name
[bbaumbach/samba-autobuild/.git] / lib / util / fault.h
1 /*
2    Unix SMB/CIFS implementation.
3    Critical Fault handling
4    Copyright (C) Andrew Tridgell 1992-1998
5    Copyright (C) Tim Prouty 2009
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef _SAMBA_FAULT_H_
22 #define _SAMBA_FAULT_H_
23
24 #include <sys/types.h>
25
26 #include "attr.h"
27
28 /* Please include header file debug.h if you want to use macro SMB_ASSERT */
29
30 /**
31  * assert macros
32  */
33 #ifdef _SAMBA_DEBUG_H
34 #define SMB_ASSERT(b) \
35 do { \
36         if (!(b)) { \
37                 DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \
38                          __FILE__, __LINE__, #b)); \
39                 smb_panic("assert failed: " #b); \
40         } \
41 } while(0)
42 #endif /* _SAMBA_DEBUG_H */
43
44 extern const char *panic_action;
45
46 /**
47  Something really nasty happened - panic !
48 **/
49 typedef void (*smb_panic_handler_t)(const char *why);
50
51 void fault_configure(smb_panic_handler_t panic_handler);
52 void fault_setup(void);
53 void fault_setup_disable(void);
54 _NORETURN_ void smb_panic(const char *reason);
55
56 void log_stack_trace(void);
57
58 #endif /* _SAMBA_FAULT_H_ */