2014-03-03 11:09:26 -08:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* \section COPYRIGHT
|
|
|
|
*
|
2015-11-13 04:22:33 -08:00
|
|
|
* Copyright 2013-2015 Software Radio Systems Limited
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
|
|
|
* \section LICENSE
|
|
|
|
*
|
2015-03-18 05:31:13 -07:00
|
|
|
* This file is part of the srsLTE library.
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
2015-03-18 05:31:13 -07:00
|
|
|
* srsLTE is free software: you can redistribute it and/or modify
|
2015-05-08 08:05:40 -07:00
|
|
|
* it under the terms of the GNU Affero General Public License as
|
2014-03-03 11:09:26 -08:00
|
|
|
* published by the Free Software Foundation, either version 3 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
2015-03-18 05:31:13 -07:00
|
|
|
* srsLTE is distributed in the hope that it will be useful,
|
2014-03-03 11:09:26 -08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-05-08 08:05:40 -07:00
|
|
|
* GNU Affero General Public License for more details.
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
2015-05-08 08:05:40 -07:00
|
|
|
* A copy of the GNU Affero General Public License can be found in
|
2014-03-03 11:09:26 -08:00
|
|
|
* the LICENSE file in the top-level directory of this distribution
|
|
|
|
* and at http://www.gnu.org/licenses/.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-04-03 05:49:12 -07:00
|
|
|
/******************************************************************************
|
|
|
|
* File: debug.h
|
|
|
|
*
|
|
|
|
* Description: Debug output utilities.
|
|
|
|
*
|
|
|
|
* Reference:
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
#ifndef DEBUG_H
|
|
|
|
#define DEBUG_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2015-03-18 05:16:28 -07:00
|
|
|
#include "srslte/config.h"
|
2017-12-18 11:04:47 -08:00
|
|
|
#include "srslte/srslte.h"
|
2015-09-21 04:51:28 -07:00
|
|
|
#define SRSLTE_VERBOSE_DEBUG 2
|
2015-03-18 11:14:24 -07:00
|
|
|
#define SRSLTE_VERBOSE_INFO 1
|
|
|
|
#define SRSLTE_VERBOSE_NONE 0
|
2014-03-03 11:09:26 -08:00
|
|
|
|
|
|
|
#include <sys/time.h>
|
2015-03-18 05:31:13 -07:00
|
|
|
SRSLTE_API void get_time_interval(struct timeval * tdata);
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2015-09-22 13:20:36 -07:00
|
|
|
#define SRSLTE_DEBUG_ENABLED 1
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
SRSLTE_API extern int srslte_verbose;
|
2017-12-18 11:04:47 -08:00
|
|
|
SRSLTE_API extern int srslte_is_example;
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
#define SRSLTE_VERBOSE_ISINFO() (srslte_verbose>=SRSLTE_VERBOSE_INFO)
|
|
|
|
#define SRSLTE_VERBOSE_ISDEBUG() (srslte_verbose>=SRSLTE_VERBOSE_DEBUG)
|
|
|
|
#define SRSLTE_VERBOSE_ISNONE() (srslte_verbose==SRSLTE_VERBOSE_NONE)
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
#define PRINT_DEBUG srslte_verbose=SRSLTE_VERBOSE_DEBUG
|
|
|
|
#define PRINT_INFO srslte_verbose=SRSLTE_VERBOSE_INFO
|
|
|
|
#define PRINT_NONE srslte_verbose=SRSLTE_VERBOSE_NONE
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2017-12-18 11:04:47 -08:00
|
|
|
#define DEBUG(_fmt, ...) if (SRSLTE_DEBUG_ENABLED && srslte_verbose >= SRSLTE_VERBOSE_DEBUG && srslte_is_example)\
|
|
|
|
{ fprintf(stdout, "[DEBUG]: " _fmt, ##__VA_ARGS__); }\
|
|
|
|
else{ srslte_phy_log_print(LOG_LEVEL_DEBUG, _fmt, ##__VA_ARGS__); }
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2017-12-18 11:04:47 -08:00
|
|
|
#define INFO(_fmt, ...) if (SRSLTE_DEBUG_ENABLED && ((srslte_verbose >= SRSLTE_VERBOSE_INFO)) && srslte_is_example)\
|
|
|
|
{ fprintf(stdout, "[INFO]: " _fmt, ##__VA_ARGS__); }\
|
|
|
|
else{ srslte_phy_log_print(LOG_LEVEL_INFO, _fmt, ##__VA_ARGS__); }
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2017-08-17 01:23:03 -07:00
|
|
|
#if CMAKE_BUILD_TYPE==Debug
|
|
|
|
/* In debug mode, it prints out the */
|
2017-12-18 11:04:47 -08:00
|
|
|
#define ERROR(_fmt, ...) if (srslte_is_example)\
|
|
|
|
{ fprintf(stderr, "\e[31m%s.%d: " _fmt "\e[0m\n", __FILE__, __LINE__, ##__VA_ARGS__);}\
|
|
|
|
else {srslte_phy_log_print(LOG_LEVEL_ERROR, _fmt, ##__VA_ARGS__);} //
|
2017-08-17 01:23:03 -07:00
|
|
|
#else
|
2017-12-18 11:04:47 -08:00
|
|
|
#define ERROR(_fmt, ...) if (srslte_is_example)\
|
|
|
|
{ fprintf(stderr, "[ERROR in %s]:" _fmt "\n", __FUNCTION__, ##__VA_ARGS__);}\
|
|
|
|
else{srslte_phy_log_print(LOG_LEVEL_ERROR, _fmt, ##__VA_ARGS__);} //
|
2017-08-17 01:23:03 -07:00
|
|
|
#endif /* CMAKE_BUILD_TYPE==Debug */
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2017-11-22 07:00:07 -08:00
|
|
|
void srslte_debug_handle_crash(int argc, char **argv);
|
|
|
|
|
2014-06-13 04:42:29 -07:00
|
|
|
#endif // DEBUG_H
|