1 /*****************************************************************************\
2 ** pmix_debug.h - PMIx debug primitives
3 *****************************************************************************
4 * Copyright (C) 2014-2015 Artem Polyakov. All rights reserved.
5 * Copyright (C) 2015 Mellanox Technologies. All rights reserved.
6 * Written by Artem Polyakov <artpol84@gmail.com, artemp@mellanox.com>.
7 *
8 * This file is part of Slurm, a resource management program.
9 * For details, see <https://slurm.schedmd.com/>.
10 * Please also read the included file: DISCLAIMER.
11 *
12 * Slurm is free software; you can redistribute it and/or modify it under
13 * the terms of the GNU General Public License as published by the Free
14 * Software Foundation; either version 2 of the License, or (at your option)
15 * any later version.
16 *
17 * In addition, as a special exception, the copyright holders give permission
18 * to link the code of portions of this program with the OpenSSL library under
19 * certain conditions as described in each individual source file, and
20 * distribute linked combinations including the two. You must obey the GNU
21 * General Public License in all respects for all of the code used other than
22 * OpenSSL. If you modify file(s) with this exception, you may extend this
23 * exception to your version of the file(s), but you are not obligated to do
24 * so. If you do not wish to do so, delete this exception statement from your
25 * version. If you delete this exception statement from all source files in
26 * the program, then also delete it here.
27 *
28 * Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
29 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
30 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
31 * details.
32 *
33 * You should have received a copy of the GNU General Public License along
34 * with Slurm; if not, write to the Free Software Foundation, Inc.,
35 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
36 \*****************************************************************************/
37 #ifndef PMIXP_DEBUG_H
38 #define PMIXP_DEBUG_H
39
40 #include "pmixp_common.h"
41 #include "pmixp_info.h"
42
43 #define MAX_MSG_SIZE 1024
44
45 #define PMIXP_DEBUG(format, args...) { \
46 char file[] = __FILE__; \
47 char *file_base = strrchr(file, '/'); \
48 if (file_base == NULL) { \
49 file_base = file; \
50 } \
51 debug("%s [%d] %s:%d [%s] mpi/pmix: " format "", \
52 pmixp_info_hostname(), pmixp_info_nodeid(), \
53 file_base, __LINE__, __func__, ## args); \
54 }
55
56 #define PMIXP_ERROR_STD(format, args...) { \
57 char file[] = __FILE__; \
58 char *file_base = strrchr(file, '/'); \
59 if (file_base == NULL) { \
60 file_base = file; \
61 } \
62 error("%s [%d] %s:%d [%s] mpi/pmix: ERROR: " format ": %s (%d)", \
63 pmixp_info_hostname(), pmixp_info_nodeid(), \
64 file_base, __LINE__, __func__, \
65 ## args, strerror(errno), errno); \
66 }
67
68 #define PMIXP_ERROR(format, args...) { \
69 char file[] = __FILE__; \
70 char *file_base = strrchr(file, '/'); \
71 if (file_base == NULL) { \
72 file_base = file; \
73 } \
74 error("%s [%d] %s:%d [%s] mpi/pmix: ERROR: " format, \
75 pmixp_info_hostname(), pmixp_info_nodeid(), \
76 file_base, __LINE__, __func__, ## args); \
77 }
78
79 #define PMIXP_ABORT(format, args...) { \
80 PMIXP_ERROR(format, ##args); \
81 error("%s [%d] %s:%d [%s] mpi/pmix: ERROR: " format, \
82 pmixp_info_hostname(), pmixp_info_nodeid(), \
83 file_base, __LINE__, __func__, ## args); \
84 slurm_kill_job_step(pmixp_info_jobid(), \
85 pmixp_info_stepid(), SIGKILL); \
86 }
87
88 #define PMIXP_ERROR_NO(err, format, args...) { \
89 char file[] = __FILE__; \
90 char *file_base = strrchr(file, '/'); \
91 if (file_base == NULL) { \
92 file_base = file; \
93 } \
94 error("%s [%d] %s:%d [%s] mpi/pmix: ERROR: " format ": %s (%d)", \
95 pmixp_info_hostname(), pmixp_info_nodeid(), \
96 file_base, __LINE__, __func__, \
97 ## args, strerror(err), err); \
98 }
99
100 #ifdef NDEBUG
101 #define pmixp_debug_hang(x)
102 #else
_pmixp_debug_hang(int delay)103 static inline void _pmixp_debug_hang(int delay)
104 {
105 while (delay) {
106 sleep(1);
107 }
108 }
109
110 #define pmixp_debug_hang(x) _pmixp_debug_hang(x)
111
112 #endif
113 #endif /* PMIXP_DEBUG_H */
114