source: libcfa/src/bits/debug.hfa @ 6136ecc

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 6136ecc was 0a805f2, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Added second io printing group with less verbose prints.

  • Property mode set to 100644
File size: 6.3 KB
RevLine 
[78b3f52]1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
[73abe95]7// debug.hfa --
[78b3f52]8//
9// Author           : Thierry Delisle
10// Created On       : Mon Nov 28 12:27:26 2016
[851fd92]11// Last Modified By : Andrew Beach
12// Last Modified On : Mon Apr 27 10:15:00 2020
13// Update Count     : 10
[78b3f52]14//
15
[6b0b624]16#pragma once
[78b3f52]17
18#ifdef __CFA_DEBUG__
[36982fc]19        #define __cfaabi_dbg_debug_do(...) __VA_ARGS__
20        #define __cfaabi_dbg_no_debug_do(...)
21        #define __cfaabi_dbg_ctx __PRETTY_FUNCTION__
22        #define __cfaabi_dbg_ctx2 , __PRETTY_FUNCTION__
[e3fea42]23        #define __cfaabi_dbg_ctx_param const char caller[]
24        #define __cfaabi_dbg_ctx_param2 , const char caller[]
[ae66348]25        #define __cfaabi_dbg_ctx_fwd caller
26        #define __cfaabi_dbg_ctx_fwd2 , caller
[78b3f52]27#else
[36982fc]28        #define __cfaabi_dbg_debug_do(...)
29        #define __cfaabi_dbg_no_debug_do(...) __VA_ARGS__
30        #define __cfaabi_dbg_ctx
31        #define __cfaabi_dbg_ctx2
32        #define __cfaabi_dbg_ctx_param
33        #define __cfaabi_dbg_ctx_param2
[ae66348]34        #define __cfaabi_dbg_ctx_fwd
35        #define __cfaabi_dbg_ctx_fwd2
[4aa2fb2]36#endif
37
[9d944b2]38#ifdef __cforall
39extern "C" {
40#endif
[6a5be52]41        #include <stdarg.h>
[9d944b2]42
[e3fea42]43        extern void __cfaabi_bits_write( int fd, const char buffer[], int len );
[1c40091]44        extern void __cfaabi_bits_acquire();
45        extern void __cfaabi_bits_release();
46        extern void __cfaabi_bits_print_safe  ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) ));
47        extern void __cfaabi_bits_print_nolock( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) ));
48        extern void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list arg );
49        extern void __cfaabi_bits_print_buffer( int fd, char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) ));
[851fd92]50
51#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__) \
52                || defined(__CFA_DEBUG_PRINT_MONITOR__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__) \
53                || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__)
54        #include <stdio.h>
55        #include <unistd.h>
56#endif
[9d944b2]57#ifdef __cforall
58}
59#endif
60
[851fd92]61// Deprecated: Use the versions with the new module names.
[d9c44c3]62#ifdef __CFA_DEBUG_PRINT__
[1c40091]63        #define __cfaabi_dbg_write( buffer, len )         __cfaabi_bits_write( STDERR_FILENO, buffer, len )
64        #define __cfaabi_dbg_acquire()                    __cfaabi_bits_acquire()
65        #define __cfaabi_dbg_release()                    __cfaabi_bits_release()
[93ace83]66        #define __cfaabi_dbg_print_safe(...)              __cfaabi_bits_print_safe   ( STDERR_FILENO, __VA_ARGS__ )
67        #define __cfaabi_dbg_print_nolock(...)            __cfaabi_bits_print_nolock ( STDERR_FILENO, __VA_ARGS__ )
68        #define __cfaabi_dbg_print_buffer(...)            __cfaabi_bits_print_buffer ( STDERR_FILENO, __VA_ARGS__ )
69        #define __cfaabi_dbg_print_buffer_decl(...)       char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( STDERR_FILENO, __dbg_text, __dbg_len );
70        #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_write( STDERR_FILENO, __dbg_text, __dbg_len );
[d9c44c3]71#else
[36982fc]72        #define __cfaabi_dbg_write(...)               ((void)0)
73        #define __cfaabi_dbg_acquire()                ((void)0)
74        #define __cfaabi_dbg_release()                ((void)0)
75        #define __cfaabi_dbg_print_safe(...)          ((void)0)
76        #define __cfaabi_dbg_print_nolock(...)        ((void)0)
77        #define __cfaabi_dbg_print_buffer(...)        ((void)0)
78        #define __cfaabi_dbg_print_buffer_decl(...)   ((void)0)
79        #define __cfaabi_dbg_print_buffer_local(...)  ((void)0)
[d9c44c3]80#endif
81
[851fd92]82// Debug print functions and statements:
83// Most are wrappers around the bits printing function but are not always used.
84// If they are used depends if the group (first argument) is active or not. The group must be one
85// defined belowe. The other arguments depend on the wrapped function.
86#define __cfadbg_write(group, buffer, len) \
87        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_write(STDERR_FILENO, buffer, len))
88#define __cfadbg_acquire(group) \
89        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_acquire())
90#define __cfadbg_release(group) \
91        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_release())
92#define __cfadbg_print_safe(group, ...) \
93        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_safe(STDERR_FILENO, __VA_ARGS__))
94#define __cfadbg_print_nolock(group, ...) \
95        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_nolock(STDERR_FILENO, __VA_ARGS__))
96#define __cfadbg_print_buffer(group, ...) \
97        __CFADBG_PRINT_GROUP_##group(__cfaabi_bits_print_buffer(STDERR_FILENO, __VA_ARGS__))
98#define __cfadbg_print_buffer_decl(group, ...) \
99        __CFADBG_PRINT_GROUP_##group(char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( __dbg_text, __dbg_len ))
100#define __cfadbg_print_buffer_local(group, ...) \
101        __CFADBG_PRINT_GROUP_##group(__dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write(STDERR_FILENO, __dbg_text, __dbg_len))
102
103// The debug print groups:
104#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__)
105#       define __CFADBG_PRINT_GROUP_io(...) __VA_ARGS__
106#else
107#       define __CFADBG_PRINT_GROUP_io(...) ((void)0)
108#endif
[0a805f2]109#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_IO__) || defined(__CFA_DEBUG_PRINT_IO_CORE__)
110#       define __CFADBG_PRINT_GROUP_io_core(...) __VA_ARGS__
111#else
112#       define __CFADBG_PRINT_GROUP_io_core(...) ((void)0)
113#endif
[851fd92]114#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_MONITOR__)
115#       define __CFADBG_PRINT_GROUP_monitor(...) __VA_ARGS__
116#else
117#       define __CFADBG_PRINT_GROUP_monitor(...) ((void)0)
118#endif
119#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_PREEMPTION__)
120#       define __CFADBG_PRINT_GROUP_preemption(...) __VA_ARGS__
121#else
122#       define __CFADBG_PRINT_GROUP_preemption(...) ((void)0)
123#endif
124#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_RUNTIME_CORE__)
125#       define __CFADBG_PRINT_GROUP_runtime_core(...) __VA_ARGS__
126#else
127#       define __CFADBG_PRINT_GROUP_runtime_core(...) ((void)0)
128#endif
129#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_READY_QUEUE__)
130#       define __CFADBG_PRINT_GROUP_ready_queue(...) __VA_ARGS__
131#else
132#       define __CFADBG_PRINT_GROUP_ready_queue(...) ((void)0)
133#endif
134#if defined(__CFA_DEBUG_PRINT__) || defined(__CFA_DEBUG_PRINT_EXCEPTION__)
135#       define __CFADBG_PRINT_GROUP_exception(...) __VA_ARGS__
136#else
137#       define __CFADBG_PRINT_GROUP_exception(...) ((void)0)
138#endif
139
[78b3f52]140// Local Variables: //
141// mode: c //
142// tab-width: 4 //
143// End: //
Note: See TracBrowser for help on using the repository browser.