1 /* 2 * Copyright (c) 2023 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef NSI_COMMON_SRC_INCL_NSI_TRACING_H 8 #define NSI_COMMON_SRC_INCL_NSI_TRACING_H 9 10 #include <stdarg.h> 11 #include "nsi_utils.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /* 18 * Native simulator tracing API: 19 * Print a message/warning/error to the tracing backend 20 * and in case of nsi_print_error_and_exit() also call nsi_exit() 21 * 22 * All print()/vprint() APIs take the same arguments as printf()/vprintf(). 23 */ 24 25 NSI_FUNC_NORETURN void nsi_print_error_and_exit(const char *format, ...); 26 void nsi_print_warning(const char *format, ...); 27 void nsi_print_trace(const char *format, ...); 28 NSI_FUNC_NORETURN void nsi_vprint_error_and_exit(const char *format, va_list vargs); 29 void nsi_vprint_warning(const char *format, va_list vargs); 30 void nsi_vprint_trace(const char *format, va_list vargs); 31 32 /* 33 * @brief Is the tracing backend connected to a ptty/terminal or not 34 * 35 * @param nbr: Which output. Options are: 0 trace output, 1: warning and error output 36 * 37 * @return 38 * 0 : Not a ptty (i.e. probably a pipe to another program) 39 * 1 : Connected to a ptty (for ex. stdout/err to the invoking terminal) 40 * -1: Unknown at this point 41 */ 42 int nsi_trace_over_tty(int nbr); 43 44 #ifdef __cplusplus 45 } 46 #endif 47 48 #endif /* NSI_COMMON_SRC_INCL_NSI_TRACING_H */ 49