From 31f9dff9385545170e2ee046c7af65bc941e26fd Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 1 Aug 2023 13:46:54 +0200 Subject: [PATCH] Fix regression for tracing asn1c enc/dec tracing As described in common/utils/config.h, it is possible to hook into the asn1c tracing mechanism to print logs. This commit fixes a regression to print theses traces properly in OAI. Above-mentioned file explains also how to reduce the amount of logs, e.g., for single code blocks. --- CMakeLists.txt | 13 +++++-------- cmake_targets/build_oai | 6 ++++++ common/utils/config.h | 11 +++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa9f0c4685..d689930203 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,8 +256,11 @@ add_definitions("-DPACKAGE_BUGREPORT=\"openair4g-devel@lists.eurecom.fr\"") # Debug related options ######################################### -add_boolean_option(DEBUG_ASN1 False "ASN1 coder/decoder Debug" OFF) -#add_boolean_option(DEBUG_MAC_INTERFACE False "print MAC-RLC PDU exchange to stdout") # if true, make sure that global and PDCP log levels are trace, not found in code, commented out, to be removed +add_boolean_option(DEBUG_ASN1 False "Enable ASN1 debug logs" OFF) +# asn1c skeletons have hardcoded this flag to make customized debug logs +# OAI uses this feature to re-use OAI LOG_I(ASN1, ...) +# see common/utils/config.h +add_boolean_option(TRACE_ASN1C_ENC_DEC OFF "Enable ASN1 encoder/decoder debug traces via OAI logging system" ON) add_boolean_option(T_TRACER True "Activate the T tracer, a debugging/monitoring framework" ON) add_boolean_option(UE_AUTOTEST_TRACE False "Activate UE autotest specific logs" ON) add_boolean_option(UE_DEBUG_TRACE False "Activate UE debug trace" ON) @@ -267,12 +270,6 @@ set (OCP_ITTI ${OPENAIR_DIR}/common/utils/ocp_itti) add_library(ITTI ${OCP_ITTI}/intertask_interface.cpp) target_link_libraries(ITTI PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs) -# asn1c skeletons have hardcoded this flag to make customized debug logs -# OAI uses this feature to re-use OAI LOG_I(ASN1, ...) -if (DEBUG_ASN1C) - add_definitions(-DHAVE_CONFIG_H) -endif() - # asn1c skeletons need this add_definitions(-DHAVE_NETINET_IN_H) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index cb66d4f862..a9241bf3b3 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -120,6 +120,8 @@ Options: Builds Coverity-Scan objects for upload --disable-deadline Disables deadline scheduler of Linux kernel (>=3.14.x). +--trace-asn1c-enc-dec + Output asn1c logging traces via OAI logging system. --enable-deadline Enable deadline scheduler of Linux kernel (>=3.14.x). --disable-cpu-affinity @@ -416,6 +418,10 @@ function main() { sleep 2 CMAKE_CMD="$CMAKE_CMD -DSANITIZE_MEMORY=ON -DSANITIZE_ADDRESS=OFF -DSANITIZE_UNDEFINED=OFF" shift;; + --trace-asn1c-enc-dec) + CMAKE_CMD="$CMAKE_CMD -DTRACE_ASN1C_ENC_DEC=ON" + echo_info "Enabling asn1c internal traces via OAI logging system" + shift 1;; -h | --help) print_help exit 1;; diff --git a/common/utils/config.h b/common/utils/config.h index 6d15a309c9..91aabe1347 100644 --- a/common/utils/config.h +++ b/common/utils/config.h @@ -22,12 +22,15 @@ #ifndef UTILS_CONFIG_H_ASN1 #define UTILS_CONFIG_H_ASN1 -// This is hard coded file name "config.h" and HAVE_CONFIG_H_ in asn1c skeletons +// This is hard coded file name "config.h" in asn1c skeletons /* * This file "config.h" will be used by asn1c if HAVE_CONFIG_H_ is defined and - * included. This logs asn1c encoder and decoder traces at execution time using - * the regular OAI logging system, i.e., LOG_I(ASN1...); + * included (this is the case for OAI). + * This allows to trace the asn1c encoder and decoder at execution time using + * the regular OAI logging system, i.e., LOG_I(ASN1, ...); + * + * to enable it, at compilation time, see ./build_oai --enable-asn1c-debug * * As it is very verbose, note that you can change the log level per module in * source or in gdb, e.g., to only activate it for a short time. @@ -47,7 +50,7 @@ */ #include "common/utils/LOG/log.h" -#if DEBUG_ASN1C +#if TRACE_ASN1C_ENC_DEC #define ASN_DEBUG(x...) do{ LOG_I(ASN1,x);LOG_I(ASN1,"\n"); } while(false) #else #define ASN_DEBUG(x...)