diff --git a/core/arch/arm/kernel/trace_ext.c b/core/arch/arm/kernel/trace_ext.c index 78b87a90eba..35fe8af6c59 100644 --- a/core/arch/arm/kernel/trace_ext.c +++ b/core/arch/arm/kernel/trace_ext.c @@ -31,7 +31,7 @@ #include #include -const char trace_ext_prefix[] = "TEE-CORE"; +const char trace_ext_prefix[] = "TC"; int trace_level = TRACE_LEVEL; static unsigned int puts_lock = SPINLOCK_UNLOCK; diff --git a/lib/libutils/ext/trace.c b/lib/libutils/ext/trace.c index 59e58ce0cd6..b03bdb242ce 100644 --- a/lib/libutils/ext/trace.c +++ b/lib/libutils/ext/trace.c @@ -53,9 +53,8 @@ int trace_get_level(void) static const char *trace_level_to_string(int level, bool level_ok) { - static const char lvl_strs[][9] = { - "UNKNOWN:", "ERROR: ", "INFO: ", "DEBUG: ", - "FLOW: " }; + static const char lvl_strs[][3] = { + "U/", "E/", "I/", "D/", "F/" }; int l = 0; if (!level_ok) @@ -68,58 +67,57 @@ static const char *trace_level_to_string(int level, bool level_ok) } /* Format trace of user ta. Inline with kernel ta */ -void trace_printf(const char *function, int line, int level, bool level_ok, - const char *fmt, ...) +void trace_printf(const char __maybe_unused *function, int __maybe_unused line, + int level, bool level_ok, const char *fmt, ...) { va_list ap; char buf[MAX_PRINT_SIZE]; size_t boffs = 0; int res; - int thread_id; + int __maybe_unused thread_id; if (level_ok && level > trace_level) return; - res = snprintk(buf, sizeof(buf), "%s ", + res = snprintk(buf, sizeof(buf), "%s", trace_level_to_string(level, level_ok)); if (res < 0) return; boffs += res; + res = snprintk(buf + boffs, sizeof(buf) - boffs, "%s ", + trace_ext_prefix); + if (res < 0) + return; + boffs += res; + +#if defined(CFG_TRACE_THREAD_ID) if (level_ok && !(BIT(level) & CFG_MSG_LONG_PREFIX_MASK)) thread_id = -1; else thread_id = trace_ext_get_thread_id(); if (thread_id >= 0) { - res = snprintk(buf + boffs, sizeof(buf) - boffs, "[0x%x] ", + res = snprintk(buf + boffs, sizeof(buf) - boffs, "[%02d] ", thread_id); if (res < 0) return; boffs += res; } +#endif - res = snprintk(buf + boffs, sizeof(buf) - boffs, "%s:", - trace_ext_prefix); - if (res < 0) - return; - boffs += res; - +#if defined(CFG_TRACE_FUNCTION) if (level_ok && !(BIT(level) & CFG_MSG_LONG_PREFIX_MASK)) function = NULL; if (function) { - res = snprintk(buf + boffs, sizeof(buf) - boffs, "%s:%d:", + res = snprintk(buf + boffs, sizeof(buf) - boffs, "%s:%d ", function, line); if (res < 0) return; boffs += res; } - - res = snprintk(buf + boffs, sizeof(buf) - boffs, " "); - if (res < 0) - return; - boffs += res; +#endif va_start(ap, fmt); res = vsnprintk(buf + boffs, sizeof(buf) - boffs, fmt, ap); diff --git a/mk/config.mk b/mk/config.mk index d7a35eb8690..3285ca9cbec 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -61,6 +61,12 @@ CFG_TEE_TA_LOG_LEVEL ?= 1 # CFG_TEE_TA_LOG_LEVEL. Otherwise, they are not output at all CFG_TEE_CORE_TA_TRACE ?= y +# When "y", the current thread will be shown +CFG_TRACE_THREAD_ID ?= y + +# When "y", the function and line will be shown +CFG_TRACE_FUNCTION ?= y + # If 1, enable debug features in TA memory allocation. # Debug features include check of buffer overflow, statistics, mark/check heap # feature. diff --git a/ta/arch/arm/user_ta_header.c b/ta/arch/arm/user_ta_header.c index b256fa90193..958736a8891 100644 --- a/ta/arch/arm/user_ta_header.c +++ b/ta/arch/arm/user_ta_header.c @@ -33,11 +33,7 @@ int trace_level = TRACE_LEVEL; -#ifdef TA_LOG_PREFIX -const char trace_ext_prefix[] = TA_LOG_PREFIX; -#else -const char trace_ext_prefix[] = "USER-TA"; -#endif +const char trace_ext_prefix[] = "TA"; #ifndef TA_VERSION #define TA_VERSION "Undefined version"