HPCToolkit
messages.h
Go to the documentation of this file.
1 // -*-Mode: C++;-*- // technically C99
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // $HeadURL$
6 // $Id$
7 //
8 // --------------------------------------------------------------------------
9 // Part of HPCToolkit (hpctoolkit.org)
10 //
11 // Information about sources of support for research and development of
12 // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
13 // --------------------------------------------------------------------------
14 //
15 // Copyright ((c)) 2002-2019, Rice University
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are
20 // met:
21 //
22 // * Redistributions of source code must retain the above copyright
23 // notice, this list of conditions and the following disclaimer.
24 //
25 // * Redistributions in binary form must reproduce the above copyright
26 // notice, this list of conditions and the following disclaimer in the
27 // documentation and/or other materials provided with the distribution.
28 //
29 // * Neither the name of Rice University (RICE) nor the names of its
30 // contributors may be used to endorse or promote products derived from
31 // this software without specific prior written permission.
32 //
33 // This software is provided by RICE and contributors "as is" and any
34 // express or implied warranties, including, but not limited to, the
35 // implied warranties of merchantability and fitness for a particular
36 // purpose are disclaimed. In no event shall RICE or contributors be
37 // liable for any direct, indirect, incidental, special, exemplary, or
38 // consequential damages (including, but not limited to, procurement of
39 // substitute goods or services; loss of use, data, or profits; or
40 // business interruption) however caused and on any theory of liability,
41 // whether in contract, strict liability, or tort (including negligence
42 // or otherwise) arising in any way out of the use of this software, even
43 // if advised of the possibility of such damage.
44 //
45 // ******************************************************* EndRiceCopyright *
46 
47 #ifndef messages_h
48 #define messages_h
49 
50 //*****************************************************************************
51 // global includes
52 //*****************************************************************************
53 #include <stdarg.h>
54 #include <stdbool.h>
55 
56 
57 
58 //*****************************************************************************
59 // local includes
60 //*****************************************************************************
61 
62 #include <messages/debug-flag.h>
63 #include <messages/fmt.h>
64 
65 
66 //*****************************************************************************
67 // macros
68 //*****************************************************************************
69 
70 #define EMSG hpcrun_emsg
71 #define AMSG hpcrun_amsg
72 
73 #ifdef COMPILE_IN
74 #define CTMSG(...) TMSG(__VA_ARGS__)
75 #else
76 #define CTMSG(...)
77 #endif // COMPILE_IN
78 
79 #ifdef NO_HPCRUN_MSGS
80 #define STDERR_MSG(...)
81 #define EEMSG(...)
82 #define PMSG(f,...)
83 #define TMSG(f,...)
84 #define ETMSG(f,...)
85 #define NMSG(f,...)
86 #define ENMSG(f, ...)
87 #else // ! NO_HPCRUN_MSGS
88 
89 #define STDERR_MSG(...) hpcrun_stderr_log_msg(false,__VA_ARGS__)
90 #define EEMSG(...) hpcrun_stderr_log_msg(true,__VA_ARGS__)
91 
92 #define PMSG(f,...) hpcrun_pmsg(DBG_PREFIX(f), NULL, __VA_ARGS__)
93 #define TMSG(f,...) if (debug_flag_get(DBG_PREFIX(f))) hpcrun_pmsg(#f, __VA_ARGS__)
94 
95 #define ETMSG(f,...) hpcrun_pmsg_stderr(true,DBG_PREFIX(f), #f, __VA_ARGS__)
96 #define NMSG(f,...) if (debug_flag_get(DBG_PREFIX(f))) hpcrun_nmsg(DBG_PREFIX(f), #f, __VA_ARGS__)
97 #define ENMSG(f, ...) hpcrun_nmsg_stderr(true, DBG_PREFIX(f), #f, __VA_ARGS__)
98 #endif // NO_HPCRUN_MSGS
99 
100 #define EXIT_ON_ERROR(r,e,...) hpcrun_exit_on_error(r,e,__VA_ARGS__)
101 
102 #define hpcrun_abort(...) hpcrun_abort_w_info(messages_donothing, __VA_ARGS__)
103 
104 
105 
106 void messages_init();
107 void messages_fini(void);
108 
110 int messages_logfile_fd(void);
111 
112 void messages_donothing(void);
113 
114 void hpcrun_amsg(const char *fmt,...);
115 void hpcrun_emsg(const char *fmt,...);
116 void hpcrun_emsg_valist(const char *fmt, va_list_box* box);
117 void hpcrun_nmsg(pmsg_category flag, const char* tag, const char *fmt,...);
118 extern void hpcrun_pmsg(const char* tag, const char *fmt,...);
119 
120 void hpcrun_pmsg_stderr(bool echo_stderr,pmsg_category flag, const char* tag,
121  const char *fmt,...);
122 void hpcrun_nmsg_stderr(bool echo_stderr,pmsg_category flag, const char* tag,
123  const char *fmt,...);
124 void hpcrun_stderr_log_msg(bool copy_to_log, const char *fmt,...);
125 void hpcrun_exit_on_error(int ret, int ret_expected, const char *fmt,...);
126 
127 void hpcrun_abort_w_info(void (*info)(void),const char *fmt,...);
128 
130 void hpcrun_up_pmsg_count(void);
131 
132 void unlimit_msgs(void);
133 void limit_msgs(void);
134 
135 #endif // messages_h
void hpcrun_pmsg(const char *tag, const char *fmt,...)
void limit_msgs(void)
void messages_init()
void hpcrun_amsg(const char *fmt,...)
void hpcrun_exit_on_error(int ret, int ret_expected, const char *fmt,...)
pmsg_category
Definition: debug-flag.h:89
void hpcrun_abort_w_info(void(*info)(void), const char *fmt,...)
void hpcrun_emsg(const char *fmt,...)
int hpcrun_below_pmsg_threshold(void)
void hpcrun_pmsg_stderr(bool echo_stderr, pmsg_category flag, const char *tag, const char *fmt,...)
void unlimit_msgs(void)
void hpcrun_nmsg_stderr(bool echo_stderr, pmsg_category flag, const char *tag, const char *fmt,...)
void messages_fini(void)
void messages_logfile_create()
void hpcrun_nmsg(pmsg_category flag, const char *tag, const char *fmt,...)
void messages_donothing(void)
int messages_logfile_fd(void)
void hpcrun_emsg_valist(const char *fmt, va_list_box *box)
void hpcrun_stderr_log_msg(bool copy_to_log, const char *fmt,...)
void hpcrun_up_pmsg_count(void)